Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding fail2ban files generation based on templates. #55

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`)
Expand Down
45 changes: 45 additions & 0 deletions tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down