Skip to content

Commit 4ca4f09

Browse files
authored
Cleanup old OS-support and simplify vars (#458)
* use os_family instead of distribution for debian systems Signed-off-by: rndmh3ro <[email protected]> * remove tasks related to rhel6 or debian 6 Signed-off-by: rndmh3ro <[email protected]>
1 parent 72ec118 commit 4ca4f09

File tree

8 files changed

+6
-25
lines changed

8 files changed

+6
-25
lines changed

roles/os_hardening/tasks/hardening.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@
6868
tags: yum
6969

7070
- import_tasks: apt.yml
71-
when: ansible_facts.distribution in ['Debian', 'Ubuntu']
71+
when: ansible_facts.os_family == 'Debian'
7272
tags: apt
7373

7474
- import_tasks: selinux.yml

roles/os_hardening/tasks/modprobe.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@
1919
- name: Remove used filesystems from fs-list
2020
set_fact:
2121
os_unused_filesystems: "{{ os_unused_filesystems | difference(ansible_mounts | map(attribute='fstype') | list) }}"
22-
# we cannot do this on el6 and below, because these systems don't support the map function
23-
when: not ((ansible_facts.os_family in ['Oracle Linux', 'RedHat']) and ansible_facts.distribution_major_version < '7')
2422

2523
- name: Disable unused filesystems | os-10
2624
template:

roles/os_hardening/tasks/pam.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020
- import_tasks: pam_debian.yml
2121
when:
22-
- ansible_facts.distribution in ['Debian', 'Ubuntu']
22+
- ansible_facts.os_family == 'Debian'
2323

2424
- import_tasks: pam_rhel.yml
2525
when:

roles/os_hardening/tasks/sysctl.yml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,16 +58,15 @@
5858
ignoreerrors: true
5959
with_dict: '{{ sysctl_config }}'
6060

61-
- name: Change various sysctl-settings on rhel6-hosts or older, look at the sysctl-vars file for documentation
61+
- name: Change various sysctl-settings on Amazon Linux, look at the sysctl-vars file for documentation
6262
sysctl:
6363
name: '{{ item.key }}'
6464
value: '{{ item.value }}'
6565
state: present
6666
reload: true
6767
ignoreerrors: true
6868
with_dict: '{{ sysctl_rhel_config }}'
69-
when: ((ansible_facts.distribution in ['CentOS', 'Fedora', 'RedHat']) and
70-
ansible_distribution_version|int is version('7', '<')) or ansible_facts.distribution == 'Amazon'
69+
when: ansible_facts.distribution == 'Amazon'
7170

7271
when: ansible_virtualization_type not in ['docker', 'lxc', 'openvz']
7372

@@ -78,5 +77,5 @@
7877
mode: '0644'
7978
when:
8079
- ufw_manage_defaults
81-
- ansible_facts.distribution in ['Debian', 'Ubuntu']
80+
- ansible_facts.os_family == 'Debian'
8281
tags: ufw

roles/ssh_hardening/defaults/main.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,6 @@ ssh_server_accept_env_vars: ''
191191
# maximum number of concurrent unauthenticated connections to the SSH daemon
192192
ssh_max_startups: '10:30:60' # sshd
193193

194-
ssh_ps53: 'yes'
195194
ssh_ps59: 'sandbox'
196195

197196
ssh_macs: []

roles/ssh_hardening/tasks/crypto_macs.yml

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,6 @@
44
ssh_macs: '{{ ssh_macs_53_default }}'
55
when: sshd_version is version('5.3', '>=')
66

7-
- name: Set macs for Enterprise Linux >= 6.5 (openssh 5.3 with backports)
8-
set_fact:
9-
ssh_macs: '{{ ssh_macs_53_el_6_5_default }}'
10-
when:
11-
- ansible_facts.distribution in ['CentOS', 'OracleLinux', 'RedHat']
12-
- ansible_facts.distribution_version is version('6.5', '>=')
13-
147
- name: Set macs according to openssh-version if openssh >= 5.9
158
set_fact:
169
ssh_macs: '{{ ssh_macs_59_default }}'

roles/ssh_hardening/templates/opensshd.conf.j2

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -103,11 +103,7 @@ LogLevel {{ sshd_log_level }}
103103
UseLogin no
104104
{% endif %}
105105
{% if sshd_version is version('7.5', '<') %}
106-
UsePrivilegeSeparation {{
107-
(ansible_facts.distribution == 'Debian' and ansible_facts.distribution_major_version <= '6')
108-
or (ansible_facts.os_family in ['Oracle Linux', 'RedHat'] and ansible_facts.distribution_major_version <= '6' and not ansible_facts.distribution == 'Amazon')
109-
| ternary(ssh_ps53, ssh_ps59)
110-
}}
106+
UsePrivilegeSeparation {{ ssh_ps59 }}
111107
{% endif %}
112108

113109
LoginGraceTime {{ ssh_login_grace_time }}

roles/ssh_hardening/vars/main.yml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,6 @@ ssh_macs_53_default:
33
- hmac-ripemd160
44
- hmac-sha1
55

6-
ssh_macs_53_el_6_5_default:
7-
- hmac-sha2-512
8-
- hmac-sha2-256
9-
106
ssh_macs_59_default:
117
- hmac-sha2-512
128
- hmac-sha2-256

0 commit comments

Comments
 (0)