List only stg hosts in the stg policy and prod hosts in the prod policy.
This commit is contained in:
parent
404430fb62
commit
ceb8e0b73d
2 changed files with 7 additions and 2 deletions
|
@ -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'],
|
||||
|
|
|
@ -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 }}",
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue