Puppet:如何循环检查exec命令的状态

时间:2017-05-10 03:49:57

标签: puppet

在我的一个Puppet清单中,我运行exec命令在远程服务器上运行作业并将输出转储到文件中。文件内容在json中,它包含几个字段。一个字段是状态,它决定作业是否完整而另一个是jobid,它提供作业的id。如果状态已完成,我使用jobid查询服务器以获取更多信息。如果状态未完成,我需要继续循环,直到作业完成。

我意识到exec有" try_sleep"但是因为我需要在exec之后解析json文件,所以我不相信我可以使用它。

我该如何解决这个问题?

根据Alex的要求,添加以下序列

Use exec command to execute some statement > /tmp/phase1.json

Parse /tmp/phase1.json and extract fields status and jobid

If field status is not complete, keep looping until it completes

If field status is complete, take the jobid and perform further processing

0 个答案:

没有答案