Skip to content

Commit 8220ae9

Browse files
author
Sebastian Gumprich
committed
fix linting errors
1 parent a9f19a0 commit 8220ae9

File tree

7 files changed

+60
-59
lines changed

7 files changed

+60
-59
lines changed

molecule/os_hardening/prepare.yml

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
- name: wrapper playbook for kitchen testing "ansible-os-hardening" with custom vars for testing
2+
- name: Wrapper playbook for kitchen testing "ansible-os-hardening" with custom vars for testing
33
hosts: all
44
become: true
55
environment:
@@ -21,43 +21,43 @@
2121

2222
- name: install required tools on SuSE
2323
# cannot use zypper module, since it depends on python-xml
24-
shell: "zypper -n install python-xml"
24+
ansible.builtin.shell: zypper -n install python-xml
2525
when: ansible_facts.os_family == 'Suse'
2626

27-
- name: install required tools on fedora
28-
dnf:
27+
- name: Install required tools on fedora
28+
ansible.builtin.dnf:
2929
name:
3030
- python
3131
- findutils
3232
- procps-ng
3333
when: ansible_facts.distribution == 'Fedora'
3434

35-
- name: install required tools on Arch
35+
- name: Install required tools on Arch
3636
community.general.pacman:
3737
name:
3838
- awk
3939
state: present
4040
update_cache: true
4141
when: ansible_facts.os_family == 'Archlinux'
4242

43-
- name: install required tools on RHEL # noqa ignore-errors
44-
yum:
43+
- name: Install required tools on RHEL # noqa ignore-errors
44+
ansible.builtin.yum:
4545
name:
4646
- openssh-clients
4747
- openssh
4848
state: present
4949
update_cache: true
5050
ignore_errors: true
5151

52-
- name: create recursing symlink to test minimize access
53-
shell: "rm -f /usr/bin/zzz && ln -s /usr/bin /usr/bin/zzz"
52+
- name: Create recursing symlink to test minimize access
53+
ansible.builtin.shell: rm -f /usr/bin/zzz && ln -s /usr/bin /usr/bin/zzz
5454
changed_when: false
5555

56-
- name: include YUM prepare tasks
57-
include_tasks: prepare_tasks/yum.yml
56+
- name: Include YUM prepare tasks
57+
ansible.builtin.include_tasks: prepare_tasks/yum.yml
5858
when: ansible_facts.os_family == 'RedHat'
5959

60-
- name: include preparation tasks
60+
- name: Include preparation tasks
6161
ansible.builtin.include_tasks:
6262
file: "{{ item }}"
6363
loop:

molecule/os_hardening/verify.yml

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,14 @@
77
https_proxy: "{{ lookup('env', 'https_proxy') | default(omit) }}"
88
no_proxy: "{{ lookup('env', 'no_proxy') | default(omit) }}"
99
tasks:
10-
- name: set ansible_python_interpreter to "/usr/bin/python3"
11-
set_fact:
12-
ansible_python_interpreter: "/usr/bin/python3"
10+
- name: Set ansible_python_interpreter to "/usr/bin/python3"
11+
ansible.builtin.set_fact:
12+
ansible_python_interpreter: /usr/bin/python3
1313

14-
- name: include verification tasks
14+
- name: Include verification tasks
1515
ansible.builtin.include_tasks:
1616
file: "{{ item }}"
17-
loop:
17+
loop:
1818
- verify_tasks/sys_account_shell.yml
1919
- verify_tasks/pw_ageing.yml
2020
- verify_tasks/netrc.yml
@@ -37,7 +37,7 @@
3737
no_proxy: "{{ lookup('env', 'no_proxy') | default(omit) }}"
3838
tasks:
3939
- name: Execute cinc-auditor tests
40-
command: >
40+
ansible.builtin.command: >
4141
docker run
4242
--volume /run/docker.sock:/run/docker.sock
4343
--volume {{ playbook_dir }}/waivers.yaml:/waivers.yaml
@@ -51,12 +51,12 @@
5151
ignore_errors: true
5252

5353
- name: Display details about the cinc-auditor results
54-
debug:
54+
ansible.builtin.debug:
5555
msg: "{{ test_results.stdout_lines }}"
5656

5757
- name: Fail when tests fail
58-
fail:
59-
msg: "Inspec failed to validate"
58+
ansible.builtin.fail:
59+
msg: Inspec failed to validate
6060
when: test_results.rc != 0
6161

6262
- name: Verify
@@ -70,15 +70,15 @@
7070
- devsec.hardening
7171
tasks:
7272
# test if variable can be overridden
73-
- name: workaround for https://github.com/ansible/ansible/issues/66304
74-
set_fact:
75-
ansible_virtualization_type: "docker"
73+
- name: Workaround for https://github.com/ansible/ansible/issues/66304
74+
ansible.builtin.set_fact:
75+
ansible_virtualization_type: docker
7676
os_env_umask: "027 #override"
7777

78-
- include_role:
78+
- ansible.builtin.include_role:
7979
name: os_hardening
8080

81-
- name: verify os_env_umask
82-
shell:
81+
- name: Verify os_env_umask
82+
ansible.builtin.shell:
8383
cmd: "grep '027 #override' /etc/login.defs"
8484
changed_when: false
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
---
22
- name: test that .netrc in root homedir exists
33
ansible.builtin.file:
4-
path: '/root/.netrc'
4+
path: /root/.netrc
55
state: file
66
register: result_test_netrc
77

