ansible-roles/mysql/tasks/users_jessie.yml

60 lines
1.3 KiB
YAML
Raw Normal View History

---
- name: "Abort if MariaDB on Debian 8"
fail:
msg: "We can't create other users with 'debian-sys-maint' on Debian 8 with MariaDB.\nWe must give it the GRANT privilege before continuing."
when: mysql_variant == "mariadb"
# dependency for mysql_user and mysql_db
- name: python-mysqldb is installed (Ansible dependency)
apt:
name: python-mysqldb
state: present
tags:
- mysql
- name: create a password for mysqladmin
2017-08-12 18:11:13 +02:00
command: "apg -n 1 -m 16 -M lcN"
register: mysql_admin_password
2016-12-16 01:27:12 +01:00
changed_when: False
2017-11-14 09:39:24 +01:00
check_mode: no
tags:
- mysql
- name: there is a mysqladmin user
mysql_user:
name: mysqladmin
password: '{{ mysql_admin_password.stdout }}'
priv: "*.*:ALL,GRANT"
update_password: on_create
state: present
config_file: "/etc/mysql/debian.cnf"
register: create_mysqladmin_user
2017-01-04 18:53:37 +01:00
tags:
- mysql
- name: mysqladmin is the default user
ini_file:
dest: /root/.my.cnf
mode: "0600"
section: client
option: '{{ item.option }}'
value: '{{ item.value }}'
create: yes
loop:
2018-04-17 10:24:12 +02:00
- { option: 'user', value: 'mysqladmin' }
- { option: 'password', value: '{{ mysql_admin_password.stdout }}' }
when: create_mysqladmin_user.changed
tags:
- mysql
- name: remove root user
mysql_user:
name: root
host_all: yes
config_file: "/root/.my.cnf"
state: absent
tags:
- mysql