proxmox: set up firewall

Firewall policy is set in NetBox as cluster services¹. For Proxmox we
have to manually allow communication between nodes when using L3,
since the default management ipset does not get populated correctly.
We also need to open VTEP communication between nodes, which the
default rules don’t. We allow all inter-node traffic, as SSH without
passwords must be permitted anyway.

This also adds some helper filters that are spectacularly annoying to
implement purely in templates.

¹ There is actually no such thing as as a cluster service (yet?), so
instead we create a fake VM for the cluster, define services for it,
and then add the same services to a custom field on the cluster.
Alternative would be to tie services to a specific node, but that
could be problematic if that node is replaced.
This commit is contained in:
Timotej Lazar 2024-04-05 06:00:50 +02:00
parent 179547beff
commit e7f9132571
4 changed files with 74 additions and 1 deletions

View file

@ -0,0 +1,12 @@
- name: Retrieve service list
set_fact:
services: '{{ query("netbox.netbox.nb_lookup", "clusters", raw_data=true, api_filter="name="+cluster) | map(attribute="custom_fields.services") | flatten }}'
- name: Set up firewall
template:
dest: /etc/pve/firewall/cluster.fw
src: cluster.fw.j2
mode: 0640
owner: root
group: www-data

View file

@ -1,3 +1,7 @@
- name: Get all nodes in my cluster
set_fact:
nodes: "{{ groups['cluster_'+cluster] | map('extract', hostvars) }}"
- name: Disable enterprise repositories
apt_repository:
repo: '{{ item }}'
@ -40,4 +44,6 @@
- include_tasks: mgmt.yml
- include_tasks: firewall.yml
- include_tasks: frr.yml