Skip to content
This repository was archived by the owner on Dec 26, 2020. It is now read-only.

Commit b17bd65

Browse files
author
Sebastian Gumprich
committed
Add more conditionals
1 parent 9560f33 commit b17bd65

File tree

1 file changed

+4
-4
lines changed
  • roles/ansible-ssh-hardening/tasks

1 file changed

+4
-4
lines changed

roles/ansible-ssh-hardening/tasks/main.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,19 +39,19 @@
3939
- name: Distributing custom selinux policies
4040
copy: src='ssh_password' dest='{{ custom_selinux_dir }}'
4141
register: custom_policies_output
42-
when: not ssh_use_pam and sestatus.stdout != 'Disabled'
42+
when: not ssh_use_pam and sestatus.stdout != 'Disabled' and selinux_installed.rc == 0
4343

4444
- name: check and compile policy
4545
shell: checkmodule -M -m -o {{ custom_selinux_dir }}/ssh_password.mod {{ custom_selinux_dir }}/ssh_password
46-
when: not ssh_use_pam and sestatus.stdout != 'Disabled'
46+
when: not ssh_use_pam and sestatus.stdout != 'Disabled' and selinux_installed.rc == 0
4747

4848
- name: create selinux policy module package
4949
shell: semodule_package -o {{ custom_selinux_dir }}/ssh_password.pp -m {{ custom_selinux_dir }}/ssh_password.mod
50-
when: not ssh_use_pam and sestatus.stdout != 'Disabled'
50+
when: not ssh_use_pam and sestatus.stdout != 'Disabled' and selinux_installed.rc == 0
5151

5252
- name: install selinux policy
5353
shell: semodule -i {{ custom_selinux_dir }}/ssh_password.pp
54-
when: not ssh_use_pam and sestatus.stdout != 'Disabled'
54+
when: not ssh_use_pam and sestatus.stdout != 'Disabled' and selinux_installed.rc == 0
5555

5656
- name: remove selinux-policy when Pam is used, because Allowing sshd to read the shadow file directly is considered a potential security risk (http://danwalsh.livejournal.com/12333.html)
5757
shell: semodule -r ssh_password

0 commit comments

Comments
 (0)