Skip to content

Commit

Permalink
fix: lint: yaml[truthy] warnings
Browse files Browse the repository at this point in the history
Only use `true` / `false` for booleans.
cf. https://ansible.readthedocs.io/projects/lint/rules/yaml/#yaml

Signed-off-by: Alexis Thietard <alexis.thietard@rtone.fr>
  • Loading branch information
Al-thi committed Jan 31, 2025
1 parent c11de48 commit 6852aa5
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 14 deletions.
16 changes: 8 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ Installs and configures MySQL or MariaDB server on RHEL/CentOS or Debian/Ubuntu

## Requirements

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:
No special requirements; note that this role requires root access, so either run it in a playbook with a global `become: true`, or invoke the role in your playbook like:

```yaml
- hosts: database
roles:
- role: geerlingguy.mysql
become: yes
become: true
```
## Role Variables
Expand All @@ -39,7 +39,7 @@ The MySQL root user account details.
mysql_root_password_update: false
```

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`.
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 `true`.

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

Expand All @@ -62,7 +62,7 @@ The main my.cnf configuration file and include directory.
overwrite_global_mycnf: true
```

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.
Whether the global my.cnf should be overwritten each time this role is run. Setting this to `false` tells Ansible to only create the `my.cnf` file if it doesn't exist. This should be left at its default value (`true`) if you'd like to use this role's variables to configure MySQL.

```yaml
mysql_config_include_files: []
Expand All @@ -86,10 +86,10 @@ The MySQL users and their privileges. A user has the values:

- `name`
- `host` (defaults to `localhost`)
- `password` (can be plaintext or encrypted—if encrypted, set `encrypted: yes`)
- `encrypted` (defaults to `no`)
- `password` (can be plaintext or encrypted—if encrypted, set `encrypted: true`)
- `encrypted` (defaults to `false`)
- `priv` (defaults to `*.*:USAGE`)
- `append_privs` (defaults to `no`)
- `append_privs` (defaults to `false`)
- `state` (defaults to `present`)

The formats of these are the same as in the `mysql_user` module.
Expand Down Expand Up @@ -223,7 +223,7 @@ If you have only installed `ansible-core`, be sure to require `community.mysql`
## Example Playbook

- hosts: db-servers
become: yes
become: true
vars_files:
- vars/main.yml
roles:
Expand Down
2 changes: 1 addition & 1 deletion defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ mysql_log: ""

mysql_config_include_files: []
# - src: path/relative/to/playbook/file.cnf
# - { src: path/relative/to/playbook/anotherfile.cnf, force: yes }
# - { src: path/relative/to/playbook/anotherfile.cnf, force: true }

# Databases.
mysql_databases: []
Expand Down
2 changes: 1 addition & 1 deletion tasks/configure.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
owner: root
group: root
mode: 0644
force: "{{ item.force | default(False) }}"
force: "{{ item.force | default(false) }}"
with_items: "{{ mysql_config_include_files }}"
notify: restart mysql

Expand Down
4 changes: 2 additions & 2 deletions tasks/setup-Debian.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@

- name: Update apt cache if MySQL is not yet installed.
ansible.builtin.apt:
update_cache: yes
changed_when: False
update_cache: true
changed_when: false
when: not mysql_installed.stat.exists

- name: Ensure MySQL Python libraries are installed.
Expand Down
4 changes: 2 additions & 2 deletions tasks/users.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
password: "{{ item.password }}"
priv: "{{ item.priv | default('*.*:USAGE') }}"
state: "{{ item.state | default('present') }}"
append_privs: "{{ item.append_privs | default('no') }}"
encrypted: "{{ item.encrypted | default('no') }}"
append_privs: "{{ item.append_privs | default(false) }}"
encrypted: "{{ item.encrypted | default(false) }}"
with_items: "{{ mysql_users }}"
no_log: "{{ mysql_hide_passwords }}"

0 comments on commit 6852aa5

Please sign in to comment.