First untested version
This commit is contained in:
		
							
								
								
									
										34
									
								
								LICENSE
									
									
									
									
									
								
							
							
						
						
									
										34
									
								
								LICENSE
									
									
									
									
									
								
							@@ -1,21 +1,19 @@
 | 
				
			|||||||
Copyright (c) <year> <owner> All rights reserved.
 | 
					MIT License Copyright (c) 2022 Oleg Vasiliev <zmey1992@ya.ru>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
Permission is granted to make and distribute verbatim copies of this
 | 
					Permission is hereby granted, free of charge, to any person obtaining a copy
 | 
				
			||||||
manual provided the copyright notice and this permission notice are
 | 
					of this software and associated documentation files (the "Software"), to deal
 | 
				
			||||||
preserved on all copies.
 | 
					in the Software without restriction, including without limitation the rights
 | 
				
			||||||
 | 
					to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 | 
				
			||||||
 | 
					copies of the Software, and to permit persons to whom the Software is furnished
 | 
				
			||||||
 | 
					to do so, subject to the following conditions:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
Permission is granted to copy and distribute modified versions of
 | 
					The above copyright notice and this permission notice (including the next
 | 
				
			||||||
this manual under the conditions for verbatim copying, provided that
 | 
					paragraph) shall be included in all copies or substantial portions of the
 | 
				
			||||||
the entire resulting derived work is distributed under the terms of
 | 
					Software.
 | 
				
			||||||
a permission notice identical to this one.
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
Since the Linux kernel and libraries are constantly changing, this
 | 
					THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 | 
				
			||||||
manual page may be incorrect or out-of-date.  The author(s) assume
 | 
					IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
 | 
				
			||||||
no responsibility for errors or omissions, or for damages resulting
 | 
					FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS
 | 
				
			||||||
from the use of the information contained herein.  The author(s) may
 | 
					OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
 | 
				
			||||||
not have taken the same level of care in the production of this
 | 
					WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
 | 
				
			||||||
manual, which is licensed free of charge, as they might when working
 | 
					OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 | 
				
			||||||
professionally.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
Formatted or processed versions of this manual, if unaccompanied by
 | 
					 | 
				
			||||||
the source, must acknowledge the copyright and authors of this work.
 | 
					 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										17
									
								
								defaults/main.yml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										17
									
								
								defaults/main.yml
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,17 @@
 | 
				
			|||||||
 | 
					---
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					mysql_packages:
 | 
				
			||||||
 | 
					  - mariadb
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					mysql_service_name: mariadb
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					mysql_configs_user: root
 | 
				
			||||||
 | 
					mysql_configs_mode: 0644
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					mysql_main_conf:
 | 
				
			||||||
 | 
					  # src:
 | 
				
			||||||
 | 
					  dest: /etc/my.cnf
 | 
				
			||||||
 | 
					mysql_confd: []
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					mysql_databases: []
 | 
				
			||||||
 | 
					mysql_users: []
 | 
				
			||||||
							
								
								
									
										6
									
								
								handlers/main.yml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										6
									
								
								handlers/main.yml
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,6 @@
 | 
				
			|||||||
 | 
					---
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					- name: MySQL | Restart
 | 
				
			||||||
 | 
					  service:
 | 
				
			||||||
 | 
					    name: "{{ mysql_service_name }}"
 | 
				
			||||||
 | 
					    state: restarted
 | 
				
			||||||
							
								
								
									
										49
									
								
								tasks/main.yml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										49
									
								
								tasks/main.yml
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,49 @@
 | 
				
			|||||||
 | 
					---
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					- name: MySQL | Install packages
 | 
				
			||||||
 | 
					  package:
 | 
				
			||||||
 | 
					    name: "{{ mysql_packages }}"
 | 
				
			||||||
 | 
					    state: present
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					- name: MySQL | Deploy main config
 | 
				
			||||||
 | 
					  template:
 | 
				
			||||||
 | 
					    src:   "{{ mysql_main_conf.src }}"
 | 
				
			||||||
 | 
					    dest:  "{{ mysql_main_conf.dest }}"
 | 
				
			||||||
 | 
					    mode:  "{{ mysql_configs_mode }}"
 | 
				
			||||||
 | 
					    owner: "{{ mysql_configs_user }}"
 | 
				
			||||||
 | 
					    group: "{{ mysql_configs_user }}"
 | 
				
			||||||
 | 
					  when: mysql_main_conf.src is defined
 | 
				
			||||||
 | 
					  notify: MySQL | Restart
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					- name: MySQL | Deploy conf.d files
 | 
				
			||||||
 | 
					    template:
 | 
				
			||||||
 | 
					    src:   "{{ item.src }}"
 | 
				
			||||||
 | 
					    dest:  "{{ item.dest }}"
 | 
				
			||||||
 | 
					    mode:  "{{ mysql_configs_mode }}"
 | 
				
			||||||
 | 
					    owner: "{{ mysql_configs_user }}"
 | 
				
			||||||
 | 
					    group: "{{ mysql_configs_user }}"
 | 
				
			||||||
 | 
					  with_items: "{{ mysql_confd }}"
 | 
				
			||||||
 | 
					  notify: MySQL | Restart
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					- name: MySQL | Enable and start
 | 
				
			||||||
 | 
					  service:
 | 
				
			||||||
 | 
					    name: "{{ mysql_service_name }}"
 | 
				
			||||||
 | 
					    state: started
 | 
				
			||||||
 | 
					    enables: yes
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					- name: MySQL | Create databases
 | 
				
			||||||
 | 
					  mysql_db:
 | 
				
			||||||
 | 
					    name:  "{{ item.name }}"
 | 
				
			||||||
 | 
					    state: "{{ item.state | d(omit) }}"
 | 
				
			||||||
 | 
					  with_items: "{{ mysql_databases }}"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					- name: MySQL | Create users
 | 
				
			||||||
 | 
					  mysql_user:
 | 
				
			||||||
 | 
					    name:     "{{ item.name }}"
 | 
				
			||||||
 | 
					    state:    "{{ item.state | d(omit) }}"
 | 
				
			||||||
 | 
					    password: "{{ item.password | d(omit) }}"
 | 
				
			||||||
 | 
					    priv:     "{{ item.priv | d(omit) }}"
 | 
				
			||||||
 | 
					  with_items:  "{{ mysql_users }}"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					- name: unbound | Run handlers
 | 
				
			||||||
 | 
					  meta: flush_handlers
 | 
				
			||||||
		Reference in New Issue
	
	Block a user