Rework service handling

Allow running playbooks without NetBox access. Mainly to bootstrap
NetBox itself.

Would prefer not to access network from filter plugins, so maybe do
that at some point also.
This commit is contained in:
Timotej Lazar 2024-06-19 13:33:32 +02:00
parent 38c3464279
commit 29598ef4bb
5 changed files with 34 additions and 27 deletions

View file

@ -7,7 +7,9 @@ table inet filter {
{% set prefixes4 = prefixes | selectattr('family.value', '==', 4) | map('string') %}
{% set prefixes6 = prefixes | selectattr('family.value', '==', 6) | map('string') %}
{% set ports = service.ports | compact_numlist %}
{% if 'name' in service %}
# service {{ service.name }}
{% endif %}
{% if prefixes4 or prefixes6 %}
{% if prefixes4 %}
ip saddr { {{ prefixes4 | join(', ') }} } tcp dport { {{ ports }} } accept