Skip to content

Commit d92ea65

Browse files
authored
Merge pull request #3 from singleplatform-eng/Upstream_changes
Upstream changes
2 parents 7f62587 + 4309731 commit d92ea65

File tree

14 files changed

+50
-25
lines changed

14 files changed

+50
-25
lines changed

README.md

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,21 @@ A list of files that should override the default global my.cnf. Each item in the
5858

5959
The MySQL databases to create. A database has the values `name`, `encoding` (defaults to `utf8`), `collation` (defaults to `utf8_general_ci`) and `replicate` (defaults to `1`, only used if replication is configured). The formats of these are the same as in the `mysql_db` module.
6060

61+
You can also delete a database (or ensure it's not on the server) by setting `state` to `absent` (defaults to `present`).
62+
6163
mysql_users: []
6264

63-
The MySQL users and their privileges. A user has the values `name`, `host` (defaults to `localhost`), `password`, `priv` (defaults to `*.*:USAGE`), `append_privs` (defaults to `no`), `state` (defaults to `present`). The formats of these are the same as in the `mysql_user` module.
65+
The MySQL users and their privileges. A user has the values:
66+
67+
- `name`
68+
- `host` (defaults to `localhost`)
69+
- `password` (can be plaintext or encrypted—if encrypted, set `encrypted: yes`)
70+
- `encrypted` (defaults to `no`)
71+
- `priv` (defaults to `*.*:USAGE`)
72+
- `append_privs` (defaults to `no`)
73+
- `state` (defaults to `present`)
74+
75+
The formats of these are the same as in the `mysql_user` module.
6476

6577
mysql_packages:
6678
- mysql
@@ -88,6 +100,7 @@ Override this if you want to install older versions of mysql on newer OS release
88100

89101
Default MySQL connection configuration.
90102

103+
mysql_log_file_group: mysql *adm on Debian*
91104
mysql_log: ""
92105
mysql_log_error: *default value depends on OS*
93106
mysql_syslog_tag: *default value depends on OS*

defaults/main.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,9 @@ mysql_sql_mode: ''
4949
# mysql_pid_file: /var/run/mysqld/mysqld.pid
5050
# mysql_socket: /var/lib/mysql/mysql.sock
5151

52+
# Log file settings.
53+
mysql_log_file_group: mysql
54+
5255
# Slow query log settings.
5356
mysql_slow_query_log_enabled: no
5457
mysql_slow_query_time: "2"

tasks/configure.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
path: "{{ mysql_slow_query_log_file }}"
5151
state: file
5252
owner: mysql
53-
group: mysql
53+
group: "{{ mysql_log_file_group }}"
5454
mode: 0640
5555
when: mysql_slow_query_log_enabled
5656

@@ -66,7 +66,7 @@
6666
path: "{{ mysql_log_error }}"
6767
state: file
6868
owner: mysql
69-
group: mysql
69+
group: "{{ mysql_log_file_group }}"
7070
mode: 0640
7171
when: mysql_log == "" and mysql_log_error != ""
7272

tasks/databases.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@
44
name: "{{ item.name }}"
55
collation: "{{ item.collation | default('utf8_general_ci') }}"
66
encoding: "{{ item.encoding | default('utf8') }}"
7-
state: present
7+
state: "{{ item.state | default('present') }}"
88
with_items: "{{ mysql_databases }}"

tasks/main.yml

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,16 @@
11
---
22
# Variable configuration.
3-
- include: variables.yml
3+
- include_tasks: variables.yml
44

55
# Setup/install tasks.
6-
- include: setup-RedHat.yml
6+
- include_tasks: setup-RedHat.yml
77
when: ansible_os_family == 'RedHat'
8-
static: no
98

10-
- include: setup-Debian.yml
9+
- include_tasks: setup-Debian.yml
1110
when: ansible_os_family == 'Debian'
12-
static: no
1311

14-
- include: setup-Archlinux.yml
12+
- include_tasks: setup-Archlinux.yml
1513
when: ansible_os_family == 'Archlinux'
16-
static: no
1714

1815
- name: Check if MySQL packages were installed.
1916
set_fact:
@@ -22,8 +19,8 @@
2219
or (arch_mysql_install_packages is defined and arch_mysql_install_packages.changed) }}"
2320

