29 lines
874 B
YAML
29 lines
874 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
|
|
|
|
# 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: "not packages.stdout.find('fail2ban')"
|
|
|
|
# config fail2ban if is there is in the system
|
|
#- name: config fail2ban
|
|
# x:
|
|
# x
|
|
# x
|
|
# when: "{{ ansible_facts.packages['fail2ban'] }} is defined " |