Skip to content

Commit

Permalink
Added custom template functionality
Browse files Browse the repository at this point in the history
Signed-off-by: Radovan Sroka <[email protected]>
  • Loading branch information
radosroka committed Nov 8, 2024
1 parent a4a60d1 commit 5c653f2
Show file tree
Hide file tree
Showing 14 changed files with 396 additions and 37 deletions.
27 changes: 19 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,21 @@ only.

## Role Variables

### aide_custom_template

This variable takes a string to specify a path where the custom template for aide.conf is located.

To be sure that everething is correct, template needs to start with following snippet:

``` jinja
{{ ansible_managed | comment }}
{{ "system_role:aide" | comment(prefix="", postfix="") }}
```

Default: `null`

Type: `string`

### aide_db_fetch_dir

This variable takes a string to specify the directory on the Ansible Control
Expand All @@ -45,17 +60,13 @@ same directory as the playbook.
In case you like to store the fetched AIDE database files somewhere else you
need to specify a different path here.

### aide_install
Default: `files`

With this variable the role ensures that the `aide` package is installed on the remote nodes

Default: `false`
Type: `string

Type: `bool`

### aide_generate_config
### aide_install

Generates the file `/etc/aide.conf` using `templates/aide.conf.j2`; the template needs to be adjusted to fit your requirements; if you do not use this varable the default configuration file shipped with the `aide` package will be used.
With this variable the role ensures that the `aide` package is installed on the remote nodes

Default: `false`

Expand Down
6 changes: 3 additions & 3 deletions defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
# Here is the right place to put the role's input variables.
# This file also serves as a documentation for such a variables.

# Path to template file
aide_custom_template: null

# Examples of role input variables:
aide_db_fetch_dir: files

# Enable install phase
aide_install: false

# Enable config file generation phase
aide_generate_config: false

# Enable initialization of the database phase
aide_init: false

Expand Down
File renamed without changes.
16 changes: 16 additions & 0 deletions examples/custom-template.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# SPDX-License-Identifier: MIT
---
- name: Example aide role invocation
hosts: targets
tasks:
- name: Include role aide
vars:
aide_custom_template: /tmp/aide-custom.conf.j2
aide_db_fetch_dir: files
aide_install: true
aide_init: true
aide_fetch_db: true
aide_check: true
aide_update: true
ansible.builtin.include_role:
name: linux-system-roles.aide
1 change: 0 additions & 1 deletion examples/default.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
vars:
aide_db_fetch_dir: files
aide_install: false
aide_generate_config: false
aide_init: false
aide_fetch_db: false
aide_check: false
Expand Down
7 changes: 3 additions & 4 deletions examples/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,9 @@
vars:
aide_db_fetch_dir: files
aide_install: true
aide_generate_config: true
aide_init: true
aide_fetch_db: true
aide_check: true
aide_update: true
aide_fetch_db: false
aide_check: false
aide_update: false
ansible.builtin.include_role:
name: linux-system-roles.aide
1 change: 0 additions & 1 deletion examples/just_check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
vars:
aide_db_fetch_dir: files
aide_install: false
aide_generate_config: false
aide_init: false
aide_fetch_db: false
aide_check: true
Expand Down
1 change: 0 additions & 1 deletion examples/just_update.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
vars:
aide_db_fetch_dir: files
aide_install: false
aide_generate_config: false
aide_init: false
aide_fetch_db: false
aide_check: false
Expand Down
9 changes: 6 additions & 3 deletions tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,15 @@

- name: Generate "/etc/{{ __aide_config }}"
ansible.builtin.template:
src: "{{ __aide_config }}.j2"
# remote_src: true
src: "{{ aide_custom_template }}"
dest: "/etc/{{ __aide_config }}"
backup: true
mode: "0400"
when:
- aide_generate_config
- aide_custom_template

#- name: Print Header
# ansible.builtin.shell: head /etc/aide.conf || true

- name: Initialize AIDE database
when:
Expand Down
9 changes: 0 additions & 9 deletions templates/foo.conf.j2

This file was deleted.

Loading

0 comments on commit 5c653f2

Please sign in to comment.