Try dynamically generating some fedmsg config from group/host vars in staging.

This commit is contained in:
Ralph Bean 2015-06-12 16:27:31 +00:00
parent 7acd932025
commit 60dbdd00cf
15 changed files with 72 additions and 10 deletions

25
filter_plugins/fedmsg.py Normal file
View file

@ -0,0 +1,25 @@
import operator
def invert_fedmsg_authz_policy(vars):
""" Given hostvars that map hosts -> topics, invert that
and return a dict that maps topics -> hosts.
Really, returns a list of tuples -- not a dict.
"""
inverted = {}
for host in vars:
prefix = '.'.join([vars[host]['fedmsg_prefix'],
vars[host]['fedmsg_env']])
fqdn = vars[host].get('fedmsg_fqdn', vars[host]['ansible_fqdn'])
for cert in vars[host].get('fedmsg_certs', []):
for topic in cert.get('can_send', []):
key = prefix + '.' + topic
inverted[key] = inverted.get(key, [])
inverted[key].append(cert['service'] + '-' + fqdn)
result = inverted.items()
result.sort(key=operator.itemgetter(0))
return result