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 }}" - hosts: "{{ ip_addr }}"
become: yes become: yes
become_method: sudo become_method: sudo
gather_facts: no gather_facts: yes
tasks: tasks:

View File

@ -2,10 +2,22 @@
# Install and configure FAIL2BAN # Install and configure FAIL2BAN
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# install packages # comprobe if fail2ban is installed if not then install fail2ban
- name: install fail2ban package and config # 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: apt:
name: "{{ item }}" name: fail2ban
state: present state: present
with_items: when: "{{ ansible_facts.packages['fail2ban'] }} is not defined "
- fail2ban
# config fail2ban if is there is in the system
#- name: config fail2ban
# x:
# x
# x
# when: "{{ ansible_facts.packages['fail2ban'] }} is defined "