Re: [ansible-project] interpolation of loop variables

2024-03-19 Thread Rob Wagner
Got it, I’ll use the lookup. Thanks Brian > On Mar 18, 2024, at 10:36 AM, Brian Coca wrote: > > `vars` was undocumented and for internal use, we stopped using it > internally but have been unable to remove it (and save many resources) > because people keep using(abusing) it. > > Soon we will

Re: [ansible-project] interpolation of loop variables

2024-03-18 Thread Brian Coca
`vars` was undocumented and for internal use, we stopped using it internally but have been unable to remove it (and save many resources) because people keep using(abusing) it. Soon we will have 'variable deprecation' which will allow us to start removing things like these, `vars` has long been the

Re: [ansible-project] interpolation of loop variables

2024-03-16 Thread Rob Wagner
Hey Brian - any concerns with assert: that: item in vars Short and sweet! Rob On Fri, Mar 15, 2024 at 3:03 PM Brian Coca wrote: > also varnames lookup > > -- > You received this message because you are subscribed to a topic in the > Google Groups "Ansible Project" group. > To unsubscribe fr

Re: [ansible-project] interpolation of loop variables

2024-03-15 Thread Brian Coca
also varnames lookup -- 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-project+unsubscr...@googlegroups.com. To view this discussion on the web visit h

Re: [ansible-project] interpolation of loop variables

2024-03-15 Thread Brian Coca
You can also use the vars lookup: lookup('vars', item), which has broader scope over hostvars. -- -- Brian Coca (he/him/yo) -- You received this message because you are subscribed to the Google Groups "Ansible Project" group. To unsubscribe from this group and stop receiving emails fr

Re: [ansible-project] interpolation of loop variables

2024-03-14 Thread 'Rowe, Walter P. (Fed)' via Ansible Project
In the first loop assert is evaluating that 'item' itself is defined. In the second loop assert is evaluating whether a variable who's name is stored in 'item' is defined. % cat foo.yml --- - hosts: localhost gather_facts: no become: no tasks: - name: without templating asser

Re: [ansible-project] interpolation of loop variables

2024-03-14 Thread Rob Wagner
Hey Todd - apologies, I don't understand your comment. Hey Walter - yes, you are correct. To elaborate on the use case. FIrst task in my playbooks confirms the user provided all the expected/required variables. I iterate over the list of variables and make sure they are defined with assert. Th

Re: [ansible-project] interpolation of loop variables

2024-03-14 Thread 'Rowe, Walter P. (Fed)' via Ansible Project
I sense that "with templating" does as expected? % ansible --version ansible [core 2.16.4] config file = None configured module search path = ['/Users/wrowe/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules'] ansible python module location = /opt/homebrew/lib/python3.11/s

Re: [ansible-project] interpolation of loop variables

2024-03-13 Thread Todd Lewis
Maybe it will facilitate understanding what's going on if we name things what they really are: --- - hosts: localhost gather_facts: no tasks: - name: Strings in a loop are indeed defined ignore_errors: true assert: that: item is defined loop: - RandomStringA -

[ansible-project] interpolation of loop variables

2024-03-13 Thread rjwagn...@gmail.com
Hi all - I recently upgraded to Ansible core 2.15, and started hitting "Conditional is marked as unsafe, and cannot be evaluated." As discussed at https://docs.ansible.com/ansible/latest/porting_guides/porting_guide_9.html, I removed templating from when and assert. All seemed fine, but then