2421
# Configure MySQL.
25-
- include: configure.yml
26-
- include: secure-installation.yml
27-
- include: databases.yml
28-
- include: users.yml
29-
- include: replication.yml
22+
- include_tasks: configure.yml
23+
- include_tasks: secure-installation.yml
24+
- include_tasks: databases.yml
25+
- include_tasks: users.yml
26+
- include_tasks: replication.yml

tasks/replication.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
delegate_to: "{{ mysql_replication_master }}"
2828
register: master
2929
when: >
30-
((slave.Is_Slave is defined and not slave.Is_Slave) or (slave.Is_Slave is not defined and slave|failed))
30+
((slave.Is_Slave is defined and not slave.Is_Slave) or (slave.Is_Slave is not defined and slave is failed))
3131
and (mysql_replication_role == 'slave')
3232
and (mysql_replication_master != '')
3333
@@ -41,14 +41,14 @@
4141
master_log_pos: "{{ master.Position }}"
4242
ignore_errors: True
4343
when: >
44-
((slave.Is_Slave is defined and not slave.Is_Slave) or (slave.Is_Slave is not defined and slave|failed))
44+
((slave.Is_Slave is defined and not slave.Is_Slave) or (slave.Is_Slave is not defined and slave is failed))
4545
and (mysql_replication_role == 'slave')
4646
and (mysql_replication_master != '')
4747
and mysql_replication_user
4848
4949
- name: Start replication.
5050
mysql_replication: mode=startslave
5151
when: >
52-
((slave.Is_Slave is defined and not slave.Is_Slave) or (slave.Is_Slave is not defined and slave|failed))
52+
((slave.Is_Slave is defined and not slave.Is_Slave) or (slave.Is_Slave is not defined and slave is failed))
5353
and (mysql_replication_role == 'slave')
5454
and (mysql_replication_master != '')

tasks/setup-Archlinux.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@
77
with_items: "{{ mysql_packages }}"
88
register: arch_mysql_install_packages
99

10-
# Init the database if mysql is newly installed
11-
- command: mysql_install_db --user=mysql --basedir=/usr --datadir=/var/lib/mysql
10+
- name: Run mysql_install_db if MySQL packages were changed.
11+
command: mysql_install_db --user=mysql --basedir=/usr --datadir=/var/lib/mysql
1212
when: arch_mysql_install_packages.changed

tasks/setup-Debian.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,15 @@
2929
apt: update_cache=yes
3030
when: mysql_installed.stat.exists == false
3131

32+
- name: Determine required MySQL Python libraries.
33+
set_fact:
34+
deb_mysql_python_package: "{% if 'python3' in ansible_python_interpreter|default('') %}python3-mysqldb{% else %}python-mysqldb{% endif %}"
35+
3236
- name: Ensure MySQL Python libraries are installed.
33-
apt: "name=python-mysqldb state=installed"
37+
apt: "name={{ deb_mysql_python_package }} state=present"
3438

3539
- name: Ensure MySQL packages are installed.
36-
apt: "name={{ item }} state=installed"
40+
apt: "name={{ item }} state=present"
3741
with_items: "{{ mysql_packages }}"
3842
register: deb_mysql_install_packages
3943

tasks/setup-RedHat.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
---
22
- name: Ensure MySQL packages are installed.
3-
yum: "name={{ item }} state=installed enablerepo={{ mysql_enablerepo }}"
3+
yum: "name={{ item }} state=present enablerepo={{ mysql_enablerepo }}"
44
with_items: "{{ mysql_packages }}"
55
register: rh_mysql_install_packages
66

77
- name: Ensure MySQL Python libraries are installed.
8-
yum: "name=MySQL-python state=installed enablerepo={{ mysql_enablerepo }}"
8+
yum: "name=MySQL-python state=present enablerepo={{ mysql_enablerepo }}"

tasks/users.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,6 @@
77
priv: "{{ item.priv | default('*.*:USAGE') }}"
88
state: "{{ item.state | default('present') }}"
99
append_privs: "{{ item.append_privs | default('no') }}"
10+
encrypted: "{{ item.encrypted | default('no') }}"
1011
with_items: "{{ mysql_users }}"
1112
no_log: true

0 commit comments

Comments
 (0)