在Ansible tower CLI中同时启动和监视作业

在Ansible tower CLI中同时启动和监视作业,ansible,ansible-tower,Ansible,Ansible Tower,我们已经安装了Ansible Tower并实现了CLI工具。我们可以使用以下命令在CLI中启动作业- OUTPUT="$(tower-cli job launch -J 5 | grep -o '[0-9]*' | head -1 )" tower-cli monitor $OUTPUT tower cli作业启动-J 5 这将返回输出,如下所示- Resource changed. === ============ ======================== ======= =====

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

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

这将返回输出,如下所示-

Resource changed.
=== ============ ======================== ======= ======= 
id  job_template         created          status  elapsed 
=== ============ ======================== ======= ======= 
119            5 2017-12-05T20:26:31.197Z pending 0.0
=== ============ ======================== ======= ======= 
然后我们可以像这样监控状态-

塔式cli作业监视器119

是否可以以某种方式将ID的输入传递到monitor cli参数中(或者是否可以同时运行这两个参数)?由于服务器上运行着多个作业,因此每次都需要能够可靠地获取作业id

当我在上阅读文档时,我没有看到任何与此相关的内容


谢谢

我通过以下操作修复了此问题-

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

我通过以下操作修复了此问题-

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

我使用的是
towercli
版本
towercli3.3.0
。我运行了
tower cli作业启动--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
命令,这就是我在上面包含它的原因)

我使用的是
tower cli
版本
tower cli 3.3.0
。我运行了
tower cli作业启动--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
命令,这就是我将其包含在上面的原因)