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