From 0d18d2c54af8df95c21400d010b88cb0b8838ae5 Mon Sep 17 00:00:00 2001 From: Chris Roemmich Date: Sat, 31 Oct 2015 02:28:39 -0500 Subject: [PATCH] fix(contrib/linode): fix discovery url issues in deployment scripts --- contrib/linode/apply-firewall.py | 3 ++- contrib/linode/create-linode-user-data.py | 6 ++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/contrib/linode/apply-firewall.py b/contrib/linode/apply-firewall.py index dd77ccdf11..f1c05ecc64 100755 --- a/contrib/linode/apply-firewall.py +++ b/contrib/linode/apply-firewall.py @@ -46,7 +46,8 @@ def get_discovery_url_from_user_data(): try: current_dir = os.path.dirname(__file__) user_data_file = file(os.path.abspath(os.path.join(current_dir, name)), 'r') - return re.search('--discovery (http\S+)', user_data_file.read()).group(1) + user_data_yaml = yaml.safe_load(user_data_file) + return user_data_yaml['coreos']['etcd2']['discovery'] except: raise IOError('Could not load discovery url from ' + name) diff --git a/contrib/linode/create-linode-user-data.py b/contrib/linode/create-linode-user-data.py index 1a170c3c3b..51760ed5a6 100755 --- a/contrib/linode/create-linode-user-data.py +++ b/contrib/linode/create-linode-user-data.py @@ -67,14 +67,16 @@ def main(): linode_template = get_file("linode-user-data-template.yaml") coreos_template = get_file("../coreos/user-data.example") + coreos_template_string = coreos_template.read() + coreos_template_string = coreos_template_string.replace('#DISCOVERY_URL', 'https://discovery.etcd.io/' + str(etcd_token)) + configuration_linode_template = yaml.safe_load(linode_template) - configuration_coreos_template = yaml.safe_load(coreos_template) + configuration_coreos_template = yaml.safe_load(coreos_template_string) configuration = combine_dicts(configuration_coreos_template, configuration_linode_template) configuration['ssh_authorized_keys'] = public_keys dump = yaml.dump(configuration, default_flow_style=False, default_style='|') - dump = dump.replace('#DISCOVERY_URL', 'https://discovery.etcd.io/' + str(etcd_token)) with linode_user_data as outfile: outfile.write("#cloud-config\n\n" + dump)