I am having a variable with the following value:
name_prefix: stage-dbs
I am having a task in my playbook which will have to check this variable and see if it contains *-dbs , if the condition is met then it should process. I wrote something like this :
- 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??
What regex pattern should be used or how to use a regex here ?
No need to use regex for pattern searching. You can use search like this:
when: name_prefix | search("stage-dbs")
It will definitely work.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With