是否有一些等效于“failed_when"的 Ansible?为了成功 [英] Is there some Ansible equivalent to "failed_when" for success

查看:25
本文介绍了是否有一些等效于“failed_when"的 Ansible?为了成功的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

查看有关错误处理的文档Ansible 错误处理

我只看到一种使配置失败的方法fail_when,我想知道是否有任何方法可以做到这一点.

看起来像这样:

<块引用>

- 名称:ping pong redis命令:redis-cli ping注册:command_resultsuccess_when:command_result.stderr 中的‘PONG’"

谢谢.

解决方案

我想也许 assert module 就是你想要的.

<块引用>

1.5 版的新功能

示例:

- assert: { that: ansible_os_family != 'RedHat'";}

Looking at the documentation about error handling Ansible error handling

I only see a way to fail the provisioning fail_when, i am wondering if there is any way to do the oposite.

something that looks like this:

- name: ping pong redis
  command: redis-cli ping
  register: command_result
  success_when: "'PONG' in command_result.stderr"

Thanks.

解决方案

I think maybe assert module is what you want.

New in version 1.5

Examples:

- assert: { that: "ansible_os_family != 'RedHat'" }

这篇关于是否有一些等效于“failed_when"的 Ansible?为了成功的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