Files
ansible-role-aide/tasks/main.yml
T
marko aadd117d01
Ansible Lint / ansible_lint (map[ansible:2.16.* ansible_lint:24.* python:3.12]) (push) Failing after 45s
Ansible Lint / ansible_lint (map[ansible:2.20.* ansible_lint:26.* python:3.13]) (push) Failing after 49s
Check for ansible_managed variable use in comments / ansible_managed_var_comment (push) Failing after 6s
Ansible Test / ansible_test (map[ansible:2-14 python:3.9]) (push) Failing after 5s
Ansible Test / ansible_test (map[ansible:2-16 python:3.11]) (push) Failing after 5s
Ansible Test / ansible_test (map[ansible:2-17 python:3.12]) (push) Failing after 5s
Ansible Test / ansible_test (map[ansible:2-18 python:3.12]) (push) Failing after 4s
Ansible Test / ansible_test (map[ansible:2-19 python:3.13]) (push) Failing after 5s
Ansible Test / ansible_test (map[ansible:2-20 python:3.13]) (push) Failing after 5s
Ansible Test / ansible_test (map[ansible:milestone python:3.13]) (push) Failing after 4s
Markdown Lint / markdownlint (push) Failing after 40s
Test / scenario (map[env:container-ansible-core-2-16 image:centos-9-bootc]) (push) Failing after 42s
Test / scenario (map[env:container-ansible-core-2-16 image:centos-9]) (push) Failing after 45s
Test / scenario (map[env:container-ansible-core-2-17 image:centos-10-bootc]) (push) Failing after 39s
Test / scenario (map[env:container-ansible-core-2-20 image:fedora-43-bootc]) (push) Failing after 42s
Test / scenario (map[env:container-ansible-core-2-20 image:fedora-43]) (push) Failing after 34s
Test / scenario (map[env:container-ansible-core-2-20 image:fedora-44-bootc]) (push) Failing after 28s
Test / scenario (map[env:container-ansible-core-2-21 image:fedora-44]) (push) Failing after 30s
Test / scenario (map[env:qemu-ansible-core-2-16 image:centos-9]) (push) Failing after 37s
Test / scenario (map[env:qemu-ansible-core-2-17 image:centos-10]) (push) Failing after 31s
Test / scenario (map[env:qemu-ansible-core-2-18 image:leap-15.6]) (push) Failing after 30s
Test / scenario (map[env:qemu-ansible-core-2-20 image:fedora-43]) (push) Failing after 42s
Test / scenario (map[env:qemu-ansible-core-2-21 image:fedora-44]) (push) Failing after 37s
ShellCheck / shellcheck (push) Failing after 50s
Test converting README.md to README.html / test_converting_readme (push) Failing after 41s
Refine AIDE update command error handling based on return codes
2026-07-27 20:32:10 +02:00

168 lines
5.3 KiB
YAML

