No one for this?
I'm also getting this problem, it'd be nice if we could get some
clarification.
Thanks!
On Tuesday, November 29, 2016 at 1:06:46 AM UTC+1, Guillaume Abrioux wrote:
>
> Hi,
>
> I would like to define a dict in group_vars/all.yml where a key inside
> this dict would consist of a fixed string concatened to the result of : "{{
> hostvars[inventory_hostname]['ansible_hostname'] }}".
>
> This should looks like following:
>
> ✘ root@lab:~/playbook# cat group_vars/all.yml
> ---
> my_dict:
> "something_{{ hostvars[inventory_hostname]['ansible_hostname'] }}":
> "key1": "value1"
> "key2": "value2"
>
>
>
> ✔ root@lab:~/playbook# cat roles/test/tasks/test.yml
> ---
> - name: print my_dict
> debug:
> msg: "{{ my_dict }}"
>
>
>
> ✔ root@lab:~/playbook# ansible-playbook -i hosts site.yml
>
> PLAY [all]
> *********************************************************************
>
> TASK [setup]
> *******************************************************************
> ok: [127.0.0.1]
>
> TASK [test : print my_dict]
> ****************************************************
> ok: [127.0.0.1] => {
> "msg": {
> "something_{{ hostvars[inventory_hostname]['ansible_hostname']
> }}": {
> "key1": "value1",
> "key2": "value2"
> }
> }
> }
>
> But as you can see, when I print it with a simple debug task, it hasn't
> the expected behaviour.
> I was more thinking to get something as following :
>
> TASK [test : print my_dict]
> ****************************************************
> ok: [127.0.0.1] => {
> "msg": {
> "something_mygreathostname": {
> "key1": "value1",
> "key2": "value2"
> }
> }
> }
>
> Do you have an idea how could I do it ?
>
> Thanks,
>
> Guillaume
>
--
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/8d5502b1-423f-4501-8a34-567a25edc3ed%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.