Dave,
You could easily just rewrite as below and it should solve your issue.

when: >
      not ansible_check_mode and (zerotier_status != "OK" or 
      zerotier_name != inventory_hostname)


On Tuesday, May 23, 2017 at 7:20:20 AM UTC-4, Dave Cottlehuber wrote:
>
> I'm getting a benign warning below: 
>
> ``` 
>  [WARNING]: when statements should not include jinja2 templating 
>  delimiters such as {{ }} or {% %}. 
>  Found: not ansible_check_mode and (zerotier_status != "OK" or 
>  zerotier_name != "{{ inventory_hostname }}") 
> ``` 
>
> In this specific case I could get away with dropping the final clause of 
> the `when` check, but does anybody have an idea how to refactor this to 
> avoid the warnings in future? I get the feeling I'm missing some very 
> obvious pattern here. 
>
> ```yaml 
> - name: zerotier | authorise this connection 
>   uri: 
>     url: https://my.zerotier.com/api/network/{{ net.zerotier.network 
>     }}/member/{{ zerotier_address }} 
>     method: POST 
>     HEADER_Authorization: "Bearer {{ net.zerotier.token }}" 
>     body_format: json 
>     body: 
>       name: "{{ inventory_hostname }}" 
>       config: 
>         authorized: true 
>     return_content: yes 
>   register: zerotier_authorisation 
>   when: not ansible_check_mode and (zerotier_status != "OK" or 
>   zerotier_name != "{{ inventory_hostname }}") 
>   tags: 
>     - zerotier 
> ``` 
>

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/529fd442-b7b0-4819-bd1e-f107218ed5d2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to