From 3d0762b7dd2ffb83cde56f56647f9e11aa53a9df Mon Sep 17 00:00:00 2001 From: Jeff Geerling Date: Thu, 9 Apr 2015 11:18:58 -0500 Subject: [PATCH] Fixes #22: Make MySQL root user password settings more reliable. --- tasks/secure-installation.yml | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/tasks/secure-installation.yml b/tasks/secure-installation.yml index db44d50..a3a4f90 100644 --- a/tasks/secure-installation.yml +++ b/tasks/secure-installation.yml @@ -1,20 +1,15 @@ --- -- name: Check if .my.cnf file already exists. - stat: "path={{ mysql_user_home }}/.my.cnf" - register: mycnf_file - -# 'localhost' needs to be the last item for idempotency, see -# http://ansible.cc/docs/modules.html#mysql-user -- name: Update MySQL root password for all root accounts. +# 'localhost' needs to be last for idempotency. +- name: Update MySQL root password for localhost root account. mysql_user: name: "root" host: "{{ item }}" password: "{{ mysql_root_password }}" with_items: + - "{{ ansible_hostname }}" - 127.0.0.1 - ::1 - localhost - when: mycnf_file.stat.exists == false # Has to be after the root password assignment, for idempotency. - name: Copy .my.cnf file with root password credentials.