summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorMartin Krizek <martin.krizek@gmail.com>2017-11-28 17:09:25 +0100
committerSam Doran <sdoran@ansible.com>2017-11-28 17:09:24 +0100
commit0592fd47bc6005e339c655cbba02aa330c7ee848 (patch)
tree4942ec29661ddbc8f2817d6e3e4246be70d35fed /test
parentIssue 19612 os router to allow adding interface by port ip (#30409) (diff)
downloadansible-0592fd47bc6005e339c655cbba02aa330c7ee848.tar.xz
ansible-0592fd47bc6005e339c655cbba02aa330c7ee848.zip
selinux: check if policy exists before switching (#31834)
* selinux: check if policy exists before switching * Check the policy dir
Diffstat (limited to 'test')
-rw-r--r--test/integration/targets/selinux/tasks/selinux.yml37
1 files changed, 37 insertions, 0 deletions
diff --git a/test/integration/targets/selinux/tasks/selinux.yml b/test/integration/targets/selinux/tasks/selinux.yml
index 5e543d1480..443f941929 100644
--- a/test/integration/targets/selinux/tasks/selinux.yml
+++ b/test/integration/targets/selinux/tasks/selinux.yml
@@ -106,6 +106,11 @@
# ##############################################################################
# Test changing only the policy, which does not require a reboot
+- name: TEST 2 | Make sure the policy is present
+ package:
+ name: selinux-policy-mls
+ state: present
+
- name: TEST 2 | Set SELinux policy
selinux:
state: enforcing
@@ -168,3 +173,35 @@
selinux:
state: enforcing
policy: targeted
+
+
+# Third Test
+# ##############################################################################
+# Test changing non-existing policy
+
+- name: TEST 3 | Set SELinux policy
+ selinux:
+ state: enforcing
+ policy: non-existing-selinux-policy
+ register: _state_test1
+ ignore_errors: yes
+
+- debug:
+ var: _state_test1
+ verbosity: 1
+
+- name: TEST 3 | Re-gather facts
+ setup:
+
+- debug:
+ var: ansible_selinux
+ tags: debug
+
+- name: TEST 3 | Assert that status was not changed, the task failed, the msg contains proper information and SELinux was not changed
+ assert:
+ that:
+ - not _state_test1 | changed
+ - _state_test1 | failed
+ - _state_test1.msg == 'Policy non-existing-selinux-policy does not exist in /etc/selinux/'
+ - ansible_selinux.config_mode == 'enforcing'
+ - ansible_selinux.type == 'targeted'