diff --git a/scripts/zulip-puppet-apply b/scripts/zulip-puppet-apply index 2116d8dbb2..cdcb93d01a 100755 --- a/scripts/zulip-puppet-apply +++ b/scripts/zulip-puppet-apply @@ -8,6 +8,7 @@ import re from lib.zulip_tools import parse_lsb_release, assert_running_as_root assert_running_as_root() +BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) force = False extra_args = sys.argv[1:] @@ -34,12 +35,17 @@ for pclass in re.split(r'\s*,\s*', config.get('machine', 'puppet_classes')): puppet_config += "include %s\n" % (pclass,) # We use the puppet configuration from the same Zulip checkout as this script -puppet_module_path = os.path.join(os.path.dirname(os.path.dirname(os.path.abspath(__file__))), "puppet") +scripts_path = os.path.join(BASE_DIR, "scripts") +puppet_module_path = os.path.join(BASE_DIR, "puppet") puppet_cmd = ["puppet", "apply", "--modulepath", puppet_module_path, "-e", puppet_config] puppet_cmd += extra_args +# Set the scripts path to be a factor so it can be used by puppet code +puppet_env = os.environ.copy() +puppet_env["FACTER_zulip_scripts_path"] = scripts_path + if not force: - subprocess.check_call(puppet_cmd + ['--noop', '--show_diff']) + subprocess.check_call(puppet_cmd + ['--noop', '--show_diff'], env=puppet_env) do_apply = None while do_apply != 'y': @@ -49,7 +55,7 @@ if not force: if do_apply == '' or do_apply == 'n': sys.exit(0) -ret = subprocess.call(puppet_cmd + ['--detailed-exitcodes']) +ret = subprocess.call(puppet_cmd + ['--detailed-exitcodes'], env=puppet_env) # ret = 0 => no changes, no errors # ret = 2 => changes, no errors # ret = 4 => no changes, yes errors