2015-05-29 19:42:43 +02:00
|
|
|
---
|
|
|
|
# 'localhost' needs to be the last item for idempotency, the mysql_user docs
|
|
|
|
- name: Secure the mysql root user
|
|
|
|
mysql_user: name=root host={{ item }} password={{ mysql_root_password }}
|
|
|
|
when: mysql_root_password is defined
|
|
|
|
with_items:
|
|
|
|
- '{{ ansible_hostname }}'
|
|
|
|
- 127.0.0.1
|
|
|
|
- ::1
|
|
|
|
- localhost
|
|
|
|
ignore_errors: True
|
2016-03-17 21:35:04 +01:00
|
|
|
tags: mysql
|
2015-05-29 19:42:43 +02:00
|
|
|
|
|
|
|
- name: Secure the mysql root user
|
|
|
|
mysql_user: name=root host={{ item }} password=""
|
|
|
|
when: mysql_root_password is not defined
|
|
|
|
with_items:
|
|
|
|
- '{{ ansible_hostname }}'
|
|
|
|
- 127.0.0.1
|
|
|
|
- ::1
|
|
|
|
- localhost
|
|
|
|
ignore_errors: True
|
2016-03-17 21:35:04 +01:00
|
|
|
tags: mysql
|
2015-05-29 19:42:43 +02:00
|
|
|
|
|
|
|
- name: Install the .my.cnf file with root password credentials
|
|
|
|
template: src=dot_my.cnf.j2 dest=/root/.my.cnf owner=root group=root mode=0400
|
|
|
|
when: mysql_root_password is defined
|
2016-03-17 21:35:04 +01:00
|
|
|
tags: mysql
|
2015-05-29 19:42:43 +02:00
|
|
|
|
2016-03-17 21:35:04 +01:00
|
|
|
- name: delete anonymous MySQL server user for the server hostname
|
2015-05-29 19:42:43 +02:00
|
|
|
mysql_user: user="" host="{{ ansible_hostname }}" state="absent"
|
2016-03-17 21:35:04 +01:00
|
|
|
tags: mysql
|
2015-05-29 19:42:43 +02:00
|
|
|
|
|
|
|
- name: delete anonymous MySQL server user for localhost
|
|
|
|
mysql_user: user="" state="absent"
|
2016-03-17 21:35:04 +01:00
|
|
|
tags: mysql
|
2015-05-29 19:42:43 +02:00
|
|
|
|
|
|
|
- name: remove the MySQL test database
|
|
|
|
mysql_db: db=test state=absent
|
2016-03-17 21:35:04 +01:00
|
|
|
tags: mysql
|