update task on main playbook

This commit is contained in:
Ruben Blanco 2023-10-18 14:24:17 +02:00
parent 9b2321d781
commit 69a6a4f548
2 changed files with 18 additions and 6 deletions

View File

@ -3,7 +3,7 @@
- hosts: "{{ ip_addr }}"
become: yes
become_method: sudo
gather_facts: no
gather_facts: yes
tasks:

View File

@ -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
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 "