diff --git a/tasks/fail2ban.yml b/tasks/fail2ban.yml index 5825cfb..ce7025c 100644 --- a/tasks/fail2ban.yml +++ b/tasks/fail2ban.yml @@ -7,6 +7,7 @@ group: root mode: 0444 notify: Restart fail2ban + when: "'fail2ban' in ansible_facts.packages" - name: Install fail2ban jail ansible.builtin.template: @@ -16,3 +17,10 @@ group: root mode: 0444 notify: Restart fail2ban + when: "'fail2ban' in ansible_facts.packages" + +- name: warn if fail2ban is not installed + ansible.builtin.fail: + msg: "the package fail2ban is not installed. no fail2ban filters deployed." + when: "'fail2ban' not in ansible_facts.packages" + ignore_errors: true diff --git a/tasks/main.yml b/tasks/main.yml index e03371c..0a698da 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -8,6 +8,10 @@ - "{{ ansible_distribution | lower }}.yml" - "{{ ansible_os_family | lower }}.yml" +- name: Gather installed packages for checks in the role (fail2ban) + ansible.builtin.package_facts: + manager: auto + - name: "Check gitea version" ansible.builtin.shell: "set -eo pipefail; /usr/local/bin/gitea -v | cut -d' ' -f 3" args: