【问题标题】:Launching and Monitoring a job at the same time in Ansible tower CLI在 Ansible Tower CLI 中同时启动和监控作业
【发布时间】:2017-12-05 21:15:06
【问题描述】:

我们已经安装了 Ansible Tower 并实施了 CLI 工具。我们可以使用以下命令在 CLI 中启动作业 -

tower-cli job launch -J 5

这会像这样返回输出 -

Resource changed.
=== ============ ======================== ======= ======= 
id  job_template         created          status  elapsed 
=== ============ ======================== ======= ======= 
119            5 2017-12-05T20:26:31.197Z pending 0.0
=== ============ ======================== ======= ======= 

然后我们可以像这样监控状态 -

tower-cli job monitor 119.

是否可以通过某种方式将 ID 的输入传递给 monitor cli 参数(或者是否可以同时运行两者)?由于我们在服务器上运行了多个作业,因此我们需要每次都能可靠地获取作业 ID。

当我阅读http://tower-cli.readthedocs.io/en/latest/cli_ref/index.html 的文档时,我没有看到任何关于此的内容。

谢谢。

【问题讨论】:

    标签: ansible ansible-tower


    【解决方案1】:

    我在tower-cli 版本Tower CLI 3.3.0。我运行了tower-cli job launch --help,它给出了以下相关命令:

    --monitor              If sent, immediately calls `job monitor` on the
                           newly launched job rather than exiting with a
                           success.
    --wait                 Monitor the status of the job, but do not print
                           while job is in progress.
    

    所以我认为你可以做到以下几点:

    tower-cli job launch -J 5 --monitor
    

    (我在 CI 构建中运行此命令时添加了 --wait 命令,这就是我将其包含在上面的原因)

    【讨论】:

      【解决方案2】:

      我通过执行以下操作解决了这个问题 -

      OUTPUT="$(tower-cli job launch -J 5 | grep -o '[0-9]*' | head -1 )"
      tower-cli monitor $OUTPUT
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2022-01-12
        • 1970-01-01
        • 1970-01-01
        • 2020-01-07
        • 1970-01-01
        相关资源
        最近更新 更多