Skip to content

Instantly share code, notes, and snippets.

@viesti
viesti / filters.py
Created September 17, 2015 13:10
Ansible filter plugin to create rules fo ec2_group
def make_rules(hosts, ports, proto):
return [{"proto": proto,
"from_port": port,
"to_port": port,
"cidr_ip": host} for host in hosts for port in map(int, ports.split(","))]
class FilterModule(object):
def filters(self):
return {'make_rules': make_rules}