使用 when 模块执行 ansible playbook [英] Getting an while executing a ansible playbook using when module

查看:27
本文介绍了使用 when 模块执行 ansible playbook的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用 when 模块执行 playbook

Am trying to execute playbook with when module

when: rxbar.stdout | join ('') | search("foo: ") and ansible_distribution_major_version|int >= 7

出现错误:.

模板化字符串时出现模板错误:没有名为搜索"的过滤器.字符串 rxbar.stdout

Template error while templating string: no filter named 'search'. String rxbar.stdout

推荐答案

你的错误不言自明.

Template error while templating string: no filter named 'search'. String rxbar.stdout

搜索不是您在此处使用的过滤器.

search is not a filter you are using here.

在 when 中搜索的示例

Example for search in when

 - debug:
            msg: "matched pattern 2"
          when: url is search("/users/.*/resources/.*")

如果在字符串中的任何位置找到模式,则搜索成功.

search succeeds if it finds the pattern anywhere within string.

这篇关于使用 when 模块执行 ansible playbook的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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