Ansible“until”无法匹配字符串

时间:2016-05-12 03:10:34

标签: ansible ansible-playbook

我正在尝试使用“until”,

显示命令的输出
 - name: Waiting for stack to Deploy...
   shell: '{{ creds }} heat event-list {{stack_name}}'
   register: waiting_for_stack
   until: waiting_for_stack.stdout.find("Stack CREATE completed successfully") or waiting_for_stack.stdout.find("CREATE_FAILED")!= -1
   retries: 10
   delay: 3
 - debug: var=waiting_for_stack.stdout_lines

我正在循环shell命令以获取堆栈的整个事件列表。但循环不起作用。它从第一次迭代退出而没有匹配条件中提供的字符串。事件列表输出看起来像这样。

ok: [10.206.41.150] => {
    "waiting_for_stack.stdout_lines": [
        "+---------------+--------------------------------------+------------------------+--------------------+----------------------+",
        "| resource_name | id                                   | resource_status_reason | resource_status    | event_time           |",
        "+---------------+--------------------------------------+------------------------+--------------------+----------------------+",
        "| stack01       | 924498f6-6498-4560-947c-fec5149b9775 | Stack CREATE started   | CREATE_IN_PROGRESS | 2016-05-12T02:55:18Z |",
        "| MCM2          | 1e6fe65d-971b-49c6-9441-dd77edd47d29 | state changed          | CREATE_IN_PROGRESS | 2016-05-12T02:55:18Z |",
        "+---------------+--------------------------------------+------------------------+--------------------+----------------------+"
    ]
}

我做错了什么,或者有更好的方法来执行此操作?我使用的是ansible 1.7版。

1 个答案:

答案 0 :(得分:0)

until: ("Stack CREATE completed successfully" in waiting_for_stack.stdout) or ("CREATE_FAILED" in  waiting_for_stack.stdout)

这份工作对我而言。