Execution
Date
15 Dec 2025 09:38:00 +0000
Duration
00:17:22.68
Controller
aio1.openstack.local
User
root
Versions
Ansible
2.18.6
ara
1.7.4 / 1.7.4
Python
3.12.3
Summary
18
Hosts
603
Tasks
2798
Results
18
Plays
138
Files
0
Records
File: /home/zuul/src/opendev.org/openstack/ansible-hardening/tasks/rhel7stig/misc.yml
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 | --- # Copyright 2016, Rackspace US, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. - name: Check autofs service ansible.builtin.command: systemctl status autofs # noqa: command-instead-of-module register: autofs_check failed_when: autofs_check.rc not in [0,3,4] changed_when: false check_mode: false tags: - always - name: V-71985 - File system automounter must be disabled unless required. ansible.builtin.service: name: autofs state: stopped enabled: false when: - autofs_check.rc not in [3,4] - security_rhel7_disable_autofs | bool tags: - medium - misc - V-71985 # NOTE(noonedeadpunk): We run this twice because of the ansible bug: # https://github.com/ansible/ansible/issues/68680 # This returns an exit code of 0 if it's running, 3 if it's masked. - name: V-71993 - The x86 Ctrl-Alt-Delete key sequence must be disabled ansible.builtin.systemd: name: ctrl-alt-del.target enabled: false when: - security_rhel7_disable_ctrl_alt_delete | bool tags: - high - misc - V-71993 - name: V-71993 - The x86 Ctrl-Alt-Delete key sequence must be disabled ansible.builtin.systemd: name: ctrl-alt-del.target masked: true daemon_reload: true when: - security_rhel7_disable_ctrl_alt_delete | bool tags: - high - misc - V-71993 - name: Check for /home on mounted filesystem ansible.builtin.debug: msg: | The STIG requires that /home is on its own filesystem, but this system does not appear to be following the requirement. when: - ansible_facts['mounts'] | selectattr('mount', 'equalto', '/home') | list | length == 0 tags: - low - misc - V-72059 - name: Check for /var on mounted filesystem ansible.builtin.debug: msg: | The STIG requires that /var is on its own filesystem, but this system does not appear to be following the requirement. when: - ansible_facts['mounts'] | selectattr('mount', 'equalto', '/var') | list | length == 0 tags: - low - misc - V-72067 - name: Check for /var/log/audit on mounted filesystem ansible.builtin.debug: msg: | The STIG requires that /var/log/audit is on its own filesystem, but this system does not appear to be following the requirement. when: - ansible_facts['mounts'] | selectattr('mount', 'equalto', '/var/log/audit') | list | length == 0 tags: - low - misc - V-72063 - name: Check for /tmp on mounted filesystem ansible.builtin.debug: msg: | The STIG requires that /tmp is on its own filesystem, but this system does not appear to be following the requirement. when: - ansible_facts['mounts'] | selectattr('mount', 'equalto', '/tmp') | list | length == 0 tags: - low - misc - V-72065 - name: Check if syslog output is being sent to another server ansible.builtin.command: 'grep "^[^#].*@" /etc/rsyslog.conf' register: rsyslog_transmit_check changed_when: false failed_when: false check_mode: false tags: - always - name: V-72209 - The system must send rsyslog output to a log aggregation server. ansible.builtin.debug: msg: Output from syslog must be sent to another server. when: - rsyslog_transmit_check is defined - rsyslog_transmit_check.rc != 0 tags: - medium - misc - V-72209 - name: Check if ClamAV is installed ansible.builtin.stat: path: /usr/bin/clamdscan register: clamav_install_check changed_when: false tags: - always - name: Remove 'Example' line from ClamAV configuration files ansible.builtin.lineinfile: dest: "{{ item }}" regexp: "^Example" state: absent with_items: - /etc/freshclam.conf - /etc/clamd.d/scan.conf when: - clamav_install_check.stat.exists - security_enable_virus_scanner | bool - ansible_facts['os_family'] | lower == 'redhat' notify: - Restart clamav tags: - misc - V-72213 - name: Set ClamAV server type as socket ansible.builtin.lineinfile: dest: /etc/clamd.d/scan.conf regexp: "^(#)?LocalSocket (.*)$" line: "LocalSocket {{ clamav_service_details['socket_path'] }}" backrefs: true when: - clamav_install_check.stat.exists - security_enable_virus_scanner | bool - ansible_facts['os_family'] | lower == 'redhat' notify: - Restart clamav tags: - misc - V-72213 - name: Ensure ClamAV socket directory exists ansible.builtin.file: path: "{{ clamav_service_details['socket_path'] | dirname }}" owner: "{{ clamav_service_details['user'] }}" group: "{{ clamav_service_details['group'] }}" mode: "{{ clamav_service_details['mode'] }}" when: - clamav_install_check.stat.exists - security_enable_virus_scanner | bool - ansible_facts['os_family'] | lower == 'redhat' notify: - Restart clamav tags: - misc - V-72213 - name: Allow automatic freshclam updates ansible.builtin.lineinfile: dest: /etc/sysconfig/freshclam regexp: "^FRESHCLAM_DELAY" state: absent when: - clamav_install_check.stat.exists - security_enable_virus_scanner | bool - ansible_facts['os_family'] | lower == 'redhat' notify: - Restart clamav tags: - misc - V-72213 - name: Check if ClamAV update process is already running ansible.builtin.shell: "set -o pipefail; ps -ef | grep -E [f]reshclam -q" register: freshclam_proc changed_when: false failed_when: false check_mode: false tags: - always - name: Update ClamAV database ansible.builtin.command: freshclam changed_when: false when: - freshclam_proc.rc != 0 - clamav_install_check.stat.exists - security_enable_virus_scanner | bool - security_run_virus_scanner_update | bool async: 300 poll: 5 tags: - misc - V-72213 - name: Ensure ClamAV is running ansible.builtin.service: name: "{{ clamav_service }}" state: started enabled: true when: - clamav_install_check.stat.exists - security_enable_virus_scanner | bool tags: - misc - V-72213 - name: V-72223 - Set 10 minute timeout on communication sessions ansible.builtin.blockinfile: dest: /etc/profile state: present insertbefore: EOF marker: "# {mark} MANAGED BY ANSIBLE-HARDENING" block: | # Set a {{ security_rhel7_session_timeout }} second timeout for sessions TMOUT={{ security_rhel7_session_timeout }} readonly TMOUT export TMOUT tags: - medium - misc - V-72223 - name: Start and enable chrony ansible.builtin.service: name: "{{ chrony_service }}" state: started enabled: true when: - not check_mode - security_rhel7_enable_chrony | bool tags: - medium - misc - V-72269 - name: Check if chrony configuration file exists ansible.builtin.stat: path: "{{ chrony_conf_file }}" register: chrony_conf_check tags: - always - name: V-72269 - Synchronize system clock (configuration file) ansible.builtin.template: src: chrony.conf.j2 dest: "{{ chrony_conf_file }}" mode: "0644" when: - chrony_conf_check.stat.exists | bool - security_rhel7_enable_chrony | bool notify: - Restart chrony tags: - medium - misc - V-72269 # Returns 0 if installed, 3 if not installed - name: Check firewalld status ansible.builtin.command: systemctl status firewalld register: firewalld_status_check failed_when: firewalld_status_check.rc not in [0,3,4] changed_when: false check_mode: false tags: - always - name: Ensure firewalld is running and enabled ansible.builtin.service: name: firewalld state: started enabled: true when: - firewalld_status_check.rc not in [3,4] - security_enable_firewalld | bool tags: - medium - misc - V-72273 - name: Limit new TCP connections to 25/minute and allow bursting to 100 ansible.builtin.command: >- firewall-cmd --direct --add-rule ipv4 filter IN_public_allow 0 -m tcp -p tcp -m limit --limit {{ security_enable_firewalld_rate_limit_per_minute }}/minute --limit-burst {{ security_enable_firewalld_rate_limit_burst }} -j ACCEPT register: add_rate_limit_firewalld_rule changed_when: "'ALREADY_ENABLED' not in add_rate_limit_firewalld_rule.stdout" when: - firewalld_status_check.rc != 3 - security_enable_firewalld_rate_limit | bool tags: - medium - misc - V-72271 # Linting checks need to be skipped because this command doesn't create any # files. - name: Count nameserver entries in /etc/resolv.conf command: grep ^nameserver /etc/resolv.conf register: nameserver_check check_mode: false changed_when: false failed_when: false tags: - always - skip_ansible_lint - name: V-72281 - For systems using DNS resolution, at least two name servers must be configured. ansible.builtin.debug: msg: | Two or more nameservers must be configured in /etc/resolv.conf. Nameservers found: {{ nameserver_check.stdout_lines | length }} when: - nameserver_check is defined - nameserver_check.stdout_lines | length < 2 tags: - low - misc - V-72281 - name: Check for interfaces in promiscuous mode ansible.builtin.shell: "set -o pipefail; ip link | grep -i promisc" register: promiscuous_interface_check changed_when: false failed_when: false check_mode: false tags: - always - name: V-72295 - Network interfaces must not be in promiscuous mode. ansible.builtin.debug: msg: > One or more network interfaces were found to be in promiscuous mode. Review all interfaces and disable promiscuous mode. when: - promiscuous_interface_check.rc == 0 tags: - medium - misc - V-72295 - name: Check for postfix configuration file ansible.builtin.stat: path: /etc/postfix/main.cf register: postfix_conf_check tags: - always - name: V-72297 - Prevent unrestricted mail relaying ansible.builtin.lineinfile: dest: /etc/postfix/main.cf regexp: "^smtpd_client_restrictions" line: "smtpd_client_restrictions = permit_mynetworks, reject" when: - postfix_conf_check.stat.exists - security_rhel7_restrict_mail_relaying | bool tags: - medium - misc - V-72297 - name: Check for TFTP server configuration file ansible.builtin.stat: path: /etc/xinetd.d/tftp register: tftp_config_check check_mode: false tags: - always - name: Check TFTP configuration mode ansible.builtin.command: "grep server_args /etc/xinetd.d/tftp" register: tftp_secure_check changed_when: false failed_when: false check_mode: false when: - tftp_config_check.stat.exists tags: - always - name: V-72305 - TFTP must be configured to operate in secure mode ansible.builtin.debug: msg: TFTP must be configured to run in secure mode with the '-s' flag. when: - tftp_config_check.stat.exists - "'-s' not in tftp_secure_check.stdout" tags: - medium - misc - V-72305 - name: Check to see if snmpd config contains public/private ansible.builtin.command: 'grep -E "^[^#].*(public|private)" /etc/snmp/snmpd.conf' register: snmp_public_private_check changed_when: false failed_when: false check_mode: false tags: - always - name: V-72313 - Change SNMP community strings from default. ansible.builtin.debug: msg: > Change the SNMP community strings from the defaults of 'public' and 'private' to meet the requirements of V-72313. when: - snmp_public_private_check.rc == 0 tags: - high - misc - V-72313 |