You can reference variables within variables.
e.g.
# group_vars/all
---
apple: JameslikesApples
banana: IwentToSanFrancisco
# group_vars/thing1
---
basket: {{ apple }}
# group_vars/thing2
---
basket: {{ banana }}
Then, you can reference {{ basket }} in your playbook or template:
# site.yml
---
tasks:
- name: my basket is cool
debug: msg="My basket says, {{ basket }}"
Which would translate to
For all hosts in group `thing1`: "My basket says, JameslikesApples"
For all hosts in group `thing2`: "My basket says, IwentToSanFrancisco"
On Thursday, May 19, 2016 at 1:23:37 PM UTC-4, Pr0fess0rM wrote:
>
> Hey guys,
>
> I have a variable {{ basket }} and it has a string for contents. The
> contents will change every time I run the playbook and I need a way to
> translate the contents of the basket, let's say "apple" to another name,
> let's say "JameslikesApples". But if the contents were "banana" it would
> have a completely different translation like "IwentToSanFrancisco".
>
> I've made a dictionary declaring "apple: 'JameslikesApples'" and on the
> next line: "banana: 'IwentToSanFrancisco'". I need to be able to reference
> "JameslikesApples" in a shell command and I just can't see a way around it.
> I've tried {{ {{ basket }} }} but Ansible doesn't accept the quadruple
> braces.
>
> Any and all help is appreciated!
>
--
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/18670592-8473-4687-b87a-41bf97448bfa%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.