Skip to content

Commit 1cb9379

Browse files
author
Sebastian Gumprich
committed
split creation of user and test
Signed-off-by: Sebastian Gumprich <sebastian.gumprich@t-systems.com>
1 parent 2fa4d64 commit 1cb9379

File tree

3 files changed

+60
-34
lines changed

3 files changed

+60
-34
lines changed

molecule/os_hardening/verify.yml

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,40 @@
2020
- verify_tasks/netrc.yml
2121
- verify_tasks/ignore_home_folders.yml
2222

23-
- name: include PAM tests
24-
include_tasks: verify_tasks/pam.yml
25-
when: ansible_facts.distribution in ['Debian', 'Ubuntu'] or ansible_facts.os_family == 'RedHat'
26-
2723
- name: include YUM tests
2824
include_tasks: verify_tasks/yum.yml
2925
when: ansible_facts.os_family == 'RedHat'
3026

27+
- name: Verify
28+
hosts: all
29+
become: true
30+
environment:
31+
http_proxy: "{{ lookup('env', 'http_proxy') | default(omit) }}"
32+
https_proxy: "{{ lookup('env', 'https_proxy') | default(omit) }}"
33+
no_proxy: "{{ lookup('env', 'no_proxy') | default(omit) }}"
34+
tasks:
35+
- name: set ansible_python_interpreter to "/usr/bin/python3"
36+
set_fact:
37+
ansible_python_interpreter: "/usr/bin/python3"
38+
- name: include PAM tests
39+
include_tasks: verify_tasks/pam_1.yml
40+
when: ansible_facts.distribution in ['Debian', 'Ubuntu'] or ansible_facts.os_family == 'RedHat'
41+
42+
- name: Verify
43+
hosts: all
44+
become: true
45+
environment:
46+
http_proxy: "{{ lookup('env', 'http_proxy') | default(omit) }}"
47+
https_proxy: "{{ lookup('env', 'https_proxy') | default(omit) }}"
48+
no_proxy: "{{ lookup('env', 'no_proxy') | default(omit) }}"
49+
tasks:
50+
- name: set ansible_python_interpreter to "/usr/bin/python3"
51+
set_fact:
52+
ansible_python_interpreter: "/usr/bin/python3"
53+
- name: include PAM tests
54+
include_tasks: verify_tasks/pam_2.yml
55+
when: ansible_facts.distribution in ['Debian', 'Ubuntu'] or ansible_facts.os_family == 'RedHat'
56+
3157
- name: Verify
3258
hosts: localhost
3359
environment:
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
---
2+
3+
- name: install pip
4+
package:
5+
name:
6+
- python3-pip
7+
- python3-setuptools
8+
state: present
9+
10+
- name: install pam-tester
11+
ansible.builtin.pip:
12+
name: pam-tester
13+
state: present
14+
executable: /usr/bin/pip3
15+
16+
- name: set password for test
17+
set_fact:
18+
test_pw: "myTestpwSage"
19+
20+
- name: set locale for test
21+
set_fact:
22+
locale: "en_US.UTF-8"
23+
when:
24+
- ansible_facts.os_family == 'RedHat'
25+
- ansible_facts.distribution_major_version < '8'
26+
27+
- name: create testuser
28+
user:
29+
name: testuser
30+
password: "{{ test_pw | password_hash('sha512') }}"

molecule/os_hardening/verify_tasks/pam.yml renamed to molecule/os_hardening/verify_tasks/pam_2.yml

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,4 @@
11
---
2-
3-
- name: install pip
4-
package:
5-
name:
6-
- python3-pip
7-
- python3-setuptools
8-
state: present
9-
10-
- name: install pam-tester
11-
ansible.builtin.pip:
12-
name: pam-tester
13-
state: present
14-
executable: /usr/bin/pip3
15-
16-
- name: set password for test
17-
set_fact:
18-
test_pw: "myTestpwSage"
19-
20-
- name: set locale for test
21-
set_fact:
22-
locale: "en_US.UTF-8"
23-
when:
24-
- ansible_facts.os_family == 'RedHat'
25-
- ansible_facts.distribution_major_version < '8'
26-
27-
- name: create testuser
28-
user:
29-
name: testuser
30-
password: "{{ test_pw | password_hash('sha512') }}"
31-
322
- name: check successful login with correct password
333
shell:
344
cmd: "/usr/local/bin/pam-tester --user testuser --password {{ test_pw }}"

0 commit comments

Comments
 (0)