From 4e534a7c22514d162e65cc773d44b706fe877cea Mon Sep 17 00:00:00 2001 From: Scott Moser Date: Mon, 8 Jun 2020 15:43:24 -0400 Subject: Replace cc_chef is_installed with use of subp.is_exe. (#421) This was brought up in review of #416. Makes sense to remove the local copy of "is this executable file". --- cloudinit/config/cc_chef.py | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) (limited to 'cloudinit/config/cc_chef.py') diff --git a/cloudinit/config/cc_chef.py b/cloudinit/config/cc_chef.py index e1f51fce..f8c22bcb 100644 --- a/cloudinit/config/cc_chef.py +++ b/cloudinit/config/cc_chef.py @@ -145,14 +145,6 @@ CHEF_EXEC_PATH = '/usr/bin/chef-client' CHEF_EXEC_DEF_ARGS = tuple(['-d', '-i', '1800', '-s', '20']) -def is_installed(): - if not os.path.isfile(CHEF_EXEC_PATH): - return False - if not os.access(CHEF_EXEC_PATH, os.X_OK): - return False - return True - - def post_run_chef(chef_cfg, log): delete_pem = util.get_cfg_option_bool(chef_cfg, 'delete_validation_post_exec', @@ -257,9 +249,10 @@ def handle(name, cfg, cloud, log, _args): # Try to install chef, if its not already installed... force_install = util.get_cfg_option_bool(chef_cfg, 'force_install', default=False) - if not is_installed() or force_install: + installed = subp.is_exe(CHEF_EXEC_PATH) + if not installed or force_install: run = install_chef(cloud, chef_cfg, log) - elif is_installed(): + elif installed: run = util.get_cfg_option_bool(chef_cfg, 'exec', default=False) else: run = False -- cgit v1.2.3