Unverified Commit 7be16e4f authored by Dmitriy Safronov's avatar Dmitriy Safronov Committed by GitHub
Browse files

D (#2)

parent 5fae74d0
Loading
Loading
Loading
Loading

defaults/main.yml

deleted100644 → 0
+0 −5
Original line number Diff line number Diff line
fail2ban_fail2ban_local: |
  loglevel = INFO

fail2ban_jail_local: |
  bantime.rndtime = 300
+1 −1
Original line number Diff line number Diff line
- name: Restart fail2ban service
- name: (Re)start fail2ban service
  ansible.builtin.systemd:
    state: restarted
    enabled: true

tasks/fail2ban_d.yml

0 → 100644
+23 −0
Original line number Diff line number Diff line
---

- name: Fail on spaces in fail2ban fail2ban_d config names
  ansible.builtin.assert:
    that:
      - "' ' not in item.key"
  with_dict: "{{ fail2ban.fail2ban_d }}"
  no_log: true

- name: Create /etc/fail2ban/fail2ban.d files
  when:
    - item.value is defined
    - item.value != None
    - item.value | length > 0
  with_dict: "{{ fail2ban.fail2ban_d }}"
  ansible.builtin.template:
    src: fail2ban.d.j2
    dest: "/etc/fail2ban/fail2ban.d/{{ item.key }}.conf"
    mode: "0600"
    owner: root
    group: root
  no_log: true
  notify: (Re)start fail2ban service

tasks/jail_d.yml

0 → 100644
+23 −0
Original line number Diff line number Diff line
---

- name: Fail on spaces in fail2ban jail_d config names
  ansible.builtin.assert:
    that:
      - "' ' not in item.key"
  with_dict: "{{ fail2ban.jail_d }}"
  no_log: true

- name: Create /etc/fail2ban/jail.d files
  when:
    - item.value is defined
    - item.value != None
    - item.value | length > 0
  with_dict: "{{ fail2ban.jail_d }}"
  ansible.builtin.template:
    src: fail2ban.d.j2
    dest: "/etc/fail2ban/jail.d/{{ item.key }}.conf"
    mode: "0600"
    owner: root
    group: root
  no_log: true
  notify: (Re)start fail2ban service
+17 −5
Original line number Diff line number Diff line
@@ -2,7 +2,7 @@
  ansible.builtin.package:
    name: fail2ban
    state: present
  notify: Restart fail2ban service
  notify: (Re)start fail2ban service

- name: Template a file to /etc/fail2ban/fail2ban.local
  ansible.builtin.template:
@@ -11,8 +11,7 @@
    owner: root
    group: root
    mode: "0644"
  when: fail2ban_fail2ban_local is defined
  notify: Restart fail2ban service
  notify: (Re)start fail2ban service

- name: Template a file to /etc/fail2ban/jail.local
  ansible.builtin.template:
@@ -21,5 +20,18 @@
    owner: root
    group: root
    mode: "0644"
  when: fail2ban_jail_local is defined
  notify: Restart fail2ban service
  notify: (Re)start fail2ban service

- name: Configure /etc/fail2ban/fail2ban.d
  when:
    - fail2ban.fail2ban_d is defined
    - fail2ban.fail2ban_d != None
  ansible.builtin.include_tasks:
    file: fail2ban_d.yml

- name: Configure /etc/fail2ban/jail.d
  when:
    - fail2ban.jail_d is defined
    - fail2ban.jail_d != None
  ansible.builtin.include_tasks:
    file: jail_d.yml
Loading