0

In the following hypothetical example, I'm executing sleep for five sec on the remote host via the shell module. I'd like the Ansible Runner to timeout after four seconds if the remote shell process hasn't returned. Is this possible?

    r = ansible_runner.run(inventory=ansible_inventory, host_pattern="all",
        module="shell",
        module_args=("sleep 5"),
        envvars = {
            "ansible_command_timeout": 4  # This doesn't seem to work
        }
    )
blong
  • 2,815
  • 8
  • 44
  • 110
  • Try this: Create and add [private_data_dir](https://ansible-runner.readthedocs.io/en/latest/python_interface.html#usage-examples) to the parameters. Put `timeout: 4` into the file [env/settings](https://ansible-runner.readthedocs.io/en/latest/intro.html#env-settings-settings-for-runner-itself) of the private dir. – Vladimir Botka Jul 10 '20 at 18:29

1 Answers1

0

This worked for me. envvars is assigned the return of this method:

    def runnerenv(self):
     """ansible runner environment"""
     env = os.environ.copy()
     path = f"{env['PATH']}:{self.venvpath}"
     self.logger.debug(f"Updated PATH {path}")
     env['PATH'] = path
     env['ANSIBLE_TASK_TIMEOUT'] = 60
     return env
gerardw
  • 5,822
  • 46
  • 39