router/handlers/main.yaml

16 lines
524 B
YAML

---
# restart nftables
- name: "restart nftables"
ansible.builtin.service:
name: "nftables"
state: "restarted"
# apply local routes
- name: "apply routes - add static routes"
ansible.builtin.shell:
cmd: |
{% for route in static_routes %}
ip route replace {{ route.destination }} via {{ route.gateway }}{{ ' dev ' + route.interface if route.interface is defined else '' }}{{ ' metric ' + route.metric if route.metric is defined else '' }}
{% endfor %}
when: "static_routes | length > 0"