Skip to content

Instantly share code, notes, and snippets.

@kamigerami
Created May 21, 2018 14:49
Show Gist options
  • Save kamigerami/81d0bc34f8b0cdc3361a76a60af87bb8 to your computer and use it in GitHub Desktop.
Save kamigerami/81d0bc34f8b0cdc3361a76a60af87bb8 to your computer and use it in GitHub Desktop.
idempotent DNS rules ansible lineinfile module
- name: Create persistent DNS rules for acepting port 53
lineinfile:
path: /etc/sysconfig/iptables
state: "{{ item.1 }}"
insertbefore: "^-A INPUT (1 - p {{ item.0 }} -- dport 53 -j ACCEPT)?"
line: "-A INPUT 1 -p {{ item.0 }} --dport 53 -j ACCEPT"
with_nested:
- ['TCP', 'UDP']
- ['absent', 'present']
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment