Skip to content

Commit 08251f2

Browse files
committed
Merge branch 'main' into feature/offboard-state
2 parents 596eb14 + e767f5d commit 08251f2

File tree

23 files changed

+400
-5
lines changed

23 files changed

+400
-5
lines changed

ansible/.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ roles/*
1414
!roles/grafana-datasources/**
1515
!roles/passwords/
1616
!roles/passwords/**
17+
!roles/fail2ban/
18+
!roles/fail2ban/**
1719
!roles/hpctests/
1820
!roles/hpctests/**
1921
!roles/block_devices/
@@ -22,3 +24,5 @@ roles/*
2224
!roles/basic_users/**
2325
!roles/openondemand/
2426
!roles/openondemand/**
27+
!roles/firewalld/
28+
!roles/firewalld/**

ansible/bootstrap.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,22 @@
3636
policy: "{{ selinux_policy }}"
3737
register: sestatus
3838

39+
- hosts: firewalld
40+
gather_facts: false
41+
become: yes
42+
tags: firewalld
43+
tasks:
44+
- import_role:
45+
name: firewalld
46+
47+
- hosts: fail2ban
48+
gather_facts: false
49+
become: yes
50+
tags: fail2ban
51+
tasks:
52+
- import_role:
53+
name: fail2ban
54+
3955
- hosts: update
4056
gather_facts: false
4157
become: yes

ansible/roles/fail2ban/.travis.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
---
2+
language: python
3+
python: "2.7"
4+
5+
# Use the new container infrastructure
6+
sudo: false
7+
8+
# Install ansible
9+
addons:
10+
apt:
11+
packages:
12+
- python-pip
13+
14+
install:
15+
# Install ansible
16+
- pip install ansible
17+
18+
# Check ansible version
19+
- ansible --version
20+
21+
# Create ansible.cfg with correct roles_path
22+
- printf '[defaults]\nroles_path=../' >ansible.cfg
23+
24+
script:
25+
# Basic role syntax check
26+
- ansible-playbook tests/test.yml -i tests/inventory --syntax-check
27+
28+
notifications:
29+
webhooks: https://galaxy.ansible.com/api/v1/notifications/

ansible/roles/fail2ban/README.md

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
fail2ban
2+
=========
3+
4+
Setup fail2ban to protect SSH on a host.
5+
6+
Note that no email alerts are set up so logs (at `/var/log/fail2ban.log`) will have to be manually reviewed if required.
7+
8+
Requirements
9+
------------
10+
11+
- An EL8 system.
12+
- `firewalld` running.
13+
14+
Role Variables
15+
--------------
16+
None.
17+
18+
Dependencies
19+
------------
20+
21+
None.
22+
23+
Example Playbook
24+
----------------
25+
26+
```yaml
27+
- hosts: fail2ban
28+
gather_facts: false
29+
become: yes
30+
tasks:
31+
- import_role:
32+
name: firewalld
33+
- import_role:
34+
name: fail2ban
35+
```
36+
37+
License
38+
-------
39+
40+
Apache v2
41+
42+
Author Information
43+
------------------
44+
45+
stackhpc.com
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
3+
- name: Restart fail2ban
4+
service:
5+
name: fail2ban
6+
state: restarted
7+
enabled: true

ansible/roles/fail2ban/meta/main.yml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
galaxy_info:
2+
author: Steve Brasier
3+
company: stackhpc
4+
5+
# If the issue tracker for your role is not on github, uncomment the
6+
# next line and provide a value
7+
# issue_tracker_url: http://example.com/issue/tracker
8+
9+
# Choose a valid license ID from https://spdx.org - some suggested licenses:
10+
# - BSD-3-Clause (default)
11+
# - MIT
12+
# - GPL-2.0-or-later
13+
# - GPL-3.0-only
14+
# - Apache-2.0
15+
# - CC-BY-4.0
16+
license: Apache-2.0
17+
18+
min_ansible_version: 2.1
19+
20+
# If this a Container Enabled role, provide the minimum Ansible Container version.
21+
# min_ansible_container_version:
22+
23+
#
24+
# Provide a list of supported platforms, and for each platform a list of versions.
25+
# If you don't wish to enumerate all versions for a particular platform, use 'all'.
26+
# To view available platforms and versions (or releases), visit:
27+
# https://galaxy.ansible.com/api/v1/platforms/
28+
#
29+
platforms:
30+
- name: EL
31+
versions:
32+
- 8
33+
34+
galaxy_tags: []
35+
# List tags for your role here, one per line. A tag is a keyword that describes
36+
# and categorizes the role. Users find roles by searching for tags. Be sure to
37+
# remove the '[]' above, if you add tags to this list.
38+
#
39+
# NOTE: A tag is limited to a single word comprised of alphanumeric characters.
40+
# Maximum 20 tags per role.
41+
42+
dependencies: []
43+
# List your role dependencies here, one per line. Be sure to remove the '[]' above,
44+
# if you add dependencies to this list.

ansible/roles/fail2ban/tasks/main.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
---
2+
- name: Install EPEL repo
3+
package:
4+
name: epel-release
5+
6+
- name: Install fail2ban packages
7+
package:
8+
name:
9+
- fail2ban-server
10+
- fail2ban-firewalld
11+
state: present
12+
13+
- name: Create config
14+
template:
15+
dest: /etc/fail2ban/jail.local
16+
src: jail.local.j2
17+
notify: Restart fail2ban
18+
19+
- name: flush handlers
20+
meta: flush_handlers
21+
22+
- name: Ensure fail2ban running even if no config change
23+
service:
24+
name: fail2ban
25+
state: started
26+
enabled: true
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
[DEFAULT]
2+
bantime = 3600
3+
action = %(action_)s
4+
5+
[sshd]
6+
enabled = true

ansible/roles/firewalld/.travis.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
---
2+
language: python
3+
python: "2.7"
4+
5+
# Use the new container infrastructure
6+
sudo: false
7+
8+
# Install ansible
9+
addons:
10+
apt:
11+
packages:
12+
- python-pip
13+
14+
install:
15+
# Install ansible
16+
- pip install ansible
17+
18+
# Check ansible version
19+
- ansible --version
20+
21+
# Create ansible.cfg with correct roles_path
22+
- printf '[defaults]\nroles_path=../' >ansible.cfg
23+
24+
script:
25+
# Basic role syntax check
26+
- ansible-playbook tests/test.yml -i tests/inventory --syntax-check
27+
28+
notifications:
29+
webhooks: https://galaxy.ansible.com/api/v1/notifications/

ansible/roles/firewalld/README.md

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
Role Name
2+
=========
3+
4+
Install and configure the `firewalld` firewall.
5+
6+
Requirements
7+
------------
8+
9+
EL8 host
10+
11+
Role Variables
12+
--------------
13+
14+
- `firewalld_enabled`: Optional. Whether `firewalld` service is enabled (starts at boot). Default `yes`.
15+
- `firewalld_state`: Optional. State of `firewalld` service. Default `started`. Other values: `stopped`.
16+
- `firewalld_configs`: Optional. List of dicts giving parameters for [ansible.posix.firewalld module](https://docs.ansible.com/ansible/latest/collections/ansible/posix/firewalld_module.html). Default is an empty list.
17+
18+
Note that the default configuration for firewalld on Rocky Linux 8.5 is as follows:
19+
```shell
20+
# firewall-offline-cmd --list-all
21+
public
22+
target: default
23+
icmp-block-inversion: no
24+
interfaces:
25+
sources:
26+
services: cockpit dhcpv6-client ssh
27+
ports:
28+
protocols:
29+
forward: no
30+
masquerade: no
31+
forward-ports:
32+
source-ports:
33+
icmp-blocks:
34+
rich rules:
35+
```
36+
37+
Dependencies
38+
------------
39+
40+
None.
41+
42+
Example Playbook
43+
----------------
44+
45+
```
46+
- hosts: firewalld
47+
gather_facts: false
48+
become: yes
49+
tags: firewalld
50+
tasks:
51+
- import_role:
52+
name: firewalld
53+
```
54+
55+
License
56+
-------
57+
58+
BSD
59+
60+
Author Information
61+
------------------
62+
63+
An optional section for the role authors to include contact information, or a website (HTML is not allowed).
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
firewalld_enabled: yes
2+
firewalld_state: started
3+
firewalld_configs: []
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
- name: Restart filewalld
3+
service:
4+
name: firewalld
5+
state: restarted
6+
when: "{{ firewalld_state != 'stopped' }}"

ansible/roles/firewalld/meta/main.yml

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
galaxy_info:
2+
author: your name
3+
description: your role description
4+
company: your company (optional)
5+
6+
# If the issue tracker for your role is not on github, uncomment the
7+
# next line and provide a value
8+
# issue_tracker_url: http://example.com/issue/tracker
9+
10+
# Choose a valid license ID from https://spdx.org - some suggested licenses:
11+
# - BSD-3-Clause (default)
12+
# - MIT
13+
# - GPL-2.0-or-later
14+
# - GPL-3.0-only
15+
# - Apache-2.0
16+
# - CC-BY-4.0
17+
license: license (GPL-2.0-or-later, MIT, etc)
18+
19+
min_ansible_version: 2.1
20+
21+
# If this a Container Enabled role, provide the minimum Ansible Container version.
22+
# min_ansible_container_version:
23+
24+
#
25+
# Provide a list of supported platforms, and for each platform a list of versions.
26+
# If you don't wish to enumerate all versions for a particular platform, use 'all'.
27+
# To view available platforms and versions (or releases), visit:
28+
# https://galaxy.ansible.com/api/v1/platforms/
29+
#
30+
# platforms:
31+
# - name: Fedora
32+
# versions:
33+
# - all
34+
# - 25
35+
# - name: SomePlatform
36+
# versions:
37+
# - all
38+
# - 1.0
39+
# - 7
40+
# - 99.99
41+
42+
galaxy_tags: []
43+
# List tags for your role here, one per line. A tag is a keyword that describes
44+
# and categorizes the role. Users find roles by searching for tags. Be sure to
45+
# remove the '[]' above, if you add tags to this list.
46+
#
47+
# NOTE: A tag is limited to a single word comprised of alphanumeric characters.
48+
# Maximum 20 tags per role.
49+
50+
dependencies: []
51+
# List your role dependencies here, one per line. Be sure to remove the '[]' above,
52+
# if you add dependencies to this list.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
- name: Install firewalld package
2+
dnf:
3+
name: firewalld
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
---
2+
- import_tasks: install.yml
3+
4+
- name: Apply filewalld configs
5+
ansible.posix.firewalld: "{{ item }}"
6+
notify: Restart filewalld
7+
loop: "{{ firewalld_configs }}"
8+
9+
- meta: flush_handlers
10+
11+
- name: Ensure filewalld state
12+
ansible.builtin.systemd:
13+
name: firewalld
14+
state: "{{ firewalld_state }}"
15+
enabled: "{{ firewalld_enabled | default('yes' ) }}"

ansible/roles/firewalld/vars/main.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
---
2+
# vars file for firewalld

0 commit comments

Comments
 (0)