]> gitweb.hamatoma.de Git - ansknife.git/commitdiff
Improvement mysql
authorHamatoma <author@hamatoma.de>
Fri, 16 May 2025 11:53:33 +0000 (13:53 +0200)
committerHamatoma <author@hamatoma.de>
Fri, 16 May 2025 11:53:33 +0000 (13:53 +0200)
playbooks.templates/mysql_users.yaml [new file with mode: 0644]

diff --git a/playbooks.templates/mysql_users.yaml b/playbooks.templates/mysql_users.yaml
new file mode 100644 (file)
index 0000000..d38294e
--- /dev/null
@@ -0,0 +1,35 @@
+- name: Creates MySQL 
+  hosts: all
+  vars_files:
+    - ../vars/common.yaml
+    - ../vars/mysql_vault.yaml
+    - ../vars/mysql.yaml
+  tasks:
+    - name: Creates the MySQL users with passwords
+      ansible.builtin.mysql_user:
+        name: "{{ item.name }}"
+        password: "{{ item.password }}"
+        host: "{{ item.host }}"
+        state: present
+        login_user: "{{ dba_name }}"
+        login_password: "{{ dba_password }}"
+      when: item.password != ""
+      with_items: "{{ mysql_users }}"
+
+    - name: Creates the MySQL users without passwords
+      ansible.builtin.mysql_user:
+        name: "{{ item.name }}"
+        host: "{{ item.host }}"
+        state: present
+        login_user: "{{ dba_name }}"
+        login_password: "{{ dba_password }}"
+      when: item.password == ""
+      with_items: "{{ mysql_users }}"
+
+    - name: Creates the MySQL databases
+      ansible.builtin.mysql_db:
+        name: "{{ item }}"
+        state: present
+        login_user: "{{ dba_name }}"
+        login_password: "{{ dba_password }}"
+      loop: "{{ mysql_dbs }}"