Hi Kai, in my current release 2.3.2.0 the hash vars is undefined as well as
the lookup plugin vars.
What's more the hostvars dictionary collects only the inventories variables
(e.g. those defined in the files {host,group}_var/*)
Whereas if the variables related to a role (e.g. those defined in the
roles/*/{default,vars}/main.yml) are not gathered by the hash hostvars
The only way I found to workaround the missing vars plugin is to build the
dictionary by myself, item by item
Is there a way to retrieve the variable name string given a variable? I'd
like to build the dictionary with a loop at least.
thanks for your support
Luca
Il giorno martedì 12 marzo 2019 07:10:17 UTC+1, Kai Stian Olstad ha scritto:
>
> On 12.03.2019 02:54, fusillator wrote:
> > #not yet working in ansible release 2.3.2
> > # when: lookup('vars', item|basename, default=false)
> > #workaround see role variable confobjs in the playbook launcher
> > when: confobjs[item|basename] is defined
> > register: template_result
>
> I'm not sure I understand what you are trying to achieve, but I think
> you are looking for this
>
> hostvars[inventory_hostname][item|basename] is defined
>
>
> It's not recommended to use vars, but this also works
>
> vars[inventory_hostname][item|basename] is defined
>
>
> If you want to combine variable with a string the syntax is
>
> hostvars[inventory_hostname][myvar ~ 'my_string'] is defined
>
>
> --
> Kai Stian Olstad
>
>
>
--
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/903dc3bf-dc4f-483c-9b7a-aa4826e266b3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.