简体   繁体   English

评估何时有条件

[英]evaluation of when condition in ansible

I have a playbook that uses multiple hostgroup like (appserver,app01server,dbserver,db01server) and if the hostgroup contains db* then the condition should execute. 我有一本剧本,它使用多个主机组,例如(appserver,app01server,dbserver,db01server),如果主机组包含db *,则条件应执行。 I have written something like this : 我写了这样的东西:

- name: status of the app
  shell: echo "Hello World"
  when: ansible_host == "db*"

What regex pattern should be used or how to use a regex here ? 这里应该使用哪种正则表达式模式或如何使用正则表达式?

Try db\\w+ 尝试db \\ w +

- name: status of the app
  shell: echo "Hello World"
  when: ansible_host == "db\w+"

You can test with regex101 . 您可以使用regex101进行测试。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM