Skip to content

Commit ce52cf9

Browse files
CopilotShawnMcKee
andcommitted
Add minimal Ansible skeleton for perfSONAR testpoint deployment
- Created ansible/ directory with complete role structure - Added README.md with quickstart guide and feature toggle documentation - Added site.yml playbook with testpoint, fail2ban, selinux, nftables roles - Added inventory.example and group_vars/testpoints.yml with defaults - Implemented testpoint role: perfSONAR package installation, service management, sysctl tuning - Implemented fail2ban role: package installation, sshd jail configuration - Implemented selinux role: conditional SELinux state management - Implemented nftables role: minimal firewall ruleset with perfSONAR port placeholders - All YAML files validated and playbook syntax checked successfully Co-authored-by: ShawnMcKee <3066214+ShawnMcKee@users.noreply.github.com>
1 parent 8a7c2e6 commit ce52cf9

File tree

12 files changed

+206
-0
lines changed

12 files changed

+206
-0
lines changed

ansible/README.md

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# Ansible: perfSONAR Testpoint (Minimal Skeleton)
2+
3+
This minimal Ansible skeleton installs and configures a perfSONAR testpoint on RHEL-family systems with optional features you can toggle:
4+
- fail2ban
5+
- SELinux
6+
- nftables
7+
8+
It is designed to be small, idempotent, and easy to try. Extend as needed for your environment.
9+
10+
## Prerequisites
11+
- Control node with Ansible >= 2.12
12+
- Target host: RHEL/Alma/Rocky 8/9 (sudo privileges)
13+
- Network access to OS and perfSONAR repos
14+
15+
## Inventory Example
16+
See [inventory.example](inventory.example). Place your target host(s) in the `testpoints` group.
17+
18+
## Feature Toggles
19+
These booleans can be set in group_vars, host_vars, or via `-e` extra vars:
20+
- `enable_fail2ban` (default: false)
21+
- `enable_selinux` (default: false)
22+
- `enable_nftables` (default: false)
23+
24+
Additional variables:
25+
- `selinux_state`: enforcing | permissive | disabled (default: enforcing when enabled)
26+
- `testpoint_sysctls`: list of sysctl name/value pairs (default provided)
27+
- `testpoint_services`: list of services to enable/start (default provided)
28+
29+
## Quick Start
30+
```bash
31+
# Dry run
32+
ansible-playbook -i ansible/inventory.example ansible/site.yml --check
33+
34+
# Apply with optional features enabled
35+
ansible-playbook -i ansible/inventory.example ansible/site.yml \
36+
-e enable_fail2ban=true -e enable_selinux=true -e enable_nftables=true
37+
```
38+
39+
## Notes
40+
- nftables: This deploys a minimal ruleset to `/etc/nftables.conf` and enables the nftables service. If you already use another firewall (firewalld/iptables), test carefully and avoid conflicts.
41+
- SELinux: The role sets the SELinux mode only when `enable_selinux=true`. On systems without SELinux, the role is skipped.
42+
- Debian/Ubuntu: Not tested here. Tasks are guarded where practical; contributions welcome.
43+
44+
## Uninstall / Revert
45+
- Remove packages if desired and restore prior firewall configuration manually. This skeleton does not attempt to revert system-wide firewall configuration automatically.

ansible/group_vars/testpoints.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Defaults for the testpoints group — override as needed
2+
enable_fail2ban: false
3+
enable_selinux: false
4+
enable_nftables: false
5+
6+
selinux_state: enforcing
7+
8+
# Services may vary by version; override if needed
9+
testpoint_services:
10+
- pscheduler-scheduler
11+
- pscheduler-runner
12+
13+
# Baseline sysctl tuning (override to suit your NIC/OS)
14+
testpoint_sysctls:
15+
- { name: 'net.core.rmem_max', value: '67108864' }
16+
- { name: 'net.core.wmem_max', value: '67108864' }

ansible/inventory.example

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[testpoints]
2+
ps-testpoint-01.example.org ansible_user=ec2-user
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
- name: Restart fail2ban
3+
service:
4+
name: fail2ban
5+
state: restarted
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
---
2+
- name: Install fail2ban
3+
package:
4+
name: fail2ban
5+
state: present
6+
tags: ['fail2ban', 'packages']
7+
8+
- name: Enable and start fail2ban
9+
service:
10+
name: fail2ban
11+
state: started
12+
enabled: true
13+
tags: ['fail2ban', 'services']
14+
15+
- name: Deploy perfSONAR-friendly jail config (sshd)
16+
template:
17+
src: jail.local.j2
18+
dest: /etc/fail2ban/jail.d/perfsonar.local
19+
mode: '0644'
20+
notify: Restart fail2ban
21+
tags: ['fail2ban', 'config']
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
[sshd]
2+
enabled = true
3+
bantime = 3600
4+
findtime = 600
5+
maxretry = 6
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
table inet filter {
2+
chains {
3+
input {
4+
type filter hook input priority 0;
5+
policy drop;
6+
ct state established,related accept
7+
iif lo accept
8+
tcp dport { 22 } accept
9+
# perfSONAR typical ports (uncomment and adapt as needed):
10+
# udp dport { 861, 876, 883, 33434-33534 } accept # owamp, twamp, traceroute range
11+
# tcp dport { 5201 } accept # iperf3 throughput tests
12+
counter drop
13+
}
14+
forward { type filter hook forward priority 0; policy drop; }
15+
output { type filter hook output priority 0; policy accept; }
16+
}
17+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---
2+
- name: Reload nftables
3+
command: nft -f /etc/nftables.conf
4+
notify: Restart nftables
5+
6+
- name: Restart nftables
7+
service:
8+
name: nftables
9+
state: restarted
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
---
2+
- name: Install nftables
3+
package:
4+
name: nftables
5+
state: present
6+
tags: ['nftables', 'packages']
7+
8+
- name: Deploy minimal nftables rules
9+
copy:
10+
src: minimal.nft
11+
dest: /etc/nftables.conf
12+
mode: '0644'
13+
backup: true
14+
notify: Reload nftables
15+
tags: ['nftables', 'config']
16+
17+
- name: Enable and start nftables
18+
service:
19+
name: nftables
20+
state: started
21+
enabled: true
22+
tags: ['nftables', 'services']
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
---
2+
- name: Gather SELinux facts
3+
setup:
4+
filter: ansible_selinux
5+
tags: ['selinux']
6+
7+
- name: Ensure SELinux state as requested
8+
ansible.posix.selinux:
9+
policy: targeted
10+
state: "{{ selinux_state }}"
11+
when: ansible_facts.selinux is defined and ansible_facts.selinux.status != 'disabled'
12+
tags: ['selinux']

0 commit comments

Comments
 (0)