[ansible-project] short-circuit eval in templated string works only sometimes?

2021-05-15 Thread Scott Mcdermott
Hello, why does short circuit only works for the first two cases: - hosts: localhost become: false vars: ivar: '{{hostvars[inventory_hostname].dne}}' tasks: - debug: msg: "works: {{'foo' or dne}}" - debug: msg: "works: {{'bar' or hostvars[inventory_hostname].dne}}

Re: [ansible-project] short-circuit eval in templated string works only sometimes?

2021-05-15 Thread Vladimir Botka
On Sat, 15 May 2021 16:55:24 -0700 Scott Mcdermott wrote: > Hello, why does short circuit only works for the first two cases: > > - hosts: localhost > become: false > vars: > ivar: '{{hostvars[inventory_hostname].dne}}' > tasks: > - debug: > msg: "works: {{'foo' or dne}}" >

Re: [ansible-project] short-circuit eval in templated string works only sometimes?

2021-05-16 Thread Vladimir Botka
On Sun, 16 May 2021 08:54:29 +0200 Vladimir Botka wrote: > On Sat, 15 May 2021 16:55:24 -0700 > Scott Mcdermott wrote: > > > Hello, why does short circuit only works for the first two cases: > > > > - hosts: localhost > > become: false > > vars: > > ivar: '{{hostvars[inventory_hostname

Re: [ansible-project] short-circuit eval in templated string works only sometimes?

2021-05-16 Thread Scott Mcdermott
On Sun, May 16, 2021 at 12:23 AM Vladimir Botka wrote: > third debug task fails because the expansion of the string > "{{ ... }}" fails before the *or* expression could be evaluated. Sure, but why is it expanded at all? You're right that we can make my already-minimal test when variable Does Not

Re: [ansible-project] short-circuit eval in templated string works only sometimes?

2021-05-16 Thread Vladimir Botka
On Sun, 16 May 2021 01:35:46 -0700 Scott Mcdermott wrote: > I cannot use a default because this whole thing is relying > on whether it's defined or not later to take different actions. > the fuller example is: > > - name: determine_subnet > when: > > project == project_bake > or hostva

Re: [ansible-project] short-circuit eval in templated string works only sometimes?

2021-05-16 Thread Vladimir Botka
On Sun, 16 May 2021 22:51:02 +0200 Vladimir Botka wrote: > On Sun, 16 May 2021 01:35:46 -0700 > Scott Mcdermott wrote: > > > I cannot use a default because this whole thing is relying > > on whether it's defined or not later to take different actions. > > the fuller example is: > > > > - name:

Re: [ansible-project] short-circuit eval in templated string works only sometimes?

2021-05-16 Thread Scott Mcdermott
On Sun, May 16, 2021 at 1:51 PM Vladimir Botka wrote: > > I cannot use a default because this whole thing is relying > > on whether it's defined or not later to take different actions. > > the fuller example is: > > > > - name: determine_subnet > > when: > > > project == project_bake > >

Re: [ansible-project] short-circuit eval in templated string works only sometimes?

2021-05-16 Thread Scott Mcdermott
On Sun, May 16, 2021 at 2:26 PM Vladimir Botka wrote: > > > I cannot use a default because this whole thing is relying > > > on whether it's defined or not later to take different actions. > > > the fuller example is: > > > > > > - name: determine_subnet > > > when: > > > > project == projec

Re: [ansible-project] short-circuit eval in templated string works only sometimes?

2021-05-18 Thread Martin Krizek
On Sun, May 16, 2021 at 1:55 AM Scott Mcdermott wrote: > > Hello, why does short circuit only works for the first two cases: > > - hosts: localhost > become: false > vars: > ivar: '{{hostvars[inventory_hostname].dne}}' > tasks: > - debug: > msg: "works: {{'foo' or dne}}" >

Re: [ansible-project] short-circuit eval in templated string works only sometimes?

2021-05-18 Thread Vladimir Botka
On Tue, 18 May 2021 14:54:07 +0200 Martin Krizek wrote: > This is effectively a side-effect of functionality in Ansible's > templating engine that allows nesting variables ... FWIW, one more of this kind not mentioned yet, I think - debug: var: my_dict.a vars: my_dict: