From 552747dda96b2b2fd73e4d52f0686aae4719ceab Mon Sep 17 00:00:00 2001 From: firesoft-de <34716031+firesoft-de@users.noreply.github.com> Date: Mon, 12 Apr 2021 12:29:42 +0200 Subject: [PATCH 1/5] Added package_facts to determine if fail2ban is installed --- tasks/main.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tasks/main.yml b/tasks/main.yml index e0c49ba..69b10a2 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -2,6 +2,10 @@ - name: perform optional versionscheck ansible.builtin.include_tasks: versioncheck.yml when: submodules_versioncheck|bool + +- name: Gather installed packages for checks later on + ansible.builtin.package_facts: + manager: auto - name: Gather variables for each operating system ansible.builtin.include_vars: "{{ lookup('first_found', gitea_variables) }}" From 18bb3f9c445d7c389477e3ee8c731ca1b77f8ade Mon Sep 17 00:00:00 2001 From: firesoft-de <34716031+firesoft-de@users.noreply.github.com> Date: Mon, 12 Apr 2021 12:30:52 +0200 Subject: [PATCH 2/5] Added condition to only configure fail2ban if it is installed --- tasks/fail2ban.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tasks/fail2ban.yml b/tasks/fail2ban.yml index 640b754..cdc03ab 100644 --- a/tasks/fail2ban.yml +++ b/tasks/fail2ban.yml @@ -8,6 +8,7 @@ group: root mode: 0444 notify: systemctl restart fail2ban + when: 'fail2ban' in ansible_facts.packages - name: Install fail2ban jail become: true @@ -18,3 +19,4 @@ group: root mode: 0444 notify: systemctl restart fail2ban + when: 'fail2ban' in ansible_facts.packages From 664c894e17bec42497ae40706ecea7dad87d2e5f Mon Sep 17 00:00:00 2001 From: firesoft-de <34716031+firesoft-de@users.noreply.github.com> Date: Mon, 12 Apr 2021 12:39:11 +0200 Subject: [PATCH 3/5] Fixed missing quotes --- tasks/fail2ban.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tasks/fail2ban.yml b/tasks/fail2ban.yml index cdc03ab..d1bce60 100644 --- a/tasks/fail2ban.yml +++ b/tasks/fail2ban.yml @@ -8,7 +8,7 @@ group: root mode: 0444 notify: systemctl restart fail2ban - when: 'fail2ban' in ansible_facts.packages + when: "'fail2ban' in ansible_facts.packages" - name: Install fail2ban jail become: true @@ -19,4 +19,4 @@ group: root mode: 0444 notify: systemctl restart fail2ban - when: 'fail2ban' in ansible_facts.packages + when: "'fail2ban' in ansible_facts.packages" From 391447a3451d2c9c68c3d65dc27880a49b790457 Mon Sep 17 00:00:00 2001 From: firesoft-de <34716031+firesoft-de@users.noreply.github.com> Date: Mon, 12 Apr 2021 16:01:24 +0200 Subject: [PATCH 4/5] removed trailing spaces --- tasks/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tasks/main.yml b/tasks/main.yml index 69b10a2..461d49d 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -2,7 +2,7 @@ - name: perform optional versionscheck ansible.builtin.include_tasks: versioncheck.yml when: submodules_versioncheck|bool - + - name: Gather installed packages for checks later on ansible.builtin.package_facts: manager: auto From 2ca88c2711a940badfdf548e7206e91b16a13871 Mon Sep 17 00:00:00 2001 From: L3D Date: Mon, 12 Apr 2021 16:56:48 +0200 Subject: [PATCH 5/5] add message to warn the user + Added a message that will warn the user that fail2ban is not installed. + Increased the version integer for the simple versionscheck. --- tasks/fail2ban.yml | 6 ++++++ vars/main.yml | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/tasks/fail2ban.yml b/tasks/fail2ban.yml index d1bce60..913127d 100644 --- a/tasks/fail2ban.yml +++ b/tasks/fail2ban.yml @@ -20,3 +20,9 @@ mode: 0444 notify: systemctl 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/vars/main.yml b/vars/main.yml index 1cdd648..c38f978 100644 --- a/vars/main.yml +++ b/vars/main.yml @@ -20,5 +20,5 @@ gitea_variables: paths: - 'vars' -playbook_version_number: 8 # should be int +playbook_version_number: 9 # should be int playbook_version_path: 'do1jlr.gitea.version'