From d01b0be9b726c0d56c189ea99659bf7c1b7fe222 Mon Sep 17 00:00:00 2001 From: lavenderguitar Date: Fri, 7 Jan 2022 19:34:34 -0500 Subject: [PATCH] Ansible for MySQL Secure Installation --- mysql_secure_installation.yml | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 mysql_secure_installation.yml diff --git a/mysql_secure_installation.yml b/mysql_secure_installation.yml new file mode 100644 index 0000000..cb950f7 --- /dev/null +++ b/mysql_secure_installation.yml @@ -0,0 +1,33 @@ +- name: "MySQL set root password" + become: yes + mysql_user: + login_user: "{{ mysql.user | default('root') }}" + login_password: "{{ mysql.password }}" + login_host: "{{ mysql.host | default('localhost') }}" + login_port: "{{ mysql.port | default('3306') }}" + user: "root" + password: "{{ icinga2.mysql.password }}" + host: "localhost" + when: use_local_db_instance + +- name: "Delete anonymous MySQL server user" + become: true + mysql_user: + login_user: "{{ mysql.user | default('root') }}" + login_password: "{{ mysql.password }}" + login_host: "{{ mysql.host | default('localhost') }}" + login_port: "{{ mysql.port | default('3306') }}" + user: "" + state: absent + when: use_local_db_instance + +- name: "Remove the MySQL test database" + become: true + mysql_db: + login_user: "{{ mysql.user | default('root') }}" + login_password: "{{ mysql.password }}" + login_host: "{{ mysql.host | default('localhost') }}" + login_port: "{{ mysql.port | default('3306') }}" + db: "test" + state: absent + when: use_local_db_instance