32 lines
991 B
YAML
32 lines
991 B
YAML
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
|
# Install and configure FAIL2BAN
|
|
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
|
|
|
# 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
|
|
register: packages.stdout.find('fail2ban')
|
|
# register: packages
|
|
|
|
# print the package facts in var
|
|
#- name: print the package facts in var
|
|
# ansible.builtin.debug:
|
|
# var: ansible_facts.packages
|
|
|
|
# install packages if is not in the system
|
|
- name: install fail2ban package if is not in the system
|
|
apt:
|
|
name: fail2ban
|
|
state: present
|
|
# when: packages.stdout.find('fail2ban') == ""
|
|
# when: "{{ packages['fail2ban'] | length }}"
|
|
when: packages == -1
|
|
|
|
# config fail2ban if is there is in the system
|
|
#- name: config fail2ban
|
|
# x:
|
|
# x
|
|
# x
|
|
# when: "{{ ansible_facts.packages['fail2ban'] }} is defined " |