Re: [ansible-project] Evaluating variables in tasks

58 views
Skip to first unread message
Message has been deleted

Michael DeHaan

unread,
Dec 15, 2014, 6:54:13 AM12/15/14
to ansible...@googlegroups.com
Hi, I'm a little confused by the above, in particular this part:

stderr: kinit: Keytab contains no suitable keys for krb_gdc_...@MSGREEN.DOM while getting initial credentials

This looks like krb_gdc_...@MSGREEN.DOM is being substituted where you have {{ krb_hostname }} correctly.

Can you elaborate on where the problem is in your view?

Thanks!

On Sat, Dec 13, 2014 at 12:14 AM, Eric Van Steenbergen <vs....@gmail.com> wrote:
Hi all,

I'm having an issue with a variable not providing the value it should. I'm creating a variable name dynamically and save it in a variable. When calling that variable I get what's stored in it which makes sense but I want the value (variable name) substituted by its value which is stored in a file. 

I've got my problem solved partially. So I have:

in my var file:


krb_hostname: "krb_{{ inventory_hostname_short | regex_replace('-', '_') }}"

krb_gdc_in1_nbapi01: GDC-IN1-NBAPI01\$\@MSGREEN.DOM
krb_gdc_in1_nbcl01besv01: GDC-IN1-NBC1BV1\$\@MSGREEN.DOM
krb_gdc_in1_nbmess01: GDC-IN1-NBMESS1\$\@MSGREEN.DOM
krb_gdc_in1_nbife01: GDC-IN1-NBIFE01\$\@MSGREEN.DOM
krb_gdc_in1_nbfeed01: GDC-IN1-NBFEED1\$\@MSGREEN.DOM
krb_gdc_in1_nbfe01: GDC-IN1-NBFE01\$\@MSGREEN.DOM
krb_gdc_in1_nbfe02: GDC-IN1-NBFE02\$\@MSGREEN.DOM
krb_gdc_in1_nbvodb01: GDC-IN1-NBVODB1\$\@MSGREEN.DOM

My task:

- name: Run kinit -k with hostname from varfile (tag = kerberos)
  shell: kinit -k {{ krb_hostname  }}
  tags: 
    - integration

But when I run it, the result is this:

failed: [gdc-co-test01] => {"changed": true, "cmd": "kinit -k krb_gdc_co_test01", "delta": "0:00:00.011155", "end": "2014-12-12 13:41:04.489263", "rc": 1, "start": "2014-12-12 13:41:04.478108"}
stderr: kinit: Keytab contains no suitable keys for krb_gdc_...@MSGREEN.DOM while getting initial credentials

So the variable gets created correctly but krb_hostname is not being substituted by the value of the generated variable, in the example krb_gdc_co_test01 which is a variable in my var file and holds GDC-CO-TEST01\$\@MSGREEN.COM as value.

Any help is greatly appreciated.

Kind regards,

Eric

--
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-proje...@googlegroups.com.
To post to this group, send email to ansible...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/beb7f33e-6741-4950-a0c2-c3b0f27cc1aa%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Message has been deleted

Michael DeHaan

unread,
Dec 15, 2014, 10:41:30 AM12/15/14
to ansible...@googlegroups.com
Sorry for being dense, but these two values look the same to me:

 krb_gdc_co_test01 
 krb_gdc_co_test01

What part of that is the incorrect part?

Thanks!





On Mon, Dec 15, 2014 at 10:39 AM, Eric Van Steenbergen <vs....@gmail.com> wrote:
Hello Michael,

Thank you for your reply. That's the main issue I'm facing. The variable krb_hostname gets substituted by the value krb_gdc_co_test01 while I would like to see the value of that variable krb_gdc_co_test01 which I defined in the vars file.

Kind regards,

Eric


On Monday, December 15, 2014 12:54:13 PM UTC+1, Michael DeHaan wrote:
Hi, I'm a little confused by the above, in particular this part:

stderr: kinit: Keytab contains no suitable keys for krb_gdc_...@MSGREEN.DOM while getting initial credentials

This looks like krb_gdc_co_test01@MSGREEN.DOM is being substituted where you have {{ krb_hostname }} correctly.
Message has been deleted

Tomasz Kontusz

unread,
Dec 15, 2014, 1:32:43 PM12/15/14
to ansible...@googlegroups.com
Try {{ hostvars[inventory_hostname][variable_with_variable_name] }}

Eric Van Steenbergen <vs....@gmail.com> napisał:
Hi,

Not at all! The values are the same indeed but my problem is exactly that ;-). What I want to achieve is this:

I've got a variable (krb_hostname) that gets dynamically build by concatenating text and the inventory_hostname. Since there are '-' in the hostname I'm substituting t(hem by '_'. That value of krb_hostname is a variable name that I define in a var file so I would like to evaluate the value of krb_hostname instead of presenting the value itself in order to have the final value GDC-CO-TEST01\$\@MSGREEN.DOM. Does that reasoning make any sense?

Kind regards,

Eric 


--
Wysłane za pomocą K-9 Mail.
Reply all
Reply to author
Forward
Message has been deleted
0 new messages