Skip to content

Commit d679f16

Browse files
L-ChamsAlex-Welsh
authored andcommitted
Add support for fail2ban in Kayobe
Adds support for installing and configuring fail2ban in Kayobe using the robertdebock.fail2ban Ansible role https://galaxy.ansible.com/ui/standalone/roles/robertdebock/fail2ban/ Change-Id: Ic484b2c4f6e261a5173ba8f5378258068f468fa2 Signed-off-by: Leonie Chamberlin-Medd <leonie@stackhpc.com>
1 parent fd57c5e commit d679f16

36 files changed

Lines changed: 417 additions & 0 deletions

ansible/control-host-configure.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
- import_playbook: "selinux.yml"
1414
- import_playbook: "network.yml"
1515
- import_playbook: "firewall.yml"
16+
- import_playbook: "fail2ban.yml"
1617
- import_playbook: "tuned.yml"
1718
- import_playbook: "sysctl.yml"
1819
- import_playbook: "time.yml"

ansible/fail2ban.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
---
2+
- name: Configure fail2ban
3+
hosts: seed:seed-hypervisor:overcloud:infra-vms:ansible-control
4+
max_fail_percentage: >-
5+
{{ fail2ban_max_fail_percentage |
6+
default(host_configure_max_fail_percentage) |
7+
default(kayobe_max_fail_percentage) |
8+
default(100) }}
9+
tags:
10+
- fail2ban
11+
roles:
12+
- role: robertdebock.fail2ban
13+
become: true
14+
when: fail2ban_enabled | bool
15+
vars:
16+
# TODO (L-Chams): Remove fail2ban_sender override when PR https://github.com/robertdebock/ansible-role-fail2ban/pull/18 is merged.
17+
fail2ban_sender: root@{{ ansible_facts.fqdn }}

ansible/infra-vm-host-configure.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
- import_playbook: "selinux.yml"
1414
- import_playbook: "network.yml"
1515
- import_playbook: "firewall.yml"
16+
- import_playbook: "fail2ban.yml"
1617
- import_playbook: "tuned.yml"
1718
- import_playbook: "sysctl.yml"
1819
- import_playbook: "disable-glean.yml"

ansible/inventory/group_vars/all/ansible-control

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,26 @@ ansible_control_firewalld_default_zone:
126126
# - state: enabled
127127
ansible_control_firewalld_rules: []
128128

129+
###############################################################################
130+
# Ansible control host fail2ban configuration.
131+
132+
# Whether to install and enable fail2ban. Default is false.
133+
ansible_control_fail2ban_enabled: false
134+
135+
# List of fail2ban jails for the Ansible control host.
136+
ansible_control_fail2ban_jail_configuration: >-
137+
{{ ansible_control_fail2ban_jail_configuration_default +
138+
ansible_control_fail2ban_jail_configuration_extra }}
139+
140+
# List of default fail2ban jails for the Ansible control host.
141+
ansible_control_fail2ban_jail_configuration_default:
142+
- option: enabled
143+
value: "true"
144+
section: sshd
145+
146+
# List of extra fail2ban jails for the Ansible control host.
147+
ansible_control_fail2ban_jail_configuration_extra: []
148+
129149
###############################################################################
130150
# Ansible control host swap configuration.
131151

ansible/inventory/group_vars/all/compute

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,26 @@ compute_firewalld_default_zone:
185185
# - state: enabled
186186
compute_firewalld_rules: []
187187

188+
###############################################################################
189+
# Compute node fail2ban configuration.
190+
191+
# Whether to install and enable fail2ban.
192+
compute_fail2ban_enabled: false
193+
194+
# List of fail2ban jails for the compute node.
195+
compute_fail2ban_jail_configuration: >-
196+
{{ compute_fail2ban_jail_configuration_default +
197+
compute_fail2ban_jail_configuration_extra }}
198+
199+
# List of default fail2ban jails for the compute node.
200+
compute_fail2ban_jail_configuration_default:
201+
- option: enabled
202+
value: "true"
203+
section: sshd
204+
205+
# List of extra fail2ban jails for the compute node.
206+
compute_fail2ban_jail_configuration_extra: []
207+
188208
###############################################################################
189209
# Compute node host libvirt configuration.
190210

ansible/inventory/group_vars/all/controllers

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,26 @@ controller_firewalld_default_zone:
224224
# - state: enabled
225225
controller_firewalld_rules: []
226226

