diff --git a/README.md b/README.md index 34d064c..c1b432c 100644 --- a/README.md +++ b/README.md @@ -33,6 +33,10 @@ None - `fail2ban_filterd_path`: [optional]: Path to directory containing filters to copy (**note the trailing slash**) - `fail2ban_actiond_path`: [optional]: Path to directory containing actions to copy (**note the trailing slash**) - `fail2ban_jaild_path`: [optional]: Path to directory containing jails to copy (**note the trailing slash**) +- `fail2ban_filterd_templates`: [optional]: List of template file names (without extension ".j2"). The files should be in the directory: templates/fail2ban/etc/fail2ban/filter.d/ +- `fail2ban_actiond_templates`: [optional]: List of template file names (without extension ".j2"). The files should be in the directory: templates/fail2ban/etc/fail2ban/action.d/ +- `fail2ban_jaild_templates`: [optional]: List of template file names (without extension ".j2"). The files should be in the directory: templates/fail2ban/etc/fail2ban/jail.d/ + - `fail2ban_services` [default see `defaults/main.yml`]: Service definitions - `fail2ban_services.{n}.name` [required]: Service name (e.g. `ssh`) diff --git a/tasks/main.yml b/tasks/main.yml index 8e6af84..665e9a8 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -79,6 +79,51 @@ - fail2ban - fail2ban-jails +- name: generate filters + template: + src: "fail2ban/etc/fail2ban/filter.d/{{ item }}.j2" + dest: /etc/fail2ban/filter.d/{{ item }} + owner: root + group: root + mode: 0644 + when: fail2ban_filterd_templates is defined + with_list: "{{ fail2ban_filterd_templates }}" + notify: restart fail2ban + tags: + - configuration + - fail2ban + - fail2ban-filters + +- name: generate actions + template: + src: "fail2ban/etc/fail2ban/action.d/{{ item }}.j2" + dest: /etc/fail2ban/action.d/{{ item }} + owner: root + group: root + mode: 0644 + when: fail2ban_actiond_templates is defined + with_list: "{{ fail2ban_actiond_templates }}" + notify: restart fail2ban + tags: + - configuration + - fail2ban + - fail2ban-actions + +- name: generate jails + template: + src: "fail2ban/etc/fail2ban/jail.d/{{ item }}.j2" + dest: /etc/fail2ban/jail.d/{{ item }} + owner: root + group: root + mode: 0644 + when: fail2ban_jaild_templates is defined + with_list: "{{ fail2ban_jaild_templates }}" + notify: restart fail2ban + tags: + - configuration + - fail2ban + - fail2ban-jails + - name: start and enable service service: name: fail2ban