Skip to content

Commit 27c6b93

Browse files
authored
add "when" statements in hardening.yml(#453) (#455)
* add "when" statements in hardening.yml(#453) Signed-off-by: jqiuyin <[email protected]> * add "when" statements in hardening.yml(#453) Signed-off-by: jqiuyin <[email protected]> * add "when" statements in hardening.yml(#453) Signed-off-by: jqiuyin <[email protected]>
1 parent e733906 commit 27c6b93

File tree

3 files changed

+104
-3
lines changed

3 files changed

+104
-3
lines changed

roles/os_hardening/README.md

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,48 @@ We know that this is the case on Raspberry Pi.
193193
- `os_ignore_home_folder_users`
194194
- Default: `lost+found`
195195
- Description: specify user home folders in `/home` that shouldn't be chmodded to 700
196+
- `os_cron_enabled`
197+
- Default: `true`
198+
- Description: Set to false to disable installing and configuring cron.
199+
- `os_limits_enabled`
200+
- Default: `true`
201+
- Description: Set to false to disable installing and configuring limits.
202+
- `os_login_defs_enabled`
203+
- Default: `true`
204+
- Description: Set to false to disable installing and configuring login_defs.
205+
- `os_minimize_access_enabled`
206+
- Default: `true`
207+
- Description: Set to false to disable installing and configuring minimize_access.
208+
- `os_pam_enabled`
209+
- Default: `true`
210+
- Description: Set to false to disable installing and configuring pam.
211+
- `os_modprobe_enabled`
212+
- Default: `true`
213+
- Description: Set to false to disable installing and configuring modprobe.
214+
- `os_profile_enabled`
215+
- Default: `true`
216+
- Description: Set to false to disable installing and configuring profile.
217+
- `os_securetty_enabled`
218+
- Default: `true`
219+
- Description: Set to false to disable installing and configuring securetty.
220+
- `os_sysctl_enabled`
221+
- Default: `true`
222+
- Description: Set to false to disable installing and configuring sysctl.
223+
- `os_user_accounts_enabled`
224+
- Default: `true`
225+
- Description: Set to false to disable installing and configuring user_accounts.
226+
- `os_rhosts_enabled`
227+
- Default: `true`
228+
- Description: Set to false to disable installing and configuring rhosts.
229+
- `os_yum_enabled`
230+
- Default: `true`
231+
- Description: Set to false to disable installing and configuring yum.
232+
- `os_apt_enabled`
233+
- Default: `true`
234+
- Description: Set to false to disable installing and configuring apt.
235+
- `os_selinux_enabled`
236+
- Default: `true`
237+
- Description: Set to false to disable installing and configuring selinux.
196238
- `os_sha_crypt_min_rounds`
197239
- Default: `640000`
198240
- Description: Define the number of minimum SHA rounds. With a lot of rounds brute forcing the password is more difficult. But note also that it more CPU resources will be needed to authenticate users. The values must be inside the 1000-999999999 range.

roles/os_hardening/defaults/main.yml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -322,6 +322,48 @@ os_selinux_policy: targeted
322322
# Mount options for proc in /etc/fstab.
323323
proc_mnt_options: 'rw,nosuid,nodev,noexec,relatime,hidepid={{ hidepid_option }}'
324324

325+
# Set to false to disable installing and configuring cron.
326+
os_cron_enabled: true
327+
328+
# Set to false to disable installing and configuring limits.
329+
os_limits_enabled: true
330+
331+
# Set to false to disable installing and configuring login_defs.
332+
os_login_defs_enabled: true
333+
334+
# Set to false to disable installing and configuring minimize_access.
335+
os_minimize_access_enabled: true
336+
337+
# Set to false to disable installing and configuring pam.
338+
os_pam_enabled: true
339+
340+
# Set to false to disable installing and configuring modprobe.
341+
os_modprobe_enabled: true
342+
343+
# Set to false to disable installing and configuring profile.
344+
os_profile_enabled: true
345+
346+
# Set to false to disable installing and configuring securetty.
347+
os_securetty_enabled: true
348+
349+
# Set to false to disable installing and configuring sysctl.
350+
os_sysctl_enabled: true
351+
352+
# Set to false to disable installing and configuring user_accounts.
353+
os_user_accounts_enabled: true
354+
355+
# Set to false to disable installing and configuring rhosts.
356+
os_rhosts_enabled: true
357+
358+
# Set to false to disable installing and configuring yum.
359+
os_yum_enabled: true
360+
361+
# Set to false to disable installing and configuring apt.
362+
os_apt_enabled: true
363+
364+
# Set to false to disable installing and configuring selinux.
365+
os_selinux_enabled: true
366+
325367
# Define the number of SHA rounds.
326368
# With a lot of rounds brute forcing the password is more difficult. But note also that it more CPU resources will be needed to authenticate users.
327369
# The values must be inside the 1000-999999999 range.

roles/os_hardening/tasks/hardening.yml

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,49 +28,66 @@
2828

2929
- import_tasks: cron.yml
3030
tags: cron
31+
when: os_cron_enabled | bool
3132

3233
- import_tasks: limits.yml
3334
tags: limits
35+
when: os_limits_enabled | bool
3436

3537
- import_tasks: login_defs.yml
3638
tags: login_defs
39+
when: os_login_defs_enabled | bool
3740

3841
- import_tasks: minimize_access.yml
3942
tags: minimize_access
43+
when: os_minimize_access_enabled | bool
4044

4145
- import_tasks: pam.yml
4246
tags: pam
47+
when: os_pam_enabled | bool
4348

4449
- import_tasks: modprobe.yml
4550
tags: modprobe
51+
when: os_modprobe_enabled | bool
4652

4753
- import_tasks: profile.yml
4854
tags: profile
55+
when: os_profile_enabled | bool
4956

5057
- import_tasks: securetty.yml
5158
tags: securetty
59+
when: os_securetty_enabled | bool
5260

5361
- import_tasks: suid_sgid.yml
5462
when: os_security_suid_sgid_enforce | bool
5563
tags: suid_sgid
5664

5765
- import_tasks: sysctl.yml
5866
tags: sysctl
67+
when: os_sysctl_enabled | bool
5968

6069
- import_tasks: user_accounts.yml
6170
tags: user_accounts
71+
when: os_user_accounts_enabled | bool
6272

6373
- import_tasks: rhosts.yml
6474
tags: rhosts
75+
when: os_rhosts_enabled | bool
6576

6677
- import_tasks: yum.yml
67-
when: ansible_facts.os_family == 'RedHat'
6878
tags: yum
79+
when:
80+
- ansible_facts.os_family == 'RedHat'
81+
- os_yum_enabled | bool
6982

7083
- import_tasks: apt.yml
71-
when: ansible_facts.os_family == 'Debian'
7284
tags: apt
85+
when:
86+
- ansible_facts.os_family == 'Debian'
87+
- os_apt_enabled | bool
7388

7489
- import_tasks: selinux.yml
7590
tags: selinux
76-
when: ansible_facts.selinux.status == 'enabled'
91+
when:
92+
- ansible_facts.selinux.status == 'enabled'
93+
- os_selinux_enabled | bool

0 commit comments

Comments
 (0)