Coder Social home page Coder Social logo

buluma / ansible-role-auditd Goto Github PK

View Code? Open in Web Editor NEW
1.0 2.0 1.0 117 KB

Install and configure auditd on your system.

Home Page: https://galaxy.ansible.com/buluma/auditd

License: Apache License 2.0

Jinja 89.55% Shell 10.45%
ansible ansible-role auditd molecule tox

ansible-role-auditd's Introduction

Ansible role auditd

Install and configure auditd on your system.

GitHub Version Issues Pull Requests Downloads
github Version Issues PullRequests Ansible Role

This example is taken from molecule/default/converge.yml and is tested on each push, pull request and release.

---
- name: Converge
  hosts: all
  become: true
  gather_facts: true

  roles:
    - role: buluma.auditd
      auditd_start_service: false
      auditd_local_events: "no"
      auditd_rules:
        - file: /var/log/audit/
          keyname: auditlog
        - file: /etc/audit/
          permissions:
            - write
            - attribute_change
          keyname: auditconfig
        - file: /etc/libaudit.conf
          permissions:
            - write
            - attribute_change
          keyname: auditconfig
        - file: /etc/audisp/
          permissions:
            - write
            - attribute_change
          keyname: audispconfig
        - file: /sbin/auditctl
          permissions:
            - execute
          keyname: audittools
        - file: /sbin/auditd
          permissions:
            - execute
          keyname: audittools
        - syscall: open
          action: always
          filter: exit
          filters:
            - auid!=4294967295
            - auid!=unset
          keyname: my_keyname
          arch: b32
        - syscall: adjtimex
          action: always
          filter: exit
          keyname: time_change
        - syscall: settimeofday
          action: always
          filter: exit
          keyname: time_change
        - action: always
          filter: exit
          filters:
            - path=/bin/ping
            - perm=x
            - auid>=500
            - auid!=4294967295
          keyname: privileged

The machine needs to be prepared. In CI this is done using molecule/default/prepare.yml:

---
- name: Prepare
  hosts: all
  become: true
  gather_facts: false

  roles:
    - role: buluma.bootstrap

Also see a full explanation and example on how to use these roles.

The default values for the variables are set in defaults/main.yml:

---
# defaults file for auditd

# Below variables are docuemented in the man page for auditd.conf
# https://linux.die.net/man/5/auditd.conf
auditd_buffer_size: 32768
auditd_fail_mode: 1
auditd_maximum_rate: 60
auditd_enable_flag: 1
auditd_local_events: "yes"
auditd_write_logs: "yes"
auditd_log_file: /var/log/audit/audit.log
auditd_log_group: root
auditd_log_format: RAW
auditd_flush: incremental_async
auditd_freq: 50
auditd_max_log_file: 8
auditd_num_logs: 5
auditd_priority_boost: 4
auditd_disp_qos: lossy
auditd_dispatcher: /sbin/audispd
auditd_name_format: none
auditd_max_log_file_action: rotate
auditd_space_left: "75"  # This can be a number ('25') or a percentage. ('25%')
auditd_space_left_action: syslog
auditd_verify_email: "yes"
auditd_action_mail_acct: root
auditd_admin_space_left: 50
auditd_admin_space_left_action: suspend
auditd_disk_full_action: suspend
auditd_disk_error_action: suspend
auditd_use_libwrap: "yes"
auditd_tcp_listen_queue: 5
auditd_tcp_max_per_addr: 1
auditd_tcp_client_max_idle: 0
auditd_enable_krb5: "no"
auditd_krb5_principal: auditd
auditd_distribute_network: "no"

# You can opt to manage the rules with this role or not.
# Setting auditd_manage_rules to false will not manage the rules.
auditd_manage_rules: true

# Some rules require a specific architecture to be set.
auditd_default_arch: b64


# You can opt to start the auditd service or not.
# Mostly useful in CI, to avoid starting the service.
auditd_start_service: true

The following roles are used to prepare a system. You can prepare your system in another way.

Requirement GitHub Version
buluma.bootstrap Ansible Molecule Version

This role is a part of many compatible roles. Have a look at the documentation of these roles for further information.

Here is an overview of related roles:

dependencies

This role has been tested on these container images:

container tags
EL 8, 9
Debian all
Fedora all
opensuse all
Ubuntu all