227+
###############################################################################
228+
# Controller node fail2ban configuration.
229+
230+
# Whether to install and enable fail2ban.
231+
controller_fail2ban_enabled: false
232+
233+
# List of fail2ban jails for the controller node.
234+
controller_fail2ban_jail_configuration: >-
235+
{{ controller_fail2ban_jail_configuration_default +
236+
controller_fail2ban_jail_configuration_extra }}
237+
238+
# List of default fail2ban jails for the controller node.
239+
controller_fail2ban_jail_configuration_default:
240+
- option: enabled
241+
value: "true"
242+
section: sshd
243+
244+
# List of extra fail2ban jails for the controller node.
245+
controller_fail2ban_jail_configuration_extra: []
246+
227247
###############################################################################
228248
# Controller node swap configuration.
229249

ansible/inventory/group_vars/all/infra-vms

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,26 @@ infra_vm_firewalld_default_zone:
230230
# - state: enabled
231231
infra_vm_firewalld_rules: []
232232

233+
###############################################################################
234+
# Infrastructure VM node fail2ban configuration.
235+
236+
# Whether to install and enable fail2ban.
237+
infra_vm_fail2ban_enabled: false
238+
239+
# List of fail2ban jails for the infrastructure VM node.
240+
infra_vm_fail2ban_jail_configuration: >-
241+
{{ infra_vm_fail2ban_jail_configuration_default +
242+
infra_vm_fail2ban_jail_configuration_extra }}
243+
244+
# List of default fail2ban jails for the infrastructure VM node.
245+
infra_vm_fail2ban_jail_configuration_default:
246+
- option: enabled
247+
value: "true"
248+
section: sshd
249+
250+
# List of extra fail2ban jails for the infrastructure VM node.
251+
infra_vm_fail2ban_jail_configuration_extra: []
252+
233253
###############################################################################
234254
# Infrastructure VM node swap configuration.
235255

ansible/inventory/group_vars/all/monitoring

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,26 @@ monitoring_firewalld_default_zone: "{{ controller_firewalld_default_zone }}"
124124
# - state: enabled
125125
monitoring_firewalld_rules: "{{ controller_firewalld_rules }}"
126126

127+
###############################################################################
128+
# Monitoring node fail2ban configuration.
129+
130+
# Whether to install and enable fail2ban.
131+
monitoring_fail2ban_enabled: false
132+
133+
# List of fail2ban jails for the monitoring node.
134+
monitoring_fail2ban_jail_configuration: >-
135+
{{ monitoring_fail2ban_jail_configuration_default +
136+
monitoring_fail2ban_jail_configuration_extra }}
137+
138+
# List of default fail2ban jails for the monitoring node.
139+
monitoring_fail2ban_jail_configuration_default:
140+
- option: enabled
141+
value: "true"
142+
section: sshd
143+
144+
# List of extra fail2ban jails for the monitoring node.
145+
monitoring_fail2ban_jail_configuration_extra: []
146+
127147
###############################################################################
128148
# Monitoring node swap configuration.
129149

ansible/inventory/group_vars/all/seed

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,26 @@ seed_firewalld_default_zone:
169169
# - state: enabled
170170
seed_firewalld_rules: []
171171

172+
###############################################################################
173+
# Seed node fail2ban configuration.
174+
175+
# Whether to install and enable fail2ban.
176+
seed_fail2ban_enabled: false
177+
178+
# List of fail2ban jails for the seed node.
179+
seed_fail2ban_jail_configuration: >-
180+
{{ seed_fail2ban_jail_configuration_default +
181+
seed_fail2ban_jail_configuration_extra }}
182+
183+
# List of default fail2ban jails for the seed node.
184+
seed_fail2ban_jail_configuration_default:
185+
- option: enabled
186+
value: "true"
187+
section: sshd
188+
189+
# List of extra fail2ban jails for the seed node.
190+
seed_fail2ban_jail_configuration_extra: []
191+
172192
###############################################################################
173193
# Seed node swap configuration.
174194

ansible/inventory/group_vars/all/seed-hypervisor

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,26 @@ seed_hypervisor_firewalld_default_zone:
162162
# - state: enabled
163163
seed_hypervisor_firewalld_rules: []
164164

165+
###############################################################################
166+
# Seed hypervisor node fail2ban configuration.
167+
168+
# Whether to install and enable fail2ban.
169+
seed_hypervisor_fail2ban_enabled: false
170+
171+
# List of fail2ban jails for the seed hypervisor node.
172+
seed_hypervisor_fail2ban_jail_configuration: >-
173+
{{ seed_hypervisor_fail2ban_jail_configuration_default +
174+
seed_hypervisor_fail2ban_jail_configuration_extra }}
175+
176+
# List of default fail2ban jails for the seed hypervisor node.
177+
seed_hypervisor_fail2ban_jail_configuration_default:
178+
- option: enabled
179+
value: "true"
180+
section: sshd
181+
182+
# List of extra fail2ban jails for the seed hypervisor node.
183+
seed_hypervisor_fail2ban_jail_configuration_extra: []
184+
165185
###############################################################################
166186
# Seed hypervisor node swap configuration.
167187

0 commit comments

Comments
 (0)