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.DOMkrb_gdc_in1_nbcl01besv01: GDC-IN1-NBC1BV1\$\@MSGREEN.DOMkrb_gdc_in1_nbmess01: GDC-IN1-NBMESS1\$\@MSGREEN.DOMkrb_gdc_in1_nbife01: GDC-IN1-NBIFE01\$\@MSGREEN.DOMkrb_gdc_in1_nbfeed01: GDC-IN1-NBFEED1\$\@MSGREEN.DOMkrb_gdc_in1_nbfe01: GDC-IN1-NBFE01\$\@MSGREEN.DOMkrb_gdc_in1_nbfe02: GDC-IN1-NBFE02\$\@MSGREEN.DOMkrb_gdc_in1_nbvodb01: GDC-IN1-NBVODB1\$\@MSGREEN.DOMMy task:- name: Run kinit -k with hostname from varfile (tag = kerberos)shell: kinit -k {{ krb_hostname }}tags:- integrationBut 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 credentialsSo 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.
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/f11c7284-c35f-4fb5-a340-01bd41e67826%40googlegroups.com.
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