When statements should not include jinja2 templating delimiters such as {{ }} or {% %}

1,835 views
Skip to first unread message

Prologas

unread,
Sep 1, 2017, 4:07:35 AM9/1/17
to Ansible Project
Hello,

strange output comes to my ansible console, but the task works as I expected?

- name: WildFly copy listed wars to server vm1
  copy: src={{ item }} dest=/tmp/ mode=0640 owner=wildfly group=wildfly
  when:
        - ansible_default_ipv4.macaddress == "{{ wildfly_vm1_server_macaddress }}"
  with_fileglob:
        - /tmp/wars/xxx.war
        - /tmp/wars/bbb.war

 [WARNING]: when statements should not include jinja2 templating delimiters such as {{ }} or {% %}. Found: ansible_default_ipv4.macaddress ==
"{{ wildfly_vm1_server_macaddress }}"

Thanks!


Uwe Sauter

unread,
Sep 1, 2017, 4:15:09 AM9/1/17
to ansible...@googlegroups.com
There has been a change (I think between 1.9 and 2.x). As the warning explains, you should rewrite your when statement:

when:
- ansible_default_ipv4.macaddress == wildfly_vm1_server_macaddress


> --
> 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 ansible-proje...@googlegroups.com
> <mailto:ansible-proje...@googlegroups.com>.
> To post to this group, send email to ansible...@googlegroups.com <mailto:ansible...@googlegroups.com>.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/c8dc81f5-31a0-44df-b90b-c9b8b2626226%40googlegroups.com
> <https://groups.google.com/d/msgid/ansible-project/c8dc81f5-31a0-44df-b90b-c9b8b2626226%40googlegroups.com?utm_medium=email&utm_source=footer>.
> For more options, visit https://groups.google.com/d/optout.

Message has been deleted

Uwe Sauter

unread,
Sep 1, 2017, 4:28:35 AM9/1/17
to Prologas, Ansible Project
Already did in my previous answer. You need to remove items like {{ }} or {% %}.


Am 01.09.2017 um 10:18 schrieb Prologas:
> Can you take an example of correct syntax?
>
> On Friday, September 1, 2017 at 11:15:09 AM UTC+3, Uwe Sauter wrote:
>
> There has been a change (I think between 1.9 and 2.x). As the warning explains, you should rewrite your when statement:
>
> when:
>   - ansible_default_ipv4.macaddress == wildfly_vm1_server_macaddress
>
>
> Am 01.09.2017 um 10:07 schrieb Prologas:
> > Hello,
> >
> > strange output comes to my ansible console, but the task works as I expected?
> >
> > - name: WildFly copy listed wars to server vm1
> >   copy: src={{ item }} dest=/tmp/ mode=0640 owner=wildfly group=wildfly
> >   when:
> >         - ansible_default_ipv4.macaddress == "{{ wildfly_vm1_server_macaddress }}"
> >   with_fileglob:
> >         - /tmp/wars/xxx.war
> >         - /tmp/wars/bbb.war
> >
> >  [WARNING]: when statements should not include jinja2 templating delimiters such as {{ }} or {% %}. Found:
> > ansible_default_ipv4.macaddress ==
> > "{{ wildfly_vm1_server_macaddress }}"
> >
> > Thanks!
> >
> >
> > --
> > 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 ansible-proje...@googlegroups.com
> <javascript:>
> > <mailto:ansible-proje...@googlegroups.com <javascript:>>.
> > To post to this group, send email to ansible...@googlegroups.com <javascript:> <mailto:ansible...@googlegroups.com
> <javascript:>>.
> <https://groups.google.com/d/msgid/ansible-project/c8dc81f5-31a0-44df-b90b-c9b8b2626226%40googlegroups.com?utm_medium=email&utm_source=footer
> <https://groups.google.com/d/msgid/ansible-project/c8dc81f5-31a0-44df-b90b-c9b8b2626226%40googlegroups.com?utm_medium=email&utm_source=footer>>.
>
> > For more options, visit https://groups.google.com/d/optout <https://groups.google.com/d/optout>.
>

Prologas

unread,
Sep 1, 2017, 4:29:43 AM9/1/17
to Ansible Project, uwe.sa...@gmail.com
Thanks, I will check it out soon!


On Friday, September 1, 2017 at 11:15:09 AM UTC+3, Uwe Sauter wrote:
There has been a change (I think between 1.9 and 2.x). As the warning explains, you should rewrite your when statement:

when:
  - ansible_default_ipv4.macaddress == wildfly_vm1_server_macaddress


Am 01.09.2017 um 10:07 schrieb Prologas:
> Hello,
>
> strange output comes to my ansible console, but the task works as I expected?
>
> - name: WildFly copy listed wars to server vm1
>   copy: src={{ item }} dest=/tmp/ mode=0640 owner=wildfly group=wildfly
>   when:
>         - ansible_default_ipv4.macaddress == "{{ wildfly_vm1_server_macaddress }}"
>   with_fileglob:
>         - /tmp/wars/xxx.war
>         - /tmp/wars/bbb.war
>
>  [WARNING]: when statements should not include jinja2 templating delimiters such as {{ }} or {% %}. Found:
> ansible_default_ipv4.macaddress ==
> "{{ wildfly_vm1_server_macaddress }}"
>
> Thanks!
>
>
> --
> 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 ansible-proje...@googlegroups.com

Prologas

unread,
Sep 1, 2017, 5:42:28 AM9/1/17
to Ansible Project, t.and...@gmail.com, uwe.sa...@gmail.com
Don't work:

wildfly_vm1_server_macaddress is undefined\n\nThe error appears to have been in 
>     > <mailto:ansible-project+unsub...@googlegroups.com <javascript:>>.

Prologas

unread,
Sep 1, 2017, 5:50:23 AM9/1/17
to Ansible Project, t.and...@gmail.com, uwe.sa...@gmail.com
Sorry, my bad, I mistyped the var
Reply all
Reply to author
Forward
0 new messages