From 69a6a4f548f039acaa104024617d0603d24f85ae Mon Sep 17 00:00:00 2001 From: rubenb Date: Wed, 18 Oct 2023 14:24:17 +0200 Subject: [PATCH] update task on main playbook --- linux/base-config-debian/config-fail2ban.yaml | 2 +- .../roles/config-fail2ban/tasks/main.yaml | 22 ++++++++++++++----- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/linux/base-config-debian/config-fail2ban.yaml b/linux/base-config-debian/config-fail2ban.yaml index abcbf63..01852c6 100644 --- a/linux/base-config-debian/config-fail2ban.yaml +++ b/linux/base-config-debian/config-fail2ban.yaml @@ -3,7 +3,7 @@ - hosts: "{{ ip_addr }}" become: yes become_method: sudo - gather_facts: no + gather_facts: yes tasks: diff --git a/linux/base-config-debian/roles/config-fail2ban/tasks/main.yaml b/linux/base-config-debian/roles/config-fail2ban/tasks/main.yaml index d48bafc..cee2397 100644 --- a/linux/base-config-debian/roles/config-fail2ban/tasks/main.yaml +++ b/linux/base-config-debian/roles/config-fail2ban/tasks/main.yaml @@ -2,10 +2,22 @@ # Install and configure FAIL2BAN #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -# install packages -- name: install fail2ban package and config +# comprobe if fail2ban is installed if not then install fail2ban +# Gather the package facts +- name: Gather the package facts + ansible.builtin.package_facts: + manager: auto + +# install packages if is not in the system +- name: install fail2ban package if is not in the system apt: - name: "{{ item }}" + name: fail2ban state: present - with_items: - - fail2ban \ No newline at end of file + when: "{{ ansible_facts.packages['fail2ban'] }} is not defined " + +# config fail2ban if is there is in the system +#- name: config fail2ban +# x: +# x +# x +# when: "{{ ansible_facts.packages['fail2ban'] }} is defined " \ No newline at end of file