Don't use the timeout command if it's not there

The timeout command is there to improve life and workaround puppet
deficiencies. However, it's not working around deficiencies on systems
that do not have the timeout command if we blindly use it.

The puppet specific timeout options are more complex and out of scope of
this.

Issue: https://github.com/ansible/ansible-modules-extras/issues/1273
Change-Id: Id2afbe7a8d0a9b52295a36eb8bde4ffd40fa8c21
This commit is contained in:
Monty Taylor 2015-11-25 07:54:46 -05:00
parent ad8aab1470
commit d049384a82
1 changed files with 10 additions and 2 deletions

View File

@ -130,6 +130,9 @@ def main():
module.fail_json(
msg="Could not find puppet. Please ensure it is installed.")
global TIMEOUT_CMD
TIMEOUT_CMD = module.get_bin_path("timeout", False)
if p['manifest']:
if not os.path.exists(p['manifest']):
module.fail_json(
@ -154,8 +157,13 @@ def main():
module.params['facter_basename'],
module.params['facts'])
base_cmd = "timeout -s 9 %(timeout)s %(puppet_cmd)s" % dict(
timeout=pipes.quote(p['timeout']), puppet_cmd=PUPPET_CMD)
if TIMEOUT_CMD:
base_cmd = "%(timeout_cmd)s -s 9 %(timeout)s %(puppet_cmd)s" % dict(
timeout_cmd=TIMEOUT_CMD,
timeout=pipes.quote(p['timeout']),
puppet_cmd=PUPPET_CMD)
else:
base_cmd = PUPPET_CMD
if not p['manifest']:
cmd = ("%(base_cmd)s agent --onetime"