Hi all,

I've come across an issue which might be a showstopper for me; either way I
wouldn't mind some advice.

My aim is to lookup in a vaulted file the name of a variable that is based
around the hostname of the server. My servers have hyphens in the hostname.

I have got something like this:

- name: Copy private key
copy:
content: "{{ ansible_hostname }}_private_key"
dest: /root/.ssh/id_rsa

And in my vaulted vars file a variable called "server-name_private_key".

Now since variables cannot have hyphens in them, but my server hostname
does, how can I lookup the variable dynamically based on which host the
task is running on?

I could always have a separate task for each host and explicitly define the
variable but keeping it short is my goal.

Thanks
Richard

-- 
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 post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CAAkoFG%3DLBMa6pnJcxyjrPOyeVszw%2B1N%2BtabYT%2BL1N32cNZ98tg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to