On Sun, 16 May 2021 22:51:02 +0200 Vladimir Botka <[email protected]> wrote:
> On Sun, 16 May 2021 01:35:46 -0700 > Scott Mcdermott <[email protected]> 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 hostvars[target].ipnet is defined > > set_fact: > > subnet: '{{ > > (project == project_bake) | ternary( > > subnet_bake, determined_subnet > > )}}' > > What value of *subnet* do you want to set when '(project != > project_bake) and (determined_subnet is undefined)' ? When the corresponding alternatives shall always be defined the defaults can't hurt, e.g. - set_fact: subnet: '{{ (project == project_bake)| ternary(subnet_bake|default(None), determined_subnet|default(None) }}' In this case test sanity first - fail: msg: Variable undefined when: ((project == project_bake) and (subnet_bake is undefined)) or ((project != project_bake) and (determined_subnet is undefined)) -- Vladimir Botka -- 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 view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/20210516232609.07905048%40gmail.com.
pgpoxkdxJcDpo.pgp
Description: OpenPGP digital signature
