Use pyyaml to output group vars
Because the ansible group vars can be more complex structures than strings and ints, we should use yaml to output the groupvars files. This will allow list or dict values to be correctly represented in the ansible vars files. Change-Id: I79b3e6a5e7acb5f95d65034a2908a005d9a343db Closes-Bug: #1801162
This commit is contained in:
parent
1ee3c59dc7
commit
279543d7c9
@ -1,3 +0,0 @@
|
||||
{% for k,v in role_group_vars.items() %}
|
||||
{{ k }}: {{ v }}
|
||||
{% endfor %}
|
@ -1,2 +1,2 @@
|
||||
max_fail_percentage: 15
|
||||
any_errors_fatal: yes
|
||||
any_errors_fatal: True
|
||||
|
@ -1,2 +1,2 @@
|
||||
max_fail_percentage: 15
|
||||
any_errors_fatal: yes
|
||||
any_errors_fatal: True
|
||||
|
@ -279,10 +279,10 @@ class TestConfig(base.TestCase):
|
||||
{'output_key': 'RoleGroupVars',
|
||||
'output_value': {
|
||||
'Controller': {
|
||||
'any_errors_fatal': 'yes',
|
||||
'any_errors_fatal': True,
|
||||
'max_fail_percentage': 15},
|
||||
'Compute': {
|
||||
'any_errors_fatal': 'yes',
|
||||
'any_errors_fatal': True,
|
||||
'max_fail_percentage': 15},
|
||||
}}]
|
||||
deployment_data, configs = \
|
||||
@ -615,10 +615,10 @@ class TestConfig(base.TestCase):
|
||||
{'output_key': 'RoleGroupVars',
|
||||
'output_value': {
|
||||
'Controller': {
|
||||
'any_errors_fatal': 'yes',
|
||||
'any_errors_fatal': True,
|
||||
'max_fail_percentage': 15},
|
||||
'Compute': {
|
||||
'any_errors_fatal': 'yes',
|
||||
'any_errors_fatal': True,
|
||||
'max_fail_percentage': 15},
|
||||
}}]
|
||||
deployment_data, configs = \
|
||||
|
@ -441,14 +441,12 @@ class Config(object):
|
||||
# Render group_vars
|
||||
for role in set(server_roles.values()):
|
||||
group_var_role_path = os.path.join(group_vars_dir, role)
|
||||
group_var_role_template = env.get_template('group_var_role.j2')
|
||||
|
||||
with open(group_var_role_path, 'w') as f:
|
||||
template_data = group_var_role_template.render(
|
||||
role=role,
|
||||
role_group_vars=role_group_vars[role])
|
||||
self.validate_config(template_data, group_var_role_path)
|
||||
f.write(template_data)
|
||||
# NOTE(aschultz): we just use yaml.safe_dump for the vars because
|
||||
# the vars should already bein a hash for for ansible.
|
||||
# See LP#1801162 for previous issues around using jinja for this
|
||||
with open(group_var_role_path, 'w') as group_vars_file:
|
||||
yaml.safe_dump(role_group_vars[role], group_vars_file,
|
||||
default_flow_style=False)
|
||||
|
||||
# Render host_vars
|
||||
for server, deployments in server_deployment_names.items():
|
||||
|
Loading…
Reference in New Issue
Block a user