Skip to content

Commit 6555d98

Browse files
authored
Merge pull request geerlingguy#478 from geerlingguy/fix-idempotence
Fix idempotence for Debian 11 and Debian 10 tests
2 parents 62b227c + f0b2c04 commit 6555d98

File tree

3 files changed

+87
-51
lines changed

3 files changed

+87
-51
lines changed

.github/workflows/ci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,10 @@ jobs:
4343
distro:
4444
- rockylinux8
4545
- centos7
46+
- ubuntu2204
4647
- ubuntu2004
47-
- ubuntu1804
48-
- debian10
4948
- debian11
49+
- debian10
5050

5151
steps:
5252
- name: Check out the codebase.

README.md

Lines changed: 84 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -8,59 +8,79 @@ Installs and configures MySQL or MariaDB server on RHEL/CentOS or Debian/Ubuntu
88

99
No special requirements; note that this role requires root access, so either run it in a playbook with a global `become: yes`, or invoke the role in your playbook like:
1010

11-
- hosts: database
12-
roles:
13-
- role: geerlingguy.mysql
14-
become: yes
11+
```yaml
12+
- hosts: database
13+
roles:
14+
- role: geerlingguy.mysql
15+
become: yes
16+
```
1517
1618
## Role Variables
1719
1820
Available variables are listed below, along with default values (see `defaults/main.yml`):
1921

20-
mysql_user_home: /root
21-
mysql_user_name: root
22-
mysql_user_password: root
22+
```yaml
23+
mysql_user_home: /root
24+
mysql_user_name: root
25+
mysql_user_password: root
26+
```
2327

2428
The home directory inside which Python MySQL settings will be stored, which Ansible will use when connecting to MySQL. This should be the home directory of the user which runs this Ansible role. The `mysql_user_name` and `mysql_user_password` can be set if you are running this role under a non-root user account and want to set a non-root user.
2529

26-
mysql_root_home: /root
27-
mysql_root_username: root
28-
mysql_root_password: root
30+
```yaml
31+
mysql_root_home: /root
32+
mysql_root_username: root
33+
mysql_root_password: root
34+
```
2935

3036
The MySQL root user account details.
3137

32-
mysql_root_password_update: false
38+
```yaml
39+
mysql_root_password_update: false
40+
```
3341

3442
Whether to force update the MySQL root user's password. By default, this role will only change the root user's password when MySQL is first configured. You can force an update by setting this to `yes`.
3543

3644
> Note: If you get an error like `ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)` after a failed or interrupted playbook run, this usually means the root password wasn't originally updated to begin with. Try either removing the `.my.cnf` file inside the configured `mysql_user_home` or updating it and setting `password=''` (the insecure default password). Run the playbook again, with `mysql_root_password_update` set to `yes`, and the setup should complete.
3745

3846
> Note: If you get an error like `ERROR 1698 (28000): Access denied for user 'root'@'localhost' (using password: YES)` when trying to log in from the CLI you might need to run as root or sudoer.
3947

40-
mysql_enabled_on_startup: true
48+
```yaml
49+
mysql_enabled_on_startup: true
50+
```
4151

4252
Whether MySQL should be enabled on startup.
4353

44-
mysql_config_file: *default value depends on OS*
45-
mysql_config_include_dir: *default value depends on OS*
46-
54+
```yaml
55+
mysql_config_file: *default value depends on OS*
56+
mysql_config_include_dir: *default value depends on OS*
57+
```
58+
4759
The main my.cnf configuration file and include directory.
4860

49-
overwrite_global_mycnf: true
61+
```yaml
62+
overwrite_global_mycnf: true
63+
```
5064

5165
Whether the global my.cnf should be overwritten each time this role is run. Setting this to `no` tells Ansible to only create the `my.cnf` file if it doesn't exist. This should be left at its default value (`yes`) if you'd like to use this role's variables to configure MySQL.
5266

53-
mysql_config_include_files: []
67+
```yaml
68+
mysql_config_include_files: []
69+
```
5470

5571
A list of files that should override the default global my.cnf. Each item in the array requires a "src" parameter which is a path to a file. An optional "force" parameter can force the file to be updated each time ansible runs.
5672

57-
mysql_databases: []
73+
```yaml
74+
mysql_databases: []
75+
```
5876

5977
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.
6078

6179
You can also delete a database (or ensure it's not on the server) by setting `state` to `absent` (defaults to `present`).
6280

63-
mysql_users: []
81+
```yaml
82+
mysql_users: []
83+
```
6484

6585
The MySQL users and their privileges. A user has the values:
6686

@@ -74,55 +94,71 @@ The MySQL users and their privileges. A user has the values:
7494

7595
The formats of these are the same as in the `mysql_user` module.
7696

77-
mysql_packages:
78-
- mysql
79-
- mysql-server
97+
```yaml
98+
mysql_packages:
99+
- mysql
100+
- mysql-server
101+
```
80102

81103
(OS-specific, RedHat/CentOS defaults listed here) Packages to be installed. In some situations, you may need to add additional packages, like `mysql-devel`.
82104

83-
mysql_enablerepo: ""
105+
```yaml
106+
mysql_enablerepo: ""
107+
```
84108

85109
(RedHat/CentOS only) If you have enabled any additional repositories (might I suggest geerlingguy.repo-epel or geerlingguy.repo-remi), those repositories can be listed under this variable (e.g. `remi,epel`). This can be handy, as an example, if you want to install later versions of MySQL.
86110

87-
mysql_python_package_debian: python3-mysqldb
111+
```yaml
112+
mysql_python_package_debian: python3-mysqldb
113+
```
88114

89115
(Ubuntu/Debian only) If you need to explicitly override the MySQL Python package, you can set it here. Set this to `python-mysqldb` if using older distributions running Python 2.
90116

91-
mysql_port: "3306"
92-
mysql_bind_address: '0.0.0.0'
93-
mysql_datadir: /var/lib/mysql
94-
mysql_socket: *default value depends on OS*
95-
mysql_pid_file: *default value depends on OS*
117+
```yaml
118+
mysql_port: "3306"
119+
mysql_bind_address: '0.0.0.0'
120+
mysql_datadir: /var/lib/mysql
121+
mysql_socket: *default value depends on OS*
122+
mysql_pid_file: *default value depends on OS*
123+
```
96124

97125
Default MySQL connection configuration.
98126

99-
mysql_log_file_group: mysql *adm on Debian*
100-
mysql_log: ""
101-
mysql_log_error: *default value depends on OS*
102-
mysql_syslog_tag: *default value depends on OS*
127+
```yaml
128+
mysql_log_file_group: mysql *adm on Debian*
129+
mysql_log: ""
130+
mysql_log_error: *default value depends on OS*
131+
mysql_syslog_tag: *default value depends on OS*
132+
```yaml
103133

104134
MySQL logging configuration. Setting `mysql_log` (the general query log) or `mysql_log_error` to `syslog` will make MySQL log to syslog using the `mysql_syslog_tag`.
105135

106-
mysql_slow_query_log_enabled: false
107-
mysql_slow_query_log_file: *default value depends on OS*
108-
mysql_slow_query_time: 2
136+
```yaml
137+
mysql_slow_query_log_enabled: false
138+
mysql_slow_query_log_file: *default value depends on OS*
139+
mysql_slow_query_time: 2
140+
```
109141

110142
Slow query log settings. Note that the log file will be created by this role, but if you're running on a server with SELinux or AppArmor, you may need to add this path to the allowed paths for MySQL, or disable the mysql profile. For example, on Debian/Ubuntu, you can run `sudo ln -s /etc/apparmor.d/usr.sbin.mysqld /etc/apparmor.d/disable/usr.sbin.mysqld && sudo service apparmor restart`.
111143

112-
mysql_key_buffer_size: "256M"
113-
mysql_max_allowed_packet: "64M"
114-
mysql_table_open_cache: "256"
115-
[...]
144+
```yaml
145+
mysql_key_buffer_size: "256M"
146+
mysql_max_allowed_packet: "64M"
147+
mysql_table_open_cache: "256"
148+
...
149+
```
116150

117-
The rest of the settings in `defaults/main.yml` control MySQL's memory usage and some other common settings. The default values are tuned for a server where MySQL can consume ~512 MB RAM, so you should consider adjusting them to suit your particular server better.
151+
The rest of the settings in `defaults/main.yml` control MySQL's memory usage and some other common settings. The default values are tuned for a server where MySQL can consume 512 MB RAM, so you should consider adjusting them to suit your particular server better.
118152

119-
mysql_server_id: "1"
120-
mysql_max_binlog_size: "100M"
121-
mysql_binlog_format: "ROW"
122-
mysql_expire_logs_days: "10"
123-
mysql_replication_role: ''
124-
mysql_replication_master: ''
125-
mysql_replication_user: {}
153+
```yaml
154+
mysql_server_id: "1"
155+
mysql_max_binlog_size: "100M"
156+
mysql_binlog_format: "ROW"
157+
mysql_expire_logs_days: "10"
158+
mysql_replication_role: ''
159+
mysql_replication_master: ''
160+
mysql_replication_user: {}
161+
```
126162

127163
Replication settings. Set `mysql_server_id` and `mysql_replication_role` by server (e.g. the master would be ID `1`, with the `mysql_replication_role` of `master`, and the slave would be ID `2`, with the `mysql_replication_role` of `slave`). The `mysql_replication_user` uses the same keys as individual list items in `mysql_users`, and is created on master servers, and used to replicate on all the slaves.
128164

tasks/setup-Debian.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
- name: Check if MySQL is already installed.
3-
stat: path=/etc/init.d/{{ mysql_daemon }}
3+
stat: path={{ mysql_config_file }}
44
register: mysql_installed
55

66
- name: Update apt cache if MySQL is not yet installed.

0 commit comments

Comments
 (0)