using regex in jinja 2 for ansible playbooks

后端 未结 7 2053
北海茫月
北海茫月 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 07:04

    This is rather ugly, but it works as of 1.6.

    {% if server|regex_replace('.*thinking.*','matched') == 'matched' %}
      {% set ssl_certificate = 'akash' %}
    
    {% elif server|regex_replace('.*sleeping.*','matched') == 'matched' %}
       {% set ssl_certificate = 'akashthakur' %}
    {% endif %}
    
    0 讨论(0)
提交回复
热议问题