diff options
author | Joshua Harlow <harlowja@gmail.com> | 2014-10-11 18:54:14 -0700 |
---|---|---|
committer | Joshua Harlow <harlowja@gmail.com> | 2014-10-11 18:54:14 -0700 |
commit | 736603ffdce0b836b43c77ae680ef2818521f30c (patch) | |
tree | 17ab0e9328189d4aa7e8736bbcfc6671db67225f | |
parent | 0a2e8b0130c2f83c0ea555d26473c92098c6adda (diff) | |
download | vyos-cloud-init-736603ffdce0b836b43c77ae680ef2818521f30c.tar.gz vyos-cloud-init-736603ffdce0b836b43c77ae680ef2818521f30c.zip |
Move the chef running to its own helper function
-rw-r--r-- | cloudinit/config/cc_chef.py | 36 |
1 files changed, 20 insertions, 16 deletions
diff --git a/cloudinit/config/cc_chef.py b/cloudinit/config/cc_chef.py index ff08050d..f501f1f7 100644 --- a/cloudinit/config/cc_chef.py +++ b/cloudinit/config/cc_chef.py @@ -167,22 +167,26 @@ def handle(name, cfg, cloud, log, _args): if not is_installed() or force_install: run_after = install_chef(cloud, chef_cfg, log) if run_after: - log.debug('Running chef-client') - cmd = [CHEF_EXEC_PATH] - if 'exec_arguments' in chef_cfg: - cmd_args = chef_cfg['exec_arguments'] - if isinstance(cmd_args, (list, tuple)): - cmd.extend(cmd_args) - elif isinstance(cmd_args, (str, basestring)): - cmd.append(cmd_args) - else: - log.warn("Unknown type %s provided for chef" - " 'exec_arguments' expected list, tuple," - " or string", type(cmd_args)) - cmd.extend(CHEF_EXEC_DEF_ARGS) - else: - cmd.extend(CHEF_EXEC_DEF_ARGS) - util.subp(cmd, capture=False) + run_chef(chef_cfg, log) + + +def run_chef(chef_cfg, log): + log.debug('Running chef-client') + cmd = [CHEF_EXEC_PATH] + if 'exec_arguments' in chef_cfg: + cmd_args = chef_cfg['exec_arguments'] + if isinstance(cmd_args, (list, tuple)): + cmd.extend(cmd_args) + elif isinstance(cmd_args, (str, basestring)): + cmd.append(cmd_args) + else: + log.warn("Unknown type %s provided for chef" + " 'exec_arguments' expected list, tuple," + " or string", type(cmd_args)) + cmd.extend(CHEF_EXEC_DEF_ARGS) + else: + cmd.extend(CHEF_EXEC_DEF_ARGS) + util.subp(cmd, capture=False) def install_chef(cloud, chef_cfg, log): |