Community discussions

MikroTik App
 
Hoet01
just joined
Topic Author
Posts: 1
Joined: Mon Apr 11, 2022 11:31 pm

Ansible: ip firewall nat

Mon Apr 11, 2022 11:57 pm

Hello,

I seems to hit a snag when trying to set-up my router using ansible.
When I try to remove the NAT that I've configured via Ansible it fails to remove it. When I run the same command via the terminal under winbox I do not encouter the issue.

MicroTik terminal
[admin@sol] /ip/firewall/nat> print
Flags: X - disabled, I - invalid; D - dynamic
0 chain=srcnat action=masquerade out-interface=Trined

Part of the Ansible script
- routeros_command:
commands:
- /ip firewall nat remove [find where out-interface="Trined"]
- /ip firewall nat add chain=srcnat action=masquerade out-interface="Trined"

The above should be able to find the NAT rule and remove it on the first like and add it again on the second line, but it seems that it does nor remove the NAT but manipulates it and creates a new one.

MicroTik terminal
[admin@sol] /ip/firewall/nat> print
Flags: X - disabled, I - invalid; D - dynamic
0 I ;;; no interface
chain=srcnat action=masquerade out-interface=*E log=no log-prefix=""

1 chain=srcnat action=masquerade out-interface=Trined

Anyone got experience with this issue. A fix or workaround would be nice.
Any help appriciated
 
kraal
Member Candidate
Member Candidate
Posts: 142
Joined: Tue Jan 19, 2021 10:24 pm

Re: Ansible: ip firewall nat

Wed May 04, 2022 6:31 pm

Did you try without the quotes ? I.e. Trined instead of "Trined"
If you absolutely need to quote the interface name, use the jinja2 filters provided by the community.routeros collection:
https://docs.ansible.com/ansible/latest ... te-quoting

Who is online

Users browsing this forum: No registered users and 26 guests