vn-ansible/linux/base-config-debian/roles/config-fail2ban/tasks/main.yaml

32 lines
1.0 KiB
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: ansible_facts.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: "'fail2ban' in ansible_facts.packages is undefined"
# config fail2ban if is there is in the system
#- name: config fail2ban
# x:
# x
# x
# when: "{{ ansible_facts.packages['fail2ban'] }} is defined "