How to put period between two variables

So this will print what I want:

  • debug:
    msg: “{{ groups.tag_Name_shibboleth_aws_dev1[0] }}”

But I’m using a with_items and need something like this:

  • { host: ‘tag_Name_shibboleth_aws_dev1’, othervar: ‘blah’ }

  • debug:
    msg: “{{ groups.item.host[0] }}”

Joining the two like so doesn’t work:

“{{ groups + ‘.’ + item.host }}”

How do I do this?

Thanks,

Kenton Brede

Use the actual join filter:

"{{ [ groups, '.', item.host | join] }}"

https://docs.ansible.com/ansible/playbooks_filters.html

Johannes

You are looking for the "bracket notation", as described here:
http://docs.ansible.com/ansible/playbooks_variables.html#what-makes-a-valid-variable-name

So, this should work in your example:
"{{ groups[item.host][0] }}"

Cheers,
Marko
CONFIDENTIALITY NOTICE: This message is the property of International Game Technology PLC and/or its subsidiaries and may contain proprietary, confidential or trade secret information. This message is intended solely for the use of the addressee. If you are not the intended recipient and have received this message in error, please delete this message from your system. Any unauthorized reading, distribution, copying, or other use of this message or its attachments is strictly prohibited.