# SPDX-License-Identifier: MIT
---
- name: Set platform/version specific variables
include_tasks: tasks/set_vars.yml
# Examples of some tasks:
- name: Ensure required packages are installed
ansible.builtin.package:
name: "{{ __aide_packages }}"
state: present
use: "{{ (__aide_is_ostree | d(false)) |
ternary('ansible.posix.rhel_rpm_ostree', omit) }}"
register: __aide_install_packages
- name: Packages are installed
# either run mode or check mode and no changes to packages
when: not ansible_check_mode or (ansible_check_mode and not __aide_install_packages.changed)
block:
- name: Get AIDE version
ansible.builtin.command:
cmd: aide --version
check_mode: false
register: __aide_version_register
changed_when: false
# assumes the version starts with a digit and goes to the end of the line
- name: Set AIDE version
set_fact:
aide_version: "{{ __output | regex_search('(?m)^A[iI][dD][eE] (\\d.*)$', '\\1') | first }}"
vars:
__output: "{{ __aide_version_register.stdout if __aide_version_register.stdout | length > 0
else __aide_version_register.stderr }}"
- name: Ensure required services are enabled and started
ansible.builtin.service:
name: "{{ item }}"
state: started
enabled: true
loop: "{{ __aide_services }}"
- name: Generate "/etc/{{ __aide_config }}"
ansible.builtin.template:
src: "{{ aide_config_template }}"
dest: "/etc/{{ __aide_config }}"
mode: "0400"
when: aide_config_template is not none
# - name: Print Header
# ansible.builtin.command: head /etc/aide.conf || true
- name: Initialize AIDE database
when:
- not ansible_check_mode
- aide_init | bool
block:
- name: Initialize AIDE database
ansible.builtin.command:
cmd: aide --init
changed_when: true
- name: Copy AIDE reference database
ansible.builtin.copy:
remote_src: true
src: "{{ __aide_db_new_name }}"
dest: "{{ __aide_db_name }}"
owner: root
group: root
mode: "0440"
force: true
when: not aide_fetch_db | bool
- name: Remove remote AIDE database file
ansible.builtin.file:
path: "{{ __aide_db_new_name }}"
state: absent
when: not aide_fetch_db | bool
- name: Fetch AIDE database
when:
- not ansible_check_mode
- aide_fetch_db | bool
block:
- name: Fetch AIDE database
ansible.builtin.fetch:
src: "{{ __aide_db_new_name }}"
dest: "{{ aide_db_fetch_dir }}"
- name: Remove remote AIDE database file
ansible.builtin.file:
path: "{{ __aide_db_new_name }}"
state: absent
- name: Check AIDE integrity
when:
- not ansible_check_mode
- aide_check | bool
block:
- name: Copy AIDE reference database
ansible.builtin.copy:
src: >-
{{ aide_db_fetch_dir }}/{{ inventory_hostname }}{{ __aide_db_new_name }}
dest: "{{ __aide_db_name }}"
owner: root
group: root
mode: "0440"
when: aide_upload_db | bool
- name: Check against AIDE reference database
ansible.builtin.command:
cmd: aide --check
register: __aide_check_result
changed_when: __aide_check_result.rc > 1 and __aide_check_result.rc <= 7
failed_when: __aide_check_result.rc >= 14
- name: Update AIDE database and fetch it
when:
- not ansible_check_mode
- aide_update | bool
block:
- name: Update AIDE database
ansible.builtin.command:
cmd: aide --update
register: __aide_update_result
changed_when: __aide_update_result.rc > 1 and __aide_update_result.rc <= 7
failed_when: __aide_update_result.rc >= 14
- name: Fetch AIDE database
ansible.builtin.fetch:
src: "{{ __aide_db_new_name }}"
dest: "{{ aide_db_fetch_dir }}"
- name: Remove remote AIDE database file
ansible.builtin.file:
path: "{{ __aide_db_new_name }}"
state: absent
- name: Update aide check cron configuration if necessary
ansible.builtin.lineinfile:
path: /etc/crontab
regexp: "^.* root {{ __aide_bin_path }} --check"
line: "{{ aide_cron_interval }} root {{ __aide_bin_path }} --check"
when:
- aide_cron_check is not none
- aide_cron_check | bool
- name: Remove aide check cron configuration if necessary
ansible.builtin.lineinfile:
path: /etc/crontab
state: absent
regexp: "^.* root {{ __aide_bin_path }} --check"
when:
- aide_cron_check is not none
- not aide_cron_check | bool
- name: Fetch AIDE logs
ansible.builtin.fetch:
src: "/var/log/aide/aide.log"
dest: "{{ aide_db_fetch_dir }}"
owner: root
group: root
mode: "0640"
- name: Record role success fingerprint
sr_fingerprint:
sr_message: >-
success system_role:aide ansible_version={{ ansible_version.full }}
{{ ansible_facts['distribution'] }}-{{ ansible_facts['distribution_version'] }}