Added filter_plugins used in other roles before
parent
62de7fcdb5
commit
54facac9c0
@ -0,0 +1,10 @@
|
||||
def domain_relative_to(domain):
|
||||
if domain == '@':
|
||||
return zone
|
||||
if domain[-1] != '.':
|
||||
return f"{domain}.{zone}"
|
||||
return domain
|
||||
|
||||
class FilterModule(object):
|
||||
def filters(self):
|
||||
return {'domain_relative_to': domain_relative_to}
|
@ -0,0 +1,29 @@
|
||||
from netaddr import IPNetwork, IPSet
|
||||
|
||||
def ip_rev(orig, rev, net):
|
||||
if orig.isdisjoint(IPSet(net)):
|
||||
rev.add(net)
|
||||
return
|
||||
elif orig.issuperset(IPSet(net)):
|
||||
return
|
||||
else:
|
||||
for net in net.subnet(net.prefixlen + 1):
|
||||
ip_rev(orig, rev, net)
|
||||
|
||||
def ip_net_rev(addresses, version=None):
|
||||
orig = IPSet(addresses)
|
||||
rev = IPSet()
|
||||
if version in [None, 4]:
|
||||
ip_rev(orig, rev, IPNetwork('0.0.0.0/0'))
|
||||
if version in [None, 6]:
|
||||
ip_rev(orig, rev, IPNetwork('::/0'))
|
||||
return [str(net) for net in rev.iter_cidrs()]
|
||||
|
||||
class FilterModule(object):
|
||||
def filters(self):
|
||||
return {'ip_net_rev': ip_net_rev}
|
||||
|
||||
if __name__ == '__main__':
|
||||
import sys
|
||||
for ip in ip_net_rev(sys.argv[1:]):
|
||||
print(ip)
|
@ -0,0 +1,8 @@
|
||||
from collections import Mapping
|
||||
|
||||
def mapping(val):
|
||||
return isinstance(val, Mapping)
|
||||
|
||||
class FilterModule(object):
|
||||
def filters(self):
|
||||
return {'mapping': mapping}
|
Loading…
Reference in New Issue