From d168dc6358369de19c1a47312da29156427570ed Mon Sep 17 00:00:00 2001 From: Scott Moser Date: Mon, 26 Mar 2012 13:49:06 -0400 Subject: 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 --- cloudinit/CloudConfig/cc_chef.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'cloudinit') 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', -- cgit v1.2.3