summaryrefslogtreecommitdiff
path: root/cloudinit
diff options
context:
space:
mode:
authorScott Moser <smoser@ubuntu.com>2012-03-26 13:49:06 -0400
committerScott Moser <smoser@ubuntu.com>2012-03-26 13:49:06 -0400
commitd168dc6358369de19c1a47312da29156427570ed (patch)
treede492ab7b4025f5ce26c5a1256d473c92a8b67c0 /cloudinit
parentebb0642b939a048e6218a28ebcd73ac86dcc7fdd (diff)
downloadvyos-cloud-init-d168dc6358369de19c1a47312da29156427570ed.tar.gz
vyos-cloud-init-d168dc6358369de19c1a47312da29156427570ed.zip
cc_chef: fix bug when validation_key was present, but validation_cert was not
This fixes a bug in chef handling if the config contained the 'validation_key' key, but not the 'validation_cert' key. LP: #960547
Diffstat (limited to 'cloudinit')
-rw-r--r--cloudinit/CloudConfig/cc_chef.py10
1 files changed, 5 insertions, 5 deletions
diff --git a/cloudinit/CloudConfig/cc_chef.py b/cloudinit/CloudConfig/cc_chef.py
index 090aaa37..941e04fe 100644
--- a/cloudinit/CloudConfig/cc_chef.py
+++ b/cloudinit/CloudConfig/cc_chef.py
@@ -40,11 +40,11 @@ def handle(_name, cfg, cloud, log, _args):
# set the validation key based on the presence of either 'validation_key'
# or 'validation_cert'. In the case where both exist, 'validation_key'
# takes precedence
- if ('validation_key' in chef_cfg or 'validation_cert' in chef_cfg):
- validation_key = util.get_cfg_option_str(chef_cfg, 'validation_key',
- chef_cfg['validation_cert'])
- with open('/etc/chef/validation.pem', 'w') as validation_key_fh:
- validation_key_fh.write(validation_key)
+ for key in ('validation_key', 'validation_cert'):
+ if key in chef_cfg and chef_cfg[key]:
+ with open('/etc/chef/validation.pem', 'w') as validation_key_fh:
+ validation_key_fh.write(chef_cfg[key])
+ break
# create the chef config from template
util.render_to_file('chef_client.rb', '/etc/chef/client.rb',