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 --- ChangeLog | 3 +++ cloudinit/CloudConfig/cc_chef.py | 10 +++++----- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index 0cf93c2a..27b412c8 100644 --- a/ChangeLog +++ b/ChangeLog @@ -38,6 +38,9 @@ (LP: #948461) [Ben Howard] - warn on non-multipart, non-handled user-data [Martin Packman] - run resizefs in the background in order to not block boot (LP: #961226) + - Fix bug in Chef support where validation_key was present in config, but + 'validation_cert' was not (LP: #960547) + 0.6.2: - fix bug where update was not done unless update was explicitly set. It would not be run if 'upgrade' or packages were set to be installed 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