summaryrefslogtreecommitdiff
path: root/cloudinit/config
diff options
context:
space:
mode:
authorJoshua Harlow <harlowja@gmail.com>2014-10-11 21:29:01 -0700
committerJoshua Harlow <harlowja@gmail.com>2014-10-11 21:29:01 -0700
commitda89dca32a3dd394c6a19807856871a645f2acc4 (patch)
tree4e86ac6d47a11fe6c0b76b217557573162f6aea8 /cloudinit/config
parentdb6cee3fe1c6033af8ae66f76c7c81a5af2d9c5a (diff)
downloadvyos-cloud-init-da89dca32a3dd394c6a19807856871a645f2acc4.tar.gz
vyos-cloud-init-da89dca32a3dd394c6a19807856871a645f2acc4.zip
Allow running even if installed
Standardize on using the chef_cfg key 'exec' which can be used when installing to tell the caller to run the chef client or can also be used if the client is already installed and its requested to be ran. To retain existing behavior 'exec' does not by default assume to be true, unless explicitly provided or a gems mode install is requested.
Diffstat (limited to 'cloudinit/config')
-rw-r--r--cloudinit/config/cc_chef.py22
1 files changed, 12 insertions, 10 deletions
diff --git a/cloudinit/config/cc_chef.py b/cloudinit/config/cc_chef.py
index e9a37652..29238861 100644
--- a/cloudinit/config/cc_chef.py
+++ b/cloudinit/config/cc_chef.py
@@ -180,9 +180,13 @@ def handle(name, cfg, cloud, log, _args):
force_install = util.get_cfg_option_bool(chef_cfg,
'force_install', default=False)
if not is_installed() or force_install:
- run_after = install_chef(cloud, chef_cfg, log)
- if run_after:
- run_chef(chef_cfg, log)
+ run = install_chef(cloud, chef_cfg, log)
+ elif is_installed():
+ run = util.get_cfg_option_bool(chef_cfg, 'exec', default=False)
+ else:
+ run = False
+ if run:
+ run_chef(chef_cfg, log)
def run_chef(chef_cfg, log):
@@ -208,18 +212,16 @@ def install_chef(cloud, chef_cfg, log):
# If chef is not installed, we install chef based on 'install_type'
install_type = util.get_cfg_option_str(chef_cfg, 'install_type',
'packages')
- run_after = util.get_cfg_option_bool(chef_cfg, 'exec_after_install',
- default=False)
+ run = util.get_cfg_option_bool(chef_cfg, 'exec', default=False)
if install_type == "gems":
# This will install and run the chef-client from gems
chef_version = util.get_cfg_option_str(chef_cfg, 'version', None)
ruby_version = util.get_cfg_option_str(chef_cfg, 'ruby_version',
RUBY_VERSION_DEFAULT)
install_chef_from_gems(cloud.distro, ruby_version, chef_version)
- # Retain backwards compat, but preferring True instead of False
+ # Retain backwards compat, by preferring True instead of False
# when not provided/overriden...
- run_after = util.get_cfg_option_bool(chef_cfg, 'exec_after_install',
- default=True)
+ run = util.get_cfg_option_bool(chef_cfg, 'exec', default=True)
elif install_type == 'packages':
# This will install and run the chef-client from packages
cloud.distro.install_packages(('chef',))
@@ -237,8 +239,8 @@ def install_chef(cloud, chef_cfg, log):
util.subp([tmpf], capture=False)
else:
log.warn("Unknown chef install type '%s'", install_type)
- run_after = False
- return run_after
+ run = False
+ return run
def get_ruby_packages(version):