当然,我可以使用shell命令,但我希望有一种可行的方法来做到这一点,这样我就可以得到“更改/未更改”的响应。
答案 0 :(得分:2)
除了评论what you found之外,如果您最终需要执行shell命令,则可以将command
模块与removes
参数(doc)一起使用。如果文件已经存在(不存在),它将跳过该步骤,这将阻止它在步骤上报告changed
。但是,您仍然需要像其他答案一样迭代列表。
答案 1 :(得分:1)
这是我的方法:
+------------+-----------+-----------+-------------------------+-------------------------+------------------+--------------+---------------+
| ServiceTag | id_sut | id_sut1 | sut | sut1 | MinuteBoundaries | WholeMinutes | FormattedTime |
+------------+-----------+-----------+-------------------------+-------------------------+------------------+--------------+---------------+
| IDXXX12 | 145818840 | 145820934 | 2019-01-18 08:35:27.000 | 2019-01-18 08:50:41.000 | 15 | 15 | 00:15 |
| IDXXX12 | 145820934 | 145822116 | 2019-01-18 08:50:41.000 | 2019-01-18 08:59:18.000 | 9 | 8 | 00:08 |
| IDXXX12 | 145822116 | 145825658 | 2019-01-18 08:59:18.000 | 2019-01-18 09:23:23.000 | 24 | 24 | 00:24 |
| IDXXX12 | 145825658 | 145826849 | 2019-01-18 09:23:23.000 | 2019-01-18 09:30:55.000 | 7 | 7 | 00:07 |
| IDXXX13 | 245818840 | 245820934 | 2019-01-17 18:35:00.000 | 2019-01-17 18:50:00.000 | 15 | 15 | 00:15 |
| IDXXX13 | 245820934 | 245822116 | 2019-01-17 18:50:00.000 | 2019-01-17 18:59:00.000 | 9 | 9 | 00:09 |
| IDXXX13 | 245822116 | 245825658 | 2019-01-17 18:59:00.000 | 2019-01-17 19:23:00.000 | 24 | 24 | 00:24 |
| IDXXX13 | 245825658 | 245826849 | 2019-01-17 19:23:00.000 | 2019-01-17 21:30:00.000 | 127 | 127 | 02:07 |
+------------+-----------+-----------+-------------------------+-------------------------+------------------+--------------+---------------+