mirror of
https://github.com/aljazceru/ansible-role-mysql.git
synced 2025-12-24 05:44:20 +01:00
27 lines
701 B
YAML
27 lines
701 B
YAML
---
|
|
# '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
|
|
|
|
# Has to be after the root password assignment, for idempotency.
|
|
- name: Copy .my.cnf file with root password credentials.
|
|
template:
|
|
src: "python-my.cnf.j2"
|
|
dest: "{{ mysql_user_home }}/.my.cnf"
|
|
owner: root
|
|
group: root
|
|
mode: 0600
|
|
|
|
- name: Remove anonymous MySQL user.
|
|
mysql_user: "name='' state=absent"
|
|
|
|
- name: Remove MySQL test database.
|
|
mysql_db: "name='test' state=absent" |