88
- name: output result if .netrc for user root exists
99
ansible.builtin.assert:
1010
that:
11-
- "result_test_netrc.state == 'file'"
12-
fail_msg: ".netrc in /root/ not present"
13-
success_msg: ".netrc exists in /root/"
11+
- result_test_netrc.state == 'file'
12+
fail_msg: .netrc in /root/ not present
13+
success_msg: .netrc exists in /root/
1414

1515
- name: delete '.netrc' in /root
1616
ansible.builtin.file:
17-
path: '/root/.netrc'
17+
path: /root/.netrc
1818
state: absent
1919
when: result_test_netrc.state == 'file'

molecule/os_hardening/verify_tasks/pam.yml

Lines changed: 22 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
---
2-
3-
- name: install pip
4-
package:
2+
- name: Install pip
3+
ansible.builtin.package:
54
name:
65
- python3-pip
76
- python3-setuptools
87
state: present
98

10-
- name: install pam-tester
9+
- name: Install pam-tester
1110
ansible.builtin.pip:
1211
name: pam-tester
1312
state: present
@@ -17,50 +16,50 @@
1716
set_fact:
1817
test_pw: "myTest!pw"
1918

20-
- name: set locale for test
21-
set_fact:
22-
locale: "en_US.UTF-8"
19+
- name: Set locale for test
20+
ansible.builtin.set_fact:
21+
locale: en_US.UTF-8
2322
when:
2423
- ansible_facts.os_family == 'RedHat'
2524
- ansible_facts.distribution_major_version < '8'
2625

27-
- name: create testuser
28-
user:
26+
- name: Create testuser
27+
ansible.builtin.user:
2928
name: testuser
3029
password: "{{ test_pw | password_hash('sha512') }}"
3130

32-
- name: check successful login with correct password
33-
shell:
34-
cmd: "/usr/local/bin/pam-tester --user testuser --password {{ test_pw }}"
31+
- name: Check successful login with correct password
32+
ansible.builtin.shell:
33+
cmd: /usr/local/bin/pam-tester --user testuser --password {{ test_pw }}
3534
environment:
3635
TMPDIR: /var/tmp
3736
LC_ALL: "{{ locale | default('C.UTF-8') }}"
3837
LANG: "{{ locale | default('C.UTF-8') }}"
3938

40-
- name: check unsuccessful login with incorrect password
41-
shell:
42-
cmd: "/usr/local/bin/pam-tester --user testuser --password {{ test_pw }}fail --expectfail"
39+
- name: Check unsuccessful login with incorrect password
40+
ansible.builtin.shell:
41+
cmd: /usr/local/bin/pam-tester --user testuser --password {{ test_pw }}fail --expectfail
4342
environment:
4443
TMPDIR: /var/tmp
4544
LC_ALL: "{{ locale | default('C.UTF-8') }}"
4645
LANG: "{{ locale | default('C.UTF-8') }}"
4746
with_sequence: count=6
4847

49-
- name: check unsuccessful login, with correct password (lockout)
50-
shell:
51-
cmd: "/usr/local/bin/pam-tester --user testuser --password {{ test_pw }} --expectfail"
48+
- name: Check unsuccessful login, with correct password (lockout)
49+
ansible.builtin.shell:
50+
cmd: /usr/local/bin/pam-tester --user testuser --password {{ test_pw }} --expectfail
5251
environment:
5352
TMPDIR: /var/tmp
5453
LC_ALL: "{{ locale | default('C.UTF-8') }}"
5554
LANG: "{{ locale | default('C.UTF-8') }}"
5655

57-
- name: wait for account to unlock
58-
pause:
56+
- name: Wait for account to unlock
57+
ansible.builtin.pause:
5958
seconds: 20
6059

61-
- name: check successful login
62-
shell:
63-
cmd: "/usr/local/bin/pam-tester --user testuser --password {{ test_pw }}"
60+
- name: Check successful login
61+
ansible.builtin.shell:
62+
cmd: /usr/local/bin/pam-tester --user testuser --password {{ test_pw }}
6463
environment:
6564
TMPDIR: /var/tmp
6665
LC_ALL: "{{ locale | default('C.UTF-8') }}"
Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1+
---
12
- name: Read local linux user database
2-
getent:
3+
ansible.builtin.getent:
34
database: passwd
45

56
- name: Check that shell_sys_acc's shell is still bash
6-
assert:
7+
ansible.builtin.assert:
78
that:
89
- getent_passwd['shell_sys_acc'][5] == "/bin/bash"
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
---
22
- name: verify 'gpgcheck' was not enabled for 'foo' repository (in whitelist)
3-
command: grep -e 'gpgcheck\s*=\s*0' /etc/yum.repos.d/foo.repo
3+
ansible.builtin.command: grep -e 'gpgcheck\s*=\s*0' /etc/yum.repos.d/foo.repo
44
changed_when: false
55

66
- name: verify 'gpgcheck' was enabled for 'bar' repository (not in whitelist)
7-
command: grep -e 'gpgcheck\s*=\s*1' /etc/yum.repos.d/bar.repo
7+
ansible.builtin.command: grep -e 'gpgcheck\s*=\s*1' /etc/yum.repos.d/bar.repo
88
changed_when: false

molecule/os_hardening_vm/verify_tasks/pam.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
ansible.builtin.pip:
1111
name: pam-tester
1212
state: present
13+
executable: /usr/bin/pip3
1314

1415
- name: set password for test
1516
set_fact:

0 commit comments

Comments
 (0)