diff --git a/LICENSE b/LICENSE index 764635a..ca49f44 100644 --- a/LICENSE +++ b/LICENSE @@ -1,21 +1,19 @@ -Copyright (c) All rights reserved. +MIT License Copyright (c) 2022 Oleg Vasiliev -Permission is granted to make and distribute verbatim copies of this -manual provided the copyright notice and this permission notice are -preserved on all copies. +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +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 -this manual under the conditions for verbatim copying, provided that -the entire resulting derived work is distributed under the terms of -a permission notice identical to this one. +The above copyright notice and this permission notice (including the next +paragraph) shall be included in all copies or substantial portions of the +Software. -Since the Linux kernel and libraries are constantly changing, this -manual page may be incorrect or out-of-date. The author(s) assume -no responsibility for errors or omissions, or for damages resulting -from the use of the information contained herein. The author(s) may -not have taken the same level of care in the production of this -manual, which is licensed free of charge, as they might when working -professionally. - -Formatted or processed versions of this manual, if unaccompanied by -the source, must acknowledge the copyright and authors of this work. +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS +FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS +OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF +OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/defaults/main.yml b/defaults/main.yml new file mode 100644 index 0000000..a4ce268 --- /dev/null +++ b/defaults/main.yml @@ -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: [] diff --git a/handlers/main.yml b/handlers/main.yml new file mode 100644 index 0000000..2688b5f --- /dev/null +++ b/handlers/main.yml @@ -0,0 +1,6 @@ +--- + +- name: MySQL | Restart + service: + name: "{{ mysql_service_name }}" + state: restarted diff --git a/tasks/main.yml b/tasks/main.yml new file mode 100644 index 0000000..cedb6d8 --- /dev/null +++ b/tasks/main.yml @@ -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