Skip to content

Instantly share code, notes, and snippets.

@kuon
Created August 26, 2014 15:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kuon/10e8d324059357ad0555 to your computer and use it in GitHub Desktop.
Save kuon/10e8d324059357ad0555 to your computer and use it in GitHub Desktop.
Mapping groups to ports in ansible
vars:
fw_ports:
- ["5000", "6000"]
- "{{ groups['api-server'] }}" # this should map to a list of IP
tasks:
- name: Open ports
firewalld:
permanent={{ permanent }}
state=enabled
rich_rule='rule family="ipv4" source address="{{ item[1) }}" port port="{{ item[0] }}" protocol="tcp" accept'
when: fw_ports is defined
with_nested_items: fw_ports
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment