Skip to content

Commit 1eee6e2

Browse files
committed
Fix some new issues found in the latest version of ansible-lint.
1 parent dc532d8 commit 1eee6e2

File tree

6 files changed

+42
-31
lines changed

6 files changed

+42
-31
lines changed

molecule/default/yaml-lint.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
extends: default
33
rules:
44
line-length:
5-
max: 150
5+
max: 120
66
level: warning

tasks/configure.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,9 @@
6565
args:
6666
creates: "{{ mysql_log_error }}"
6767
warn: false
68-
when: mysql_log == "" and mysql_log_error != ""
68+
when:
69+
- not mysql_log
70+
- mysql_log_error
6971

7072
- name: Set ownership on error log file (if configured).
7173
file:
@@ -74,7 +76,9 @@
7476
owner: mysql
7577
group: "{{ mysql_log_file_group }}"
7678
mode: 0640
77-
when: mysql_log == "" and mysql_log_error != ""
79+
when:
80+
- not mysql_log
81+
- mysql_log_error
7882

7983
- name: Ensure MySQL is started and enabled on boot.
8084
service: "name={{ mysql_daemon }} state=started enabled={{ mysql_enabled_on_startup }}"

tasks/replication.yml

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@
66
password: "{{ mysql_replication_user.password }}"
77
priv: "{{ mysql_replication_user.priv | default('*.*:REPLICATION SLAVE,REPLICATION CLIENT') }}"
88
state: present
9-
when: >
10-
(mysql_replication_role == 'master')
11-
and mysql_replication_user
12-
and (mysql_replication_master != '')
9+
when:
10+
- mysql_replication_role == 'master'
11+
- mysql_replication_user
12+
- mysql_replication_master
1313

1414
- name: Check slave replication status.
1515
mysql_replication:
@@ -18,18 +18,18 @@
1818
login_password: "{{ mysql_replication_user.password }}"
1919
ignore_errors: true
2020
register: slave
21-
when: >
22-
mysql_replication_role == 'slave'
23-
and (mysql_replication_master != '')
21+
when:
22+
- mysql_replication_role == 'slave'
23+
- mysql_replication_master
2424

2525
- name: Check master replication status.
2626
mysql_replication: mode=getmaster
2727
delegate_to: "{{ mysql_replication_master }}"
2828
register: master
29-
when: >
30-
((slave.Is_Slave is defined and not slave.Is_Slave) or (slave.Is_Slave is not defined and slave is failed))
31-
and (mysql_replication_role == 'slave')
32-
and (mysql_replication_master != '')
29+
when:
30+
- (slave.Is_Slave is defined and not slave.Is_Slave) or (slave.Is_Slave is not defined and slave is failed)
31+
- mysql_replication_role == 'slave'
32+
- mysql_replication_master
3333

3434
- name: Configure replication on the slave.
3535
mysql_replication:
@@ -40,15 +40,15 @@
4040
master_log_file: "{{ master.File }}"
4141
master_log_pos: "{{ master.Position }}"
4242
ignore_errors: true
43-
when: >
44-
((slave.Is_Slave is defined and not slave.Is_Slave) or (slave.Is_Slave is not defined and slave is failed))
45-
and (mysql_replication_role == 'slave')
46-
and (mysql_replication_master != '')
47-
and mysql_replication_user
43+
when:
44+
- (slave.Is_Slave is defined and not slave.Is_Slave) or (slave.Is_Slave is not defined and slave is failed)
45+
- mysql_replication_role == 'slave'
46+
- mysql_replication_master
47+
- mysql_replication_user
4848

4949
- name: Start replication.
5050
mysql_replication: mode=startslave
51-
when: >
52-
((slave.Is_Slave is defined and not slave.Is_Slave) or (slave.Is_Slave is not defined and slave is failed))
53-
and (mysql_replication_role == 'slave')
54-
and (mysql_replication_master != '')
51+
when:
52+
- (slave.Is_Slave is defined and not slave.Is_Slave) or (slave.Is_Slave is not defined and slave is failed)
53+
- mysql_replication_role == 'slave'
54+
- mysql_replication_master

tasks/secure-installation.yml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,11 @@
2626
changed_when: false
2727

2828
- name: Get list of hosts for the root user.
29-
command: mysql -NBe "SELECT Host FROM mysql.user WHERE User = '{{ mysql_root_username }}' ORDER BY (Host='localhost') ASC"
29+
command: mysql -NBe
30+
"SELECT Host
31+
FROM mysql.user
32+
WHERE User = '{{ mysql_root_username }}'
33+
ORDER BY (Host='localhost') ASC"
3034
register: mysql_root_hosts
3135
changed_when: false
3236
check_mode: false
@@ -38,7 +42,8 @@
3842
- name: Update MySQL root password for localhost root account (5.7.x).
3943
shell: >
4044
mysql -u root -NBe
41-
'ALTER USER "{{ mysql_root_username }}"@"{{ item }}" IDENTIFIED WITH mysql_native_password BY "{{ mysql_root_password }}";'
45+
'ALTER USER "{{ mysql_root_username }}"@"{{ item }}"
46+
IDENTIFIED WITH mysql_native_password BY "{{ mysql_root_password }}";'
4247
with_items: "{{ mysql_root_hosts.stdout_lines|default([]) }}"
4348
when: >
4449
((mysql_install_packages | bool) or mysql_root_password_update)

tasks/setup-Archlinux.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,4 @@
1010
- name: Run mysql_install_db if MySQL packages were changed.
1111
command: mysql_install_db --user=mysql --basedir=/usr --datadir=/var/lib/mysql
1212
when: arch_mysql_install_packages.changed
13+
tags: ['skip_ansible_lint']

tasks/setup-Debian.yml

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,12 @@
55

66
- name: Update apt cache if MySQL is not yet installed.
77
apt: update_cache=yes
8-
when: mysql_installed.stat.exists == false
8+
when: not mysql_installed.stat.exists
99

1010
- name: Determine required MySQL Python libraries.
1111
set_fact:
1212
deb_mysql_python_package: "{% if 'python3' in ansible_python_interpreter|default('') %}python3-mysqldb{% else %}python-mysqldb{% endif %}"
13+
tags: ['skip_ansible_lint']
1314

1415
- name: Ensure MySQL Python libraries are installed.
1516
apt: "name={{ deb_mysql_python_package }} state=present"
@@ -22,11 +23,11 @@
2223
# mysql and remove the logfiles in case the user set a custom log file size.
2324
- name: Ensure MySQL is stopped after initial install.
2425
service: "name={{ mysql_daemon }} state=stopped"
25-
when: mysql_installed.stat.exists == false
26+
when: not mysql_installed.stat.exists
2627

2728
- name: Delete innodb log files created by apt package after initial install.
28-
file: path={{ mysql_datadir }}/{{item}} state=absent
29+
file: path={{ mysql_datadir }}/{{ item }} state=absent
2930
with_items:
30-
- "ib_logfile0"
31-
- "ib_logfile1"
32-
when: mysql_installed.stat.exists == false
31+
- ib_logfile0
32+
- ib_logfile1
33+
when: not mysql_installed.stat.exists

0 commit comments

Comments
 (0)