santaclaus 发表于 2018-7-30 07:30:03

Ansible之九:条件语句

tasks:  - command: /bin/false
  register: result      #将命令执行的结果传递给result变量
  ignore_errors: True    #忽略错误
  - command: /bin/something
  when: result|failed    #如果注册变量的值 是任务failed则返回true
  - command: /bin/something_else
  when: result|success    #如果注册变量的值是任务success则返回true
  - command: /bin/still/something_else
  when: result|skipped    #如果注册变量的值是任务skipped则返回true
  - command: /bin/foo
  when: result|changed    #如果注册变量的值是任务changed则返回true
页: [1]
查看完整版本: Ansible之九:条件语句