Skip to content

Commit 978b4bb

Browse files
committed
Linting fixes
1 parent ce2fc21 commit 978b4bb

22 files changed

Lines changed: 208 additions & 168 deletions

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
**/*.swp
22
**/*.retry
3+
.venv/**

.yamllint

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22
# Based on ansible-lint config
33
extends: default
44

5+
ignore: |
6+
.venv/**
7+
.git/**
8+
59
rules:
610
braces:
711
max-spaces-inside: 1
@@ -15,7 +19,9 @@ rules:
1519
commas:
1620
max-spaces-after: -1
1721
level: error
18-
comments: disable
22+
comments:
23+
level: warning
24+
min-spaces-from-content: 1
1925
comments-indentation: disable
2026
document-start: disable
2127
empty-lines:
@@ -29,5 +35,8 @@ rules:
2935
new-line-at-end-of-file: disable
3036
new-lines:
3137
type: unix
38+
octal-values:
39+
forbid-implicit-octal: true
40+
forbid-explicit-octal: true
3241
trailing-spaces: disable
3342
truthy: disable

handlers/main.yml

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,48 @@
11
---
22
- name: Install dotfiles
3-
command:
3+
ansible.builtin.command:
44
cmd: bash create.sh
55
chdir: /root/cybera-dotfiles
6+
changed_when: true
67
when: not ansible_check_mode
78

89
- name: Restart SSH daemon
9-
service:
10+
ansible.builtin.service:
1011
name: "{{ 'ssh' if ansible_os_family == 'Debian' else 'sshd' }}"
1112
state: restarted
1213
when: not ansible_check_mode
1314

1415
- name: Restart journald
15-
systemd:
16+
ansible.builtin.systemd:
1617
name: systemd-journald
1718
state: restarted
1819
when: not ansible_check_mode
1920

2021
- name: Reload systemd
21-
systemd:
22+
ansible.builtin.systemd:
2223
daemon_reload: yes
2324
when: not ansible_check_mode
2425

2526
- name: Restart rsyslog
26-
systemd:
27+
ansible.builtin.systemd:
2728
name: rsyslog
2829
state: restarted
2930
when: not ansible_check_mode
3031

3132
- name: Restart postfix
32-
systemd:
33+
ansible.builtin.systemd:
3334
name: postfix
3435
state: restarted
3536
when: not ansible_check_mode
3637

3738
- name: Build mail aliases
38-
command:
39+
ansible.builtin.command:
3940
cmd: /usr/bin/newaliases
41+
changed_when: true
4042
when: not ansible_check_mode
4143

4244
- name: Restart Sensu Agent
43-
systemd:
45+
ansible.builtin.systemd:
4446
name: sensu-agent
4547
state: restarted
4648
when: not ansible_check_mode
@@ -60,6 +62,7 @@
6062
when: not ansible_check_mode
6163

6264
- name: Rebuild GRUB
63-
command:
65+
ansible.builtin.command:
6466
cmd: /usr/sbin/update-grub
67+
changed_when: true
6568
when: not ansible_check_mode

meta/main.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@ galaxy_info:
44
description: common settings for cybera servers
55
company: Cybera
66
license: MIT
7-
min_ansible_version: 2.10
7+
min_ansible_version: "2.10"
88
platforms:
9-
- name: CentOS
10-
versions: [7, 8]
9+
- name: EL
10+
versions: ["7", "8"]
1111
- name: Ubuntu
12-
versions: [18.04]
12+
versions: ["bionic"]
1313

1414
galaxy_tags: []
1515

molecule/default/converge.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
hosts: all
44
tasks:
55
- name: Include test data
6-
include_vars: vars.yml
6+
ansible.builtin.include_vars: vars.yml
77

88
- name: Include ansible-cybera-common
9-
include_role:
9+
ansible.builtin.include_role:
1010
name: "ansible-cybera-common"

molecule/default/prepare.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,21 @@
33

44
tasks:
55
- name: Refresh package cache
6-
package:
6+
ansible.builtin.package:
77
update_cache: yes
88

99
- name: Install tzdata
10-
package:
10+
ansible.builtin.package:
1111
name: tzdata
1212
when: ansible_os_family == "Debian"
1313

1414
- name: Create group to later remove
15-
group:
15+
ansible.builtin.group:
1616
name: jdoe
1717
gid: "1001"
1818

1919
- name: Create user to later remove
20-
user:
20+
ansible.builtin.user:
2121
name: jdoe
2222
state: present
2323
uid: "1001"
@@ -27,7 +27,7 @@
2727
create_home: true
2828

2929
- name: Ensure the sudo group exists
30-
group:
30+
ansible.builtin.group:
3131
name: sudo
3232
gid: "27"
3333
state: present

molecule/default/verify.yml

Lines changed: 59 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -4,82 +4,94 @@
44
gather_facts: true
55
tasks:
66
- name: Include test data
7-
include_vars: vars.yml
7+
ansible.builtin.include_vars: vars.yml
88

99
# Confirm SSH keys
1010
- name: Get SSH authorized_keys file
11-
shell: "cat /root/.ssh/authorized_keys"
11+
ansible.builtin.command:
12+
cmd: "cat /root/.ssh/authorized_keys"
1213
register: authorized_keys_output
14+
changed_when: false
1315

1416
- name: Verify SSH keys are installed
15-
assert:
17+
ansible.builtin.assert:
1618
that:
1719
- "'foo' in authorized_keys_output.stdout"
1820
- "'bar' in authorized_keys_output.stdout"
1921

2022
# Confirm iptables rules
2123
- name: List iptables rules
22-
shell: "iptables-save"
24+
ansible.builtin.command:
25+
cmd: "iptables-save"
2326
register: iptables_save_output
27+
changed_when: false
2428

2529
- name: Verify iptables networks are configured correctly
26-
assert:
30+
ansible.builtin.assert:
2731
that:
2832
- "'{{ item }} -j ACCEPT' in iptables_save_output.stdout"
2933
loop: "{{ cybera_networks_ipv4_trusted_global | zip(cybera_networks_ipv4_trusted) | flatten }}"
3034

3135
- name: Verify iptables ports configured correctly
32-
assert:
36+
ansible.builtin.assert:
3337
that:
3438
- "'--dport {{ (item|dict2items).0.value }} -j ACCEPT' in iptables_save_output.stdout"
3539
loop: "{{ cybera_open_ports_ipv4 }}"
3640

3741
# Confirm package installation
3842
- name: List curl package
39-
shell: which curl
43+
ansible.builtin.command:
44+
cmd: which curl
4045
register: curl_output
46+
changed_when: false
4147

4248
- name: Verify curl is correctly installed
43-
assert:
49+
ansible.builtin.assert:
4450
that:
4551
- "'curl' in curl_output.stdout"
4652

4753
# Confirm acng
4854
- name: Get acng file contents
49-
shell: "cat /etc/apt/apt.conf.d/01apt-cacher-ng-proxy"
55+
ansible.builtin.command:
56+
cmd: "cat /etc/apt/apt.conf.d/01apt-cacher-ng-proxy"
5057
register: acng_output
58+
changed_when: false
5159
when: ansible_os_family == "Debian"
5260

5361
- name: Verify acng is configured correctly
54-
assert:
62+
ansible.builtin.assert:
5563
that:
5664
- "'Acquire::http { Proxy \"http://acng-yyc.cloud.cybera.ca:3142\"; };' in acng_output.stdout"
5765
when: ansible_os_family == "Debian"
5866

5967
# Confirm dotfiles
6068
- name: Check if tmux.conf.mcjones exists
61-
shell: "ls -l /root/.tmux.conf.mcjones"
69+
ansible.builtin.command:
70+
cmd: "ls -l /root/.tmux.conf.mcjones"
6271
register: dotfiles_output
72+
changed_when: false
6373

6474
- name: Verify dotfiles was setup
65-
assert:
75+
ansible.builtin.assert:
6676
that:
6777
- "'cybera-dotfiles' in dotfiles_output.stdout"
6878

6979
# Confirm IPv6 sysctl settings
7080
- name: Get sysctl.conf contents
71-
shell: "sysctl -a"
81+
ansible.builtin.command:
82+
cmd: "sysctl -a"
7283
register: sysctl_output
84+
changed_when: false
7385

7486
- name: Verify IPv6 sysctl settings
75-
assert:
87+
ansible.builtin.assert:
7688
that:
7789
- "'net.ipv6.conf.all.use_tempaddr = 0' in sysctl_output.stdout"
7890
- "'net.ipv6.conf.all.accept_ra = 1' in sysctl_output.stdout"
7991

8092
# Verify Ubuntu quirks
8193
- name: Check for removed files
82-
stat:
94+
ansible.builtin.stat:
8395
path: "{{ item }}"
8496
loop:
8597
- "/etc/cron.weekly/update-notifier-common"
@@ -90,91 +102,105 @@
90102
register: removed_files_stat
91103

92104
- name: Verify files are removed
93-
assert:
105+
ansible.builtin.assert:
94106
that:
95107
- "'{{ item.stat.exists }}' == 'False'"
96108
loop: "{{ removed_files_stat.results }}"
97109

98110
# Verify users were removed
99111
- name: Get contents of /etc/group
100-
shell: "cat /etc/group"
112+
ansible.builtin.command:
113+
cmd: "cat /etc/group"
101114
register: etc_group_output
115+
changed_when: false
102116

103117
- name: Get contents of /etc/passwd
104-
shell: "cat /etc/passwd"
118+
ansible.builtin.command:
119+
cmd: "cat /etc/passwd"
105120
register: etc_passwd_output
121+
changed_when: false
106122

107123
- name: Verify jdoe user does not exist
108-
assert:
124+
ansible.builtin.assert:
109125
that:
110126
- "'jdoe' not in etc_group_output.stdout"
111127
- "'jdoe' not in etc_passwd_output.stdout"
112128

113129
# Verify users exist
114130
- name: Check for foo home directory
115-
stat:
131+
ansible.builtin.stat:
116132
path: "/home/foo"
117133
register: user_foo_stats
118134

119135
- name: Verify foo user exist
120-
assert:
136+
ansible.builtin.assert:
121137
that:
122138
- "'{{ user_foo_stats.stat.exists }}' == 'True'"
123139

124140
- name: Get user's groups
125-
shell: "groups foo"
141+
ansible.builtin.command:
142+
cmd: "groups foo"
126143
register: user_foo_groups
144+
changed_when: false
127145

128146
- name: Verify user's groups
129-
assert:
147+
ansible.builtin.assert:
130148
that:
131149
- "'sudo' in user_foo_groups.stdout"
132150

133151
- name: Check for bar home directory
134-
stat:
152+
ansible.builtin.stat:
135153
path: "/opt/bar"
136154
register: user_bar_stats
137155

138156
- name: Verify bar user exist
139-
assert:
157+
ansible.builtin.assert:
140158
that:
141159
- "'{{ user_bar_stats.stat.exists }}' == 'True'"
142160

143161
- name: Get sudo file
144-
shell: "cat /etc/sudoers.d/foo"
162+
ansible.builtin.command:
163+
cmd: "cat /etc/sudoers.d/foo"
145164
register: sudoers_file
165+
changed_when: false
146166

147167
- name: Verify sudo access
148-
assert:
168+
ansible.builtin.assert:
149169
that:
150170
- "'foo ALL' in sudoers_file.stdout"
151171

152172
- name: Capture rsyslog client.conf file
153-
shell: "cat /etc/rsyslog.d/client.conf"
173+
ansible.builtin.command:
174+
cmd: "cat /etc/rsyslog.d/client.conf"
154175
register: rsyslog_client_conf
176+
changed_when: false
155177
when: ansible_os_family == "Debian"
156178

157179
- name: Verify rsyslog client settings
158-
assert:
180+
ansible.builtin.assert:
159181
that:
160182
- "'/etc/ssl/certs/rsyslog.crt' in rsyslog_client_conf.stdout"
161183
- "'localhost' in rsyslog_client_conf.stdout"
162184
when: ansible_os_family == "Debian"
163185

164186
- name: Capture postfix configuration file
165-
shell: "cat /etc/postfix/main.cf"
187+
ansible.builtin.command:
188+
cmd: "cat /etc/postfix/main.cf"
166189
register: postfix_main_cf
190+
changed_when: false
167191

168192
- name: Verify relay host was set
169-
assert:
193+
ansible.builtin.assert:
170194
that:
171195
- "'relayhost = example.com' in postfix_main_cf.stdout"
172196

173197
- name: Capture mail aliases
174-
shell: "cat /etc/aliases"
198+
ansible.builtin.command:
199+
cmd: "cat /etc/aliases"
175200
register: mail_aliases
201+
changed_when: false
176202

177203
- name: Verify mail aliases were set
178-
assert:
204+
ansible.builtin.assert:
179205
that:
180206
- "'root: john.doe@example.com, jane.doe@example.com, jack.doe@example.com' in mail_aliases.stdout"

0 commit comments

Comments
 (0)