--- # 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: Add or remove packages based on STIG requirements package: name: | {%- set pkg_list = [] %} {%- for package_dict in item[1] %} {%- if pkg_list.extend(package_dict.packages) %}{% endif %} {%- endfor %} {{ pkg_list }} state: "{{ item[0] }}" with_items: - "{{ stig_packages_rhel7 | selectattr('enabled') | groupby('state') }}" tags: - cat1 - auth - packages - services - RHEL-07-010072 - RHEL-07-020000 - RHEL-07-020010 - RHEL-07-021280 - RHEL-07-021910 - RHEL-07-030810 - RHEL-07-040260 - RHEL-07-040500 - RHEL-07-040560 - name: RHEL-07-020200 - Clean requirements/dependencies when removing packages (rpm) lineinfile: dest: /etc/yum.conf regexp: "^(#)?clean_requirements_on_remove" line: "clean_requirements_on_remove=1" state: present when: - security_package_clean_on_remove | bool - ansible_os_family | lower == 'redhat' tags: - low - packages - RHEL-07-020200 - name: RHEL-07-020200 - Clean requirements/dependencies when removing packages (dpkg) lineinfile: dest: /etc/apt/apt.conf.d/security-autoremove regexp: "^(#)?APT::Get::AutomaticRemove" line: "APT{{ '::' }}Get{{ '::' }}AutomaticRemove \"0\";" state: present create: yes when: - security_package_clean_on_remove | bool - ansible_os_family | lower == 'debian' tags: - low - packages - RHEL-07-020200 - name: RHEL-07-020250 - System security patches and updates must be installed and up to date. (yum) lineinfile: dest: /etc/yum/yum-cron.conf regexp: "^apply_updates" line: "apply_updates = yes" state: present when: - ansible_os_family | lower == 'redhat' - security_rhel7_automatic_package_updates | bool tags: - packages - medium - RHEL-07-020250 - name: RHEL-07-020250 - System security patches and updates must be installed and up to date. (apt) copy: src: 20auto-upgrades dest: /etc/apt/apt.conf.d/20auto-upgrades when: - ansible_os_family | lower == 'ubuntu' - security_rhel7_automatic_package_updates | bool tags: - packages - cat2 - RHEL-07-020250