Skip to content
Snippets Groups Projects
Verified Commit b2465976 authored by Chris Croome's avatar Chris Croome
Browse files

test using community.general.to_ini filter

parent 9e3efadb
No related branches found
No related tags found
No related merge requests found
Pipeline #35738 failed
...@@ -11,5 +11,6 @@ ...@@ -11,5 +11,6 @@
# https://docs.ansible.com/ansible-lint/rules/default_rules.html # https://docs.ansible.com/ansible-lint/rules/default_rules.html
skip_list: skip_list:
- key-order[task] - key-order[task]
var_naming_pattern: "^[fail2ban|molecule]_?[a-z0-9_]*$"
# vim: syntax=yaml # vim: syntax=yaml
... ...
...@@ -9,13 +9,19 @@ ...@@ -9,13 +9,19 @@
# You should have received a copy of the GNU General Public License along with the Webarchitects Fail2ban Ansible role. If not, see <https://www.gnu.org/licenses/>. # You should have received a copy of the GNU General Public License along with the Webarchitects Fail2ban Ansible role. If not, see <https://www.gnu.org/licenses/>.
--- ---
variables: variables:
ANSIBLE_ANY_ERRORS_FATAL: "1"
ANSIBLE_CALLBACK_RESULT_FORMAT: "yaml" ANSIBLE_CALLBACK_RESULT_FORMAT: "yaml"
ANSIBLE_DIFF_ALWAYS: "1"
ANSIBLE_DISPLAY_SKIPPED_HOSTS: "0" ANSIBLE_DISPLAY_SKIPPED_HOSTS: "0"
ANSIBLE_ERROR_ON_UNDEFINED_VARS: "1"
ANSIBLE_FORCE_COLOR: "1" ANSIBLE_FORCE_COLOR: "1"
ANSIBLE_INJECT_FACT_VARS: "0" ANSIBLE_INJECT_FACT_VARS: "0"
ANSIBLE_REMOTE_TMP: "/tmp" ANSIBLE_REMOTE_TMP: "/tmp"
ANSIBLE_SHELL_ALLOW_WORLD_READABLE_TEMP: "1" ANSIBLE_SHELL_ALLOW_WORLD_READABLE_TEMP: "1"
DEBIAN_FRONTEND: noninteractive
DEFAULT_MANAGED_STR: "Ansible managed"
MOLECULE_VERBOSITY: "0" MOLECULE_VERBOSITY: "0"
PRE_COMMIT_COLOR: always
PY_COLORS: "1" PY_COLORS: "1"
before_script: before_script:
- whoami - whoami
...@@ -30,26 +36,26 @@ before_script: ...@@ -30,26 +36,26 @@ before_script:
- touch /var/log/auth.log - touch /var/log/auth.log
stages: stages:
- bookworm - bookworm
# - bullseye
- jammy - jammy
- noble
- trixie - trixie
bookworm: bookworm:
image: registry.git.coop/webarch/containers/images/bookworm:20240911 image: registry.git.coop/webarch/containers/images/bookworm:20241107
stage: bookworm stage: bookworm
script: script:
- molecule test - molecule test
# bullseye:
# image: registry.git.coop/webarch/containers/images/bullseye:20240911
# stage: bullseye
# script:
# - molecule test
jammy: jammy:
image: registry.git.coop/webarch/containers/images/jammy:20240911 image: registry.git.coop/webarch/containers/images/jammy:20241107
stage: jammy stage: jammy
script: script:
- molecule test - molecule test
noble:
image: registry.git.coop/webarch/containers/images/noble:20241107
stage: bullseye
script:
- molecule test
trixie: trixie:
image: registry.git.coop/webarch/containers/images/trixie:20240911 image: registry.git.coop/webarch/containers/images/trixie:20241107
stage: trixie stage: trixie
script: script:
- molecule test - molecule test
......
...@@ -25,7 +25,7 @@ repos: ...@@ -25,7 +25,7 @@ repos:
- templates - templates
# https://github.com/jackdewinter/pymarkdown/releases # https://github.com/jackdewinter/pymarkdown/releases
- repo: https://github.com/jackdewinter/pymarkdown.git - repo: https://github.com/jackdewinter/pymarkdown.git
rev: v0.9.23 rev: v0.9.25
hooks: hooks:
- id: pymarkdown - id: pymarkdown
name: Markdown Lint name: Markdown Lint
...@@ -34,7 +34,7 @@ repos: ...@@ -34,7 +34,7 @@ repos:
- README.md - README.md
# https://github.com/ansible/ansible-lint/releases # https://github.com/ansible/ansible-lint/releases
- repo: https://github.com/ansible/ansible-lint.git - repo: https://github.com/ansible/ansible-lint.git
rev: v24.9.2 rev: v24.10.0
hooks: hooks:
- id: ansible-lint - id: ansible-lint
name: Ansible Lint name: Ansible Lint
......
...@@ -21,5 +21,10 @@ rules: ...@@ -21,5 +21,10 @@ rules:
level: error level: error
line-length: disable line-length: disable
comments-indentation: disable comments-indentation: disable
comments:
min-spaces-from-content: 1
octal-values:
forbid-implicit-octal: true
forbid-explicit-octal: true
# vim: syntax=yaml # vim: syntax=yaml
... ...
...@@ -20,7 +20,7 @@ ...@@ -20,7 +20,7 @@
path: "{{ fail2ban_config_file.path }}" path: "{{ fail2ban_config_file.path }}"
register: fail2ban_config_file_path register: fail2ban_config_file_path
- name: Delete the file, creating a backup - name: Delete the file, creating a backup, when it is set to be absent
ansible.builtin.command: "mv {{ fail2ban_config_file.path }} {{ fail2ban_config_file.path }}.{{ fail2ban_backup_extension }}" ansible.builtin.command: "mv {{ fail2ban_config_file.path }} {{ fail2ban_config_file.path }}.{{ fail2ban_backup_extension }}"
args: args:
creates: "{{ fail2ban_config_file.path }}.{{ fail2ban_backup_extension }}" creates: "{{ fail2ban_config_file.path }}.{{ fail2ban_backup_extension }}"
...@@ -59,6 +59,18 @@ ...@@ -59,6 +59,18 @@
- name: Create or edit the file - name: Create or edit the file
block: block:
# The config files can be templated if cases sensitivity in booloans is not an issue?
# https://github.com/fail2ban/fail2ban/discussions/3886
# - name: "Template the fail2ban config file at {{ fail2ban_config_file.path }}"
# ansible.builtin.template:
# src: fail2ban.conf.j2
# dest: "{{ fail2ban_config_file.path }}"
# mode: "0644"
# owner: root
# group: root
# validate: fail2ban-client -t
# notify: Restart fail2ban
- name: Include the file section edited tasks - name: Include the file section edited tasks
ansible.builtin.include_tasks: conf_file_section.yml ansible.builtin.include_tasks: conf_file_section.yml
loop: "{{ fail2ban_config_file.conf | dict2items }}" loop: "{{ fail2ban_config_file.conf | dict2items }}"
......
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
option: "{{ fail2ban_config_file_variable_pair.key }}" option: "{{ fail2ban_config_file_variable_pair.key }}"
value: "{% if fail2ban_config_file_variable_pair.value | type_debug == 'bool' %}{{ fail2ban_config_file_variable_pair.value | lower }}{% else %}{{ fail2ban_config_file_variable_pair.value }}{% endif %}" value: "{% if fail2ban_config_file_variable_pair.value | type_debug == 'bool' %}{{ fail2ban_config_file_variable_pair.value | lower }}{% else %}{{ fail2ban_config_file_variable_pair.value }}{% endif %}"
no_extra_spaces: false no_extra_spaces: false
mode: 0644 mode: "0644"
owner: root owner: root
group: root group: root
when: >- when: >-
......
# {{ ansible_managed }}
{% if fail2ban_config_file.name is defined and fail2ban_config_file.name | length > 0 %}
# {{ fail2ban_config_file.name }}
{% endif %}
{{ fail2ban_config_file.conf | community.general.to_ini }}
# {# vim: syntax=jinja2 #}vim: syntax=dosini
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment