Skip to content

Commit 364cb3e

Browse files
committed
Merge pull request geerlingguy#28 from BlackMesh/local-action-password
geerlingguy#28 Make root password configuration more flexible, able to work with local_action
2 parents 3d0762b + 0fbf3fa commit 364cb3e

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

tasks/secure-installation.yml

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
11
---
2+
- name: Get list of hosts for root user
3+
command: mysql -NBe 'SELECT Host from mysql.user WHERE User = "root" order by (Host="localhost") ASC'
4+
register: mysql_root_hosts
5+
changed_when: false
6+
27
# 'localhost' needs to be last for idempotency.
38
- name: Update MySQL root password for localhost root account.
49
mysql_user:
510
name: "root"
611
host: "{{ item }}"
712
password: "{{ mysql_root_password }}"
8-
with_items:
9-
- "{{ ansible_hostname }}"
10-
- 127.0.0.1
11-
- ::1
12-
- localhost
13+
with_items: mysql_root_hosts.stdout_lines
1314

1415
# Has to be after the root password assignment, for idempotency.
1516
- name: Copy .my.cnf file with root password credentials.

0 commit comments

Comments
 (0)