0

在下面的假设示例中,我sleep通过 shell 模块在远程主机上执行了 5 秒。如果远程 shell 进程没有返回,我希望 Ansible Runner 在四秒后超时。这可能吗?

    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
        }
    )
4

1 回答 1

0

这对我有用。envvars 被分配了这个方法的返回值:

    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
于 2021-06-11T14:59:40.523 回答