Simplify puppet cmd generation

We were copy pastaing code in the puppet cmd generation for noop and
environment handling. Collapse that to make code easier to read and
hopefully avoid future bugs where only one side is edited.

Local testing shows that puppet parses commands like:

  puppet apply test.pp --noop

just fine.

Change-Id: Ie7665f72b9327b6b834d358699addf2c60a95ec0
This commit is contained in:
Clark Boylan 2016-09-16 12:35:25 -07:00 committed by Monty Taylor
parent b4f591b72d
commit 8cc1cd9126
No known key found for this signature in database
GPG Key ID: 7BAE94BC7141A594
1 changed files with 10 additions and 18 deletions

View File

@ -191,27 +191,19 @@ def main():
)
if p['puppetmaster']:
cmd += " --server %s" % pipes.quote(p['puppetmaster'])
if p['show_diff']:
cmd += " --show_diff"
if p['environment']:
cmd += " --environment '%s'" % p['environment']
if module.check_mode or p['noop']:
cmd += " --noop"
else:
cmd += " --no-noop"
else:
cmd = "%s apply --detailed-exitcodes " % base_cmd
if p['show_diff']:
cmd += "--show_diff "
if p['logdest'] != 'stdout':
cmd += "--logdest %s " % p['logdest']
if p['environment']:
cmd += "--environment '%s' " % p['environment']
if module.check_mode or p['noop']:
cmd += "--noop "
else:
cmd += "--no-noop "
cmd += pipes.quote(p['manifest'])
if p['logdest'] != 'stdout':
cmd += " --logdest %s" % p['logdest']
if p['show_diff']:
cmd += " --show_diff"
if p['environment']:
cmd += " --environment '%s'" % p['environment']
if module.check_mode or p['noop']:
cmd += " --noop"
else:
cmd += " --no-noop"
rc, stdout, stderr = module.run_command(cmd)
if rc == 0: