diff options
author | Scott Moser <smoser@ubuntu.com> | 2012-03-26 13:49:06 -0400 |
---|---|---|
committer | Scott Moser <smoser@ubuntu.com> | 2012-03-26 13:49:06 -0400 |
commit | d168dc6358369de19c1a47312da29156427570ed (patch) | |
tree | de492ab7b4025f5ce26c5a1256d473c92a8b67c0 | |
parent | ebb0642b939a048e6218a28ebcd73ac86dcc7fdd (diff) | |
download | vyos-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
-rw-r--r-- | ChangeLog | 3 | ||||
-rw-r--r-- | cloudinit/CloudConfig/cc_chef.py | 10 |
2 files changed, 8 insertions, 5 deletions
@@ -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', |