diff --git a/filter_plugins/fedmsg.py b/filter_plugins/fedmsg.py index 7aadc6acda..de31a2a174 100644 --- a/filter_plugins/fedmsg.py +++ b/filter_plugins/fedmsg.py @@ -1,13 +1,18 @@ import operator -def invert_fedmsg_policy(hosts, vars): +def invert_fedmsg_policy(groups, vars, env): """ 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. """ + if env == 'staging': + hosts = groups['staging'] + else: + hosts = [h for h in groups['all'] if h not in groups['staging']] + inverted = {} for host in hosts: prefix = '.'.join([vars[host]['fedmsg_prefix'], diff --git a/roles/fedmsg/base/templates/policy.py.j2 b/roles/fedmsg/base/templates/policy.py.j2 index c0a7c48d75..718afbfd54 100644 --- a/roles/fedmsg/base/templates/policy.py.j2 +++ b/roles/fedmsg/base/templates/policy.py.j2 @@ -220,7 +220,7 @@ config = dict( {% if env == 'staging' %} # ** policy dynamically generated from inventory vars # See ansible/filter_plugins/fedmsg.py for this inversion filter. - {% for topic, certs in groups['all'] | invert_fedmsg_policy(hostvars) %} + {% for topic, certs in groups | invert_fedmsg_policy(hostvars, env) %} "{{topic}}": [ {% for cert in certs %} "{{ cert }}",