The minimum version of Ansible required is 2.12, tests have been done to:

  • The previous version.
  • The current version.
  • The development version.

If you find issues, please register them in GitHub

Role History

Apache-2.0

Shadow Walker

ansible-role-auditd's People

Contributors

buluma avatar dependabot[bot] avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Forkers

nono-lqdn

ansible-role-auditd's Issues

Assertion for auditd_space_left contradicts what's written in the README

If you look at

- auditd_admin_space_left >= 0
, you will see that the assertion for auditd_space_left contradicts what's written in the README.

It's written that it can be

auditd_space_left: "75" # This can be a number ('25') or a percentage. ('25%')

But actually, if you write a percentage, then it's a string, but the assertion checks that it's a number.

The audtid.conf(5) manual says that ;

space_left
If the free space in the filesystem containing log_file
drops below this value, the audit daemon takes the action
specified by space_left_action. If the value of
space_left is specified as a whole number, it is
interpreted as an absolute size in megabytes (MiB). If
the value is specified as a number between 1 and 99
followed by a percentage sign (e.g., 5%), the audit daemon
calculates the absolute size in megabytes based on the
size of the filesystem containing log_file. (E.g., if the
filesystem containing log_file is 2 gigabytes in size, and
space_left is set to 25%, then the audit daemon sets
space_left to approximately 500 megabytes. Note that this
calculation is performed when the audit daemon starts, so
if you resize the filesystem containing log_file while the
audit daemon is running, you should send the audit daemon
SIGHUP to re-read the configuration file and recalculate
the correct percentage.

Thus, the assertion should check that it's

  • A number, between 0 and the maximum int value.

OR

  • A string, containing a value between 0 and 99, ending with '%'.

Currently, it's only possible for the role to specify a value in MB between 0 and 100.

The code should be something like this :


- name: assert | Test auditd_admin_space_left
  ansible.builtin.assert:
    that:
      - auditd_admin_space_left is defined
      - auditd_admin_space_left is number or  auditd_admin_space_left is string 
      - auditd_admin_space_left is match("([0-9])%*")
    quiet: true

Update buluma/[email protected] @buluma

Update buluma/[email protected] @buluma

uses: "alstr/[email protected]" # TODO: Update buluma/[email protected] @buluma

      - uses: "actions/checkout@master"
      - name: "TODO to Issue"
        uses: "alstr/[email protected]"  # TODO: Update buluma/[email protected] @buluma
        id: "todo"
        with:
          TOKEN: ${{ secrets.GITHUB_TOKEN }}
ndex 200896a..7b52be1 100644
++ b/.gitlab-ci.yml

06e8bf7fafd7c733c853d18ccb5b510e90a3a3d9

build debian and ubuntu

build debian and ubuntu

- image: "fedora". # TODO build debian and ubuntu

  parallel:
    matrix:
      - image: "fedora".  # TODO build debian and ubuntu
        tag: "34"
      - image: "fedora"
        tag: "latest"
      - image: "fedora"
        tag: "rawhide"

galaxy:
  script:

549dae8a3a195a43babad2a72eb5980c7fec8a43

Update action

Update action

on:
  - push

name: Ansible Graphviz

jobs:
  build:
    runs-on: ubuntu-20.04
    permissions:
      contents: write
    steps:
      - name: checkout
        uses: actions/checkout@v3
        with:
          path: ${{ github.repository }}
      - name: create png
        uses: buluma/[email protected] # TODO: Update action
      - name: Commit files
        run: |
          cd ${{ github.repository }}

95f24d2b9a0f9a62ee6353d9a6f6135bff469cf2

Update buluma/[email protected] @buluma

Update buluma/[email protected] @buluma

uses: "alstr/[email protected]" # TODO: Update buluma/[email protected] @buluma

  push:

jobs:
  build:
    runs-on: "ubuntu-20.04"
    steps:
      - uses: "actions/checkout@master"
      - name: "TODO to Issue"
        uses: "alstr/[email protected]" # TODO: Update buluma/[email protected] @buluma
        id: "todo"
        with:
          TOKEN: ${{ secrets.GITHUB_TOKEN }}
ndex 21ed080..ad73ff6 100644
++ b/.gitignore

807ab7b062c8e72d4af7d11910c5e9a716431004

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.