From 8a7b7f0b81d80851b43be19af0e85b106e28338d Mon Sep 17 00:00:00 2001 From: LinuxSquare Date: Sun, 1 Dec 2024 18:20:29 +0100 Subject: [PATCH] add .my.cnf --- mysql/files/mysql_secure-installation-my.conf.j2 | 7 +++++++ mysql/pkg.ansible.yml | 7 +++++++ 2 files changed, 14 insertions(+) create mode 100644 mysql/files/mysql_secure-installation-my.conf.j2 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: