openstack-ansible-security/tasks/rhel7stig/aide.yml
Major Hayden efbeb691a2 Add AIDE checks for ACL/xattrs [+Docs]
CentOS/RHEL have strict AIDE configs, but Ubuntu's configuration needs
extra configuration. This patch adds lines to the end of Ubuntu's AIDE
confgiuration to meet the requirements of RHEL-07-021600,
RHEL-07-021610, and RHEL-07-021620.

Documentation is included.

Implements: blueprint security-rhel7-stig
Change-Id: I107fa931f80d6871195027be0ed8db4105e2ddf4
2016-12-08 22:21:01 +00:00

103 lines
2.9 KiB
YAML

---
# 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: Verify that AIDE configuration directory exists
stat:
path: /etc/aide/aide.conf.d
register: aide_conf
check_mode: no
tags:
- always
- name: Exclude certain directories from AIDE
template:
src: ZZ_aide_exclusions.j2
dest: /etc/aide/aide.conf.d/ZZ_aide_exclusions
when: aide_conf.stat.exists | bool
tags:
- medium
- aide
- RHEL-07-020130
- name: Check to see if AIDE database is already in place
stat:
path: "{{ aide_database_file }}"
register: aide_database
check_mode: no
tags:
- always
- name: Initialize AIDE (this will take a few minutes)
command: "aideinit"
changed_when: false
register: aide_init
when:
- aide_conf.stat.exists | bool
- not aide_database.stat.exists | bool
- security_rhel7_initialize_aide | bool
tags:
- medium
- aide
- RHEL-07-020130
# NOTE(mhayden): This is only needed for CentOS 7 and RHEL 7 since Ubuntu
# copies the new AIDE database into place automatically with its AIDE wrapper
# script.
- name: Move AIDE database into place
command: "mv /var/lib/aide/aide.db.new.gz {{ aide_database_file }}"
changed_when: false
when:
- aide_init | changed
- ansible_os_family | lower == 'redhat'
tags:
- medium
- aide
- RHEL-07-020130
# NOTE(mhayden): This is only needed for CentOS 7 and RHEL 7 since the AIDE
# package doesn't come with a cron job file. Ubuntu packages a cron job for
# AIDE checks already.
- name: Create AIDE cron job
cron:
name: aide
cron_file: aide
user: root
special_time: daily
job: "aide --check | /bin/mail -s \"$HOSTNAME - Daily aide integrity check run\" root"
when:
- ansible_os_family | lower == 'redhat'
tags:
- medium
- aide
- RHEL-07-020140
# NOTE(mhayden): CentOS/RHEL already provide a very strict AIDE configuration
# that meets the requirements of RHEL-07-021600 and RHEL-07-021610. That config
# is borrowed for Ubuntu 16.04 here.
- name: Configure AIDE to verify additional properties
blockinfile:
dest: "{{ aide_conf }}"
insertbefore: EOF
marker: "# {mark} MANAGED BY OPENSTACK-ANSIBLE-SECURITY"
block: "{{ lookup('file', 'aide_extra.conf') }}"
when:
- ansible_os_family | lower == 'ubuntu'
tags:
- low
- aide
- RHEL-07-021600
- RHEL-07-021610
- RHEL-07-021620