diff options
author | Brenton Leanhardt <bleanhar@redhat.com> | 2016-01-12 10:39:25 -0500 |
---|---|---|
committer | Brenton Leanhardt <bleanhar@redhat.com> | 2016-01-12 10:39:25 -0500 |
commit | ec643bee6b4de6d26f5aea346d73e8158f10939e (patch) | |
tree | 8bac63b1372a3f5691d7433bb605e5038b823953 | |
parent | f648f7111efdb16059996667730c7c9b423d75d7 (diff) | |
parent | 4725d3509e1315ad671a77d355c7a5328578390b (diff) | |
download | openshift-ec643bee6b4de6d26f5aea346d73e8158f10939e.tar.gz openshift-ec643bee6b4de6d26f5aea346d73e8158f10939e.tar.bz2 openshift-ec643bee6b4de6d26f5aea346d73e8158f10939e.tar.xz openshift-ec643bee6b4de6d26f5aea346d73e8158f10939e.zip |
Merge pull request #1148 from LutzLange/master
Fix for providing cloud-provider arguments with multiline yaml capability
-rw-r--r-- | filter_plugins/oo_filters.py | 15 | ||||
-rw-r--r-- | roles/openshift_master/templates/master.yaml.v1.j2 | 4 | ||||
-rw-r--r-- | roles/openshift_node/templates/node.yaml.v1.j2 | 4 |
3 files changed, 17 insertions, 6 deletions
diff --git a/filter_plugins/oo_filters.py b/filter_plugins/oo_filters.py index 326c36f6c..c262693ec 100644 --- a/filter_plugins/oo_filters.py +++ b/filter_plugins/oo_filters.py @@ -12,6 +12,8 @@ import os import pdb import re import json +import yaml +from ansible.utils.unicode import to_unicode class FilterModule(object): ''' Custom ansible filters ''' @@ -474,6 +476,16 @@ class FilterModule(object): secret = os.urandom(num_bytes) return secret.encode('base-64').strip() + @staticmethod + def to_padded_yaml(data, level=0, indent=2, **kw): + ''' returns a yaml snippet padded to match the indent level you specify ''' + try: + transformed = yaml.safe_dump(data, indent=indent, allow_unicode=True, default_flow_style=False, **kw) + padded = "\n".join([" " * level * indent + line for line in transformed.splitlines()]) + return to_unicode("\n{0}".format(padded)) + except Exception as my_e: + raise errors.AnsibleFilterError('Failed to convert: %s', my_e) + def filters(self): ''' returns a mapping of filters to methods ''' return { @@ -493,5 +505,6 @@ class FilterModule(object): "oo_parse_named_certificates": self.oo_parse_named_certificates, "oo_haproxy_backend_masters": self.oo_haproxy_backend_masters, "oo_pretty_print_cluster": self.oo_pretty_print_cluster, - "oo_generate_secret": self.oo_generate_secret + "oo_generate_secret": self.oo_generate_secret, + "to_padded_yaml": self.to_padded_yaml, } diff --git a/roles/openshift_master/templates/master.yaml.v1.j2 b/roles/openshift_master/templates/master.yaml.v1.j2 index 647476b7f..dfcaf1953 100644 --- a/roles/openshift_master/templates/master.yaml.v1.j2 +++ b/roles/openshift_master/templates/master.yaml.v1.j2 @@ -87,8 +87,8 @@ kubernetesMasterConfig: - v1beta3 - v1 {% endif %} - apiServerArguments: {{ openshift.master.api_server_args | default(None) | to_json }} - controllerArguments: {{ openshift.master.controller_args | default(None) | to_json }} + apiServerArguments: {{ openshift.master.api_server_args | default(None) | to_padded_yaml( level=2 ) }} + controllerArguments: {{ openshift.master.controller_args | default(None) | to_padded_yaml( level=2 ) }} masterCount: {{ openshift.master.master_count if openshift.master.cluster_method | default(None) == 'native' else 1 }} masterIP: {{ openshift.common.ip }} podEvictionTimeout: "" diff --git a/roles/openshift_node/templates/node.yaml.v1.j2 b/roles/openshift_node/templates/node.yaml.v1.j2 index 23bd81f91..cbe811f83 100644 --- a/roles/openshift_node/templates/node.yaml.v1.j2 +++ b/roles/openshift_node/templates/node.yaml.v1.j2 @@ -11,9 +11,7 @@ imageConfig: format: {{ openshift.node.registry_url }} latest: false kind: NodeConfig -{% if openshift.node.kubelet_args is defined and openshift.node.kubelet_args %} -kubeletArguments: {{ openshift.node.kubelet_args | to_json }} -{% endif %} +kubeletArguments: {{ openshift.node.kubelet_args | default(None) | to_padded_yaml(level=1) }} masterKubeConfig: system:node:{{ openshift.common.hostname }}.kubeconfig {% if openshift.common.use_openshift_sdn %} networkPluginName: {{ openshift.common.sdn_network_plugin_name }} |