From 0fbf3fa4d868034a804b30cfc4716f52cefdd263 Mon Sep 17 00:00:00 2001 From: Solomon Gifford Date: Fri, 10 Apr 2015 09:26:24 -0400 Subject: [PATCH] Support for setting root password when running as local_action --- tasks/secure-installation.yml | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/tasks/secure-installation.yml b/tasks/secure-installation.yml index a3a4f90..acbd3ff 100644 --- a/tasks/secure-installation.yml +++ b/tasks/secure-installation.yml @@ -1,15 +1,16 @@ --- +- name: Get list of hosts for root user + command: mysql -NBe 'SELECT Host from mysql.user WHERE User = "root" order by (Host="localhost") ASC' + register: mysql_root_hosts + changed_when: false + # '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 + with_items: mysql_root_hosts.stdout_lines # Has to be after the root password assignment, for idempotency. - name: Copy .my.cnf file with root password credentials.