From: Hamatoma Date: Fri, 16 May 2025 11:53:33 +0000 (+0200) Subject: Improvement mysql X-Git-Url: https://gitweb.hamatoma.de/?a=commitdiff_plain;h=9d8aa1a2ed7dda7b0494a4268765f01db1fab24d;p=ansknife.git Improvement mysql --- diff --git a/playbooks.templates/mysql_users.yaml b/playbooks.templates/mysql_users.yaml new file mode 100644 index 0000000..d38294e --- /dev/null +++ b/playbooks.templates/mysql_users.yaml @@ -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 }}"