using regex in jinja 2 for ansible playbooks

后端 未结 7 2113
北海茫月
北海茫月 2020-12-31 06:37

HI i am new to jinja2 and trying to use regular expression as shown below

{% if ansible_hostname == \'uat\' %}
   {% set server = \'thinkingmonster.com\' %}
         


        
7条回答
  •  暖寄归人
    2020-12-31 06:44

    Thanks to Steve E. hint, I've figured out a way to add regex in a template condition:

    {% if server | regex_search('thinking') %}
    ....
    {% endif %}
    

提交回复
热议问题