diff --git a/mysql/files/mysql_secure-installation-my.conf.j2 b/mysql/files/mysql_secure-installation-my.conf.j2 new file mode 100644 index 0000000..c5226dd --- /dev/null +++ b/mysql/files/mysql_secure-installation-my.conf.j2 @@ -0,0 +1,7 @@ +[client] +user=root +password={{ MYSQL_ROOT_PASSWORD }} + +[mysql] +user=root +password={{ MYSQL_ROOT_PASSWORD }} diff --git a/mysql/pkg.ansible.yml b/mysql/pkg.ansible.yml index fe9e259..d061372 100644 --- a/mysql/pkg.ansible.yml +++ b/mysql/pkg.ansible.yml @@ -14,6 +14,13 @@ - 127.0.0.1 - ::1 - localhost + - name: Set ~/.my.cnf file + template: + - src: files/mysql_secure-installation-my.conf.j2 + - dest: /root/.my.cnf + - mode: '0600' + vars: + MYSQL_ROOT_PASSWORD: "{{mysql_root_password}}" - name: Delete anonymous MySQL user mysql_user: name="" host={{item}} state=absent with_items: