mirror of
https://github.com/aljazceru/ansible-role-mysql.git
synced 2025-12-21 19:34:20 +01:00
Fixes #22: Make MySQL root user password settings more reliable.
This commit is contained in:
@@ -1,20 +1,15 @@
|
|||||||
---
|
---
|
||||||
- name: Check if .my.cnf file already exists.
|
# 'localhost' needs to be last for idempotency.
|
||||||
stat: "path={{ mysql_user_home }}/.my.cnf"
|
- name: Update MySQL root password for localhost root account.
|
||||||
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.
|
|
||||||
mysql_user:
|
mysql_user:
|
||||||
name: "root"
|
name: "root"
|
||||||
host: "{{ item }}"
|
host: "{{ item }}"
|
||||||
password: "{{ mysql_root_password }}"
|
password: "{{ mysql_root_password }}"
|
||||||
with_items:
|
with_items:
|
||||||
|
- "{{ ansible_hostname }}"
|
||||||
- 127.0.0.1
|
- 127.0.0.1
|
||||||
- ::1
|
- ::1
|
||||||
- localhost
|
- localhost
|
||||||
when: mycnf_file.stat.exists == false
|
|
||||||
|
|
||||||
# Has to be after the root password assignment, for idempotency.
|
# Has to be after the root password assignment, for idempotency.
|
||||||
- name: Copy .my.cnf file with root password credentials.
|
- name: Copy .my.cnf file with root password credentials.
|
||||||
|
|||||||
Reference in New Issue
Block a user