On Tuesday, 25 September 2018 17.30.53 CEST eric.b.hymowitz via Ansible Project 
wrote:
> Greetings.
> 
> I feel like I've done this before, but for some reason, I can't figure it 
> out.
> 
> I've got two hashes defined.
> 
> password_change:
>   cobbler: [ ebhpw ]
>   cougar: [ ehymowitz ]

If you don't understand the brackets, why are you using them here?


> password_groups:
>   ebhpw: ehymowitz
> 
> Then I've got a play.
> 
>   - name: eric testing 9
>     debug:
>       msg: "it worked!!!! variable is {{password_change.cobbler}}"
>     when:
>       - password_change.cobbler is defined
> 
> This works:
> 
> TASK [eric testing 9] 
> ok: [gs-444-e10285] => {
>     "msg": "it worked!!!! variable is [u'ebhpw']"
> }
> 
> I don't fully understand what the brackets and the u are for.

List(array) in Ansible can be written in two ways.

myvar: ["one","two"]

or

myvar:
  - one
  - two

u is Pythons way of saying that the element in the list is unicode.


> But I think 
> that's getting in my way.  Because now I'm trying to do this:

Then you shouldn't use them in the first place.


>   - name: eric testing 9
>     debug:
>       msg: "it worked!!!! variable is {{password_change.cobbler}}"
>     when:
>      - password_change.cobbler is defined
>      - password_groups[password_change.cobbler] is defined
> 
> and it fails.
> 
> TASK [eric testing 9] 
> skipping: [gs-444-e10285]
> 
> So what am I missing?  It knows what password_change.cobbler is ("ebhpw") , 
> and it knows what password_groups[ebhpw] is ("ehymowitz"), so why I can't I 
> properly test for the value of password_groups[password_change.cobbler] ?

password_change.cobbler is not "ebhpw" it's list since you have the values 
between [], but password_change.cobbler.0 does contain "ebhpw"


-- 
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/2355499.xP609LUTeS%40x1.
For more options, visit https://groups.google.com/d/optout.
  • [ansible-pro... eric.b.hymowitz via Ansible Project
    • Re: [an... Kai Stian Olstad
      • RE:... 'Hymowitz, Eric B. (GSFC-444.0)[KBRwyle]' via Ansible Project

Reply via email to