mysql: use /etc/mysql/debian.cnf for configuration
This commit is contained in:
parent
65f91f09b0
commit
0481c51a40
|
@ -7,14 +7,14 @@
|
||||||
name: python-mysqldb
|
name: python-mysqldb
|
||||||
state: present
|
state: present
|
||||||
tags:
|
tags:
|
||||||
- mysql
|
- mysql
|
||||||
|
|
||||||
- name: create a password for mysqladmin
|
- name: create a password for mysqladmin
|
||||||
shell: perl -e 'print map{("a".."z","A".."Z",0..9)[int(rand(62))]}(1..16)'
|
shell: perl -e 'print map{("a".."z","A".."Z",0..9)[int(rand(62))]}(1..16)'
|
||||||
register: mysql_admin_password
|
register: mysql_admin_password
|
||||||
changed_when: False
|
changed_when: False
|
||||||
tags:
|
tags:
|
||||||
- mysql
|
- mysql
|
||||||
|
|
||||||
- name: there is a mysqladmin user
|
- name: there is a mysqladmin user
|
||||||
mysql_user:
|
mysql_user:
|
||||||
|
@ -23,19 +23,8 @@
|
||||||
priv: "*.*:ALL,GRANT"
|
priv: "*.*:ALL,GRANT"
|
||||||
update_password: on_create
|
update_password: on_create
|
||||||
state: present
|
state: present
|
||||||
|
config_file: "/etc/mysql/debian.cnf"
|
||||||
register: create_mysqladmin_user
|
register: create_mysqladmin_user
|
||||||
tags:
|
|
||||||
- mysql
|
|
||||||
|
|
||||||
# Ansible 2.2 allows to create with ini_file
|
|
||||||
# before: we have to create the file beforehand
|
|
||||||
|
|
||||||
- name: touch /root/.my.cnf
|
|
||||||
file:
|
|
||||||
path: /root/.my.cnf
|
|
||||||
state: touch
|
|
||||||
changed_when: False
|
|
||||||
when: create_mysqladmin_user.changed
|
|
||||||
tags:
|
tags:
|
||||||
- mysql
|
- mysql
|
||||||
|
|
||||||
|
@ -46,19 +35,20 @@
|
||||||
section: client
|
section: client
|
||||||
option: '{{ item.option }}'
|
option: '{{ item.option }}'
|
||||||
value: '{{ item.value }}'
|
value: '{{ item.value }}'
|
||||||
|
create: yes
|
||||||
with_items:
|
with_items:
|
||||||
- { option: 'user', value: 'mysqladmin' }
|
- { option: 'user', value: 'mysqladmin' }
|
||||||
- { option: password, value: '{{ mysql_admin_password.stdout }}' }
|
- { option: password, value: '{{ mysql_admin_password.stdout }}' }
|
||||||
when: create_mysqladmin_user.changed
|
when: create_mysqladmin_user.changed
|
||||||
tags:
|
tags:
|
||||||
- mysql
|
- mysql
|
||||||
|
|
||||||
- name: remove root user
|
- name: remove root user
|
||||||
mysql_user:
|
mysql_user:
|
||||||
name: root
|
name: root
|
||||||
#host_all: yes
|
#host_all: yes
|
||||||
host: "{{ item }}"
|
host: "{{ item }}"
|
||||||
config_file: /root/.my.cnf
|
config_file: "/etc/mysql/debian.cnf"
|
||||||
state: absent
|
state: absent
|
||||||
with_items:
|
with_items:
|
||||||
- "localhost"
|
- "localhost"
|
||||||
|
@ -66,4 +56,4 @@
|
||||||
- "::1"
|
- "::1"
|
||||||
- "{{ ansible_hostname }}"
|
- "{{ ansible_hostname }}"
|
||||||
tags:
|
tags:
|
||||||
- mysql
|
- mysql
|
||||||
|
|
Loading…
Reference in a new issue