16 lines
775 B
YAML
Raw Normal View History

2022-07-21 01:00:17 +02:00
---
- name: Handle nomad ports in the firewall
iptables_raw:
name: nomad_port_{{ item }}
state: "{{ (('tcp' in nomad_services[item].proto or 'udp' in nomad_services[item].proto) and nomad_services[item].src_ip | length > 0) | ternary('present', 'absent') }}"
rules: |
{% if 'tcp' in nomad_services[item].proto %}
2022-08-01 12:00:18 +02:00
-A INPUT -m state --state NEW -p tcp --dport {{ nomad_services[item].port }} -s {{ nomad_services[item].src_ip | join(',') }} -j ACCEPT
2022-07-21 01:00:17 +02:00
{% endif %}
{% if 'udp' in nomad_services[item].proto %}
2022-08-01 12:00:18 +02:00
-A INPUT -m state --state NEW -p udp --dport {{ nomad_services[item].port }} -s {{ nomad_services[item].src_ip | join(',') }} -j ACCEPT
2022-07-21 01:00:17 +02:00
{% endif %}
loop: "{{ nomad_services.keys() | list }}"
tags: firewall,nomad