Skip to content

Commit ceb2971

Browse files
committed
Update as suggested by Copilot
1 parent 4b19093 commit ceb2971

2 files changed

Lines changed: 23 additions & 12 deletions

File tree

Ansible/tasks/configure_apparmor.yml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,13 @@
44
pkg: apparmor-utils
55
state: latest
66
update_cache: yes
7-
ignore_errors: true
7+
when: ansible_distribution != 'SUSE'
88

99
- name: Enable Apparmor enforce mode
1010
shell: aa-enforce /etc/apparmor.d/*
11+
changed_when: false
1112

12-
- name: Check Apparmor status
13+
- name: Check Apparmor status
1314
shell: aa-status
14-
ignore_errors: true
15+
failed_when: false
16+
changed_when: false
Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,27 @@
11
---
22

33
- name: Get current SELinux mode
4-
shell: getenforce || true
4+
command: getenforce
55
register: selinux_mode
6+
failed_when: false
7+
changed_when: false
68

7-
- name: Set selinux to enforcing
8-
command: setenforce enforcing
9+
- name: Set SELinux to enforcing
10+
command: setenforce Enforcing
911
changed_when: false
10-
when: selinux_mode.stdout != "Enforcing"
12+
when:
13+
- selinux_mode.rc == 0
14+
- selinux_mode.stdout not in ['Enforcing', 'Disabled']
1115

12-
- name: Ensure selinux is set permanently
13-
selinux: policy=targeted state=enforcing
14-
when: selinux_mode.stdout != "Enforcing"
16+
- name: Ensure SELinux is set permanently
17+
selinux:
18+
policy: targeted
19+
state: enforcing
20+
when:
21+
- selinux_mode.rc == 0
22+
- selinux_mode.stdout != 'Disabled'
1523

1624
- name: Check SELinux status
17-
shell: sestatus
18-
ignore_errors: true
25+
command: sestatus
26+
failed_when: false
27+
changed_when: false

0 commit comments

Comments
 (0)