Files
zulip/tools/zulip-puppet-apply
Zev Benjamin 959a5c4835 zulip-puppet-apply: Always do a dry run first and then prompt to do the real run
You can immediately apply the changes by passing '-f' or '--force' as
the first argument.

(imported from commit 91f00f6afd3c42e2b11f60e92fc20962bc952f0d)
2013-10-07 16:22:55 -04:00

34 lines
799 B
Python
Executable File

#!/usr/bin/python
import sys
import subprocess
force = False
extra_args = sys.argv[1:]
if len(extra_args) and extra_args[0] in ('-f', '--force'):
force = True
eatra_args = extra_args[1:]
with open('/etc/humbug-machinetype') as f:
machinetype = f.readline().strip()
puppet_cmd = ["puppet", "apply", "-e", "class {'zulip': machinetype => '%s'}" % (machinetype,)]
puppet_cmd += extra_args
if force:
subprocess.check_call(puppet_cmd)
sys.exit(0)
subprocess.check_call(puppet_cmd + ['--noop', '--show_diff'])
do_apply = None
while not (do_apply == 'y' or do_apply == 'n'):
sys.stdout.write("Apply changes? [y/N] ")
do_apply = sys.stdin.readline().strip().lower()
if do_apply == '':
do_apply = 'n'
if do_apply == 'y':
subprocess.check_call(puppet_cmd)