Set-OPS — moteur d'ecosystemes numeriques souverains (Alliance Boreale)
This commit is contained in:
commit
3dd3f43ad8
308 changed files with 13649 additions and 0 deletions
3
roles/nftables_baseline/README.md
Normal file
3
roles/nftables_baseline/README.md
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
# Rôle nftables_baseline
|
||||
|
||||
Prépare nftables. Désactivé par défaut dans le template.
|
||||
10
roles/nftables_baseline/defaults/main.yml
Normal file
10
roles/nftables_baseline/defaults/main.yml
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
---
|
||||
nftables_baseline_enabled: false
|
||||
nftables_baseline_allow_ssh: true
|
||||
nftables_baseline_allow_icmp: true
|
||||
nftables_baseline_input_policy: "drop"
|
||||
nftables_baseline_forward_policy: "drop"
|
||||
nftables_baseline_output_policy: "accept"
|
||||
nftables_baseline_ssh_port: 22
|
||||
nftables_baseline_extra_tcp_ports: []
|
||||
nftables_baseline_extra_udp_ports: []
|
||||
4
roles/nftables_baseline/handlers/main.yml
Normal file
4
roles/nftables_baseline/handlers/main.yml
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
---
|
||||
- name: Reload nftables
|
||||
ansible.builtin.command: nft -f /etc/nftables.conf
|
||||
changed_when: true
|
||||
30
roles/nftables_baseline/tasks/main.yml
Normal file
30
roles/nftables_baseline/tasks/main.yml
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
---
|
||||
- name: Installer nftables
|
||||
ansible.builtin.apt:
|
||||
name: nftables
|
||||
state: present
|
||||
|
||||
- name: Déployer la configuration nftables Set-OPS
|
||||
ansible.builtin.template:
|
||||
src: nftables.conf.j2
|
||||
dest: /etc/nftables.conf
|
||||
owner: root
|
||||
group: root
|
||||
mode: "0644"
|
||||
notify: Reload nftables
|
||||
when: nftables_baseline_enabled | bool
|
||||
|
||||
- name: Activer nftables si demandé
|
||||
ansible.builtin.systemd:
|
||||
name: nftables
|
||||
enabled: true
|
||||
state: started
|
||||
when: nftables_baseline_enabled | bool
|
||||
|
||||
- name: Désactiver nftables si demandé
|
||||
ansible.builtin.systemd:
|
||||
name: nftables
|
||||
enabled: false
|
||||
state: stopped
|
||||
when: not (nftables_baseline_enabled | bool)
|
||||
failed_when: false
|
||||
39
roles/nftables_baseline/templates/nftables.conf.j2
Normal file
39
roles/nftables_baseline/templates/nftables.conf.j2
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
#!/usr/sbin/nft -f
|
||||
# Managed by Ansible — Set-OPS
|
||||
|
||||
flush ruleset
|
||||
|
||||
table inet setops_filter {
|
||||
chain input {
|
||||
type filter hook input priority 0; policy {{ nftables_baseline_input_policy }};
|
||||
|
||||
iif "lo" accept
|
||||
ct state established,related accept
|
||||
ct state invalid drop
|
||||
|
||||
{% if nftables_baseline_allow_icmp | bool %}
|
||||
ip protocol icmp accept
|
||||
ip6 nexthdr icmpv6 accept
|
||||
{% endif %}
|
||||
|
||||
{% if nftables_baseline_allow_ssh | bool %}
|
||||
tcp dport {{ nftables_baseline_ssh_port }} accept
|
||||
{% endif %}
|
||||
|
||||
{% for port in nftables_baseline_extra_tcp_ports %}
|
||||
tcp dport {{ port }} accept
|
||||
{% endfor %}
|
||||
|
||||
{% for port in nftables_baseline_extra_udp_ports %}
|
||||
udp dport {{ port }} accept
|
||||
{% endfor %}
|
||||
}
|
||||
|
||||
chain forward {
|
||||
type filter hook forward priority 0; policy {{ nftables_baseline_forward_policy }};
|
||||
}
|
||||
|
||||
chain output {
|
||||
type filter hook output priority 0; policy {{ nftables_baseline_output_policy }};
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue