Nis*_*ngh 6 regex ansible ansible-playbook
我有一个具有以下值的变量:
name_prefix: stage-dbs
Run Code Online (Sandbox Code Playgroud)
我在我的剧本中有一个任务,必须检查这个变量并查看它是否包含*-dbs,如果条件满足则应该处理.我写了这样的东西:
- name: Ensure deployment directory is present
file:
path=/var/tmp/deploy/paTestTool
state=directory
when: name_prefix =="*-dbs" # what condition is required here to evaulate the rest part of variable??
Run Code Online (Sandbox Code Playgroud)
应该使用什么正则表达式模式或如何在这里使用正则表达式?
Tho*_*aux 18
不确定search今天是否存在过滤器?
when: name_prefix | regex_search("^stage-dbs(.*)$")
Run Code Online (Sandbox Code Playgroud)
koh*_*ohi 14
无需使用正则表达式进行模式搜索.您可以使用以下搜索:
when: name_prefix | search("stage-dbs")
Run Code Online (Sandbox Code Playgroud)
它肯定会奏效.
| 归档时间: |
|
| 查看次数: |
15886 次 |
| 最近记录: |