-
-
Save arnoldyahad/971e96005dc6223e66a21d5e9b845725 to your computer and use it in GitHub Desktop.
ansible concatenate item / element of list of dictionaries / dict
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
- name: concatenate list elements of dictionary | |
hosts: all | |
gather_facts: no | |
vars: | |
users: | |
- username: alice | |
email: alice@example.com | |
- username: bob | |
email: bob@example.com | |
tasks: | |
- debug: | |
msg: "{{ users | map('json_query','email') | list | join('; ') }}" | |
delegate_to: localhost |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ ansible-playbook playbooks/ansible_concatenate-list-of-dict.yml | |
PLAY [concatenate list elements of dictionary] ***************************************************************************************************************************************** | |
TASK [debug] *************************************************************************************************************************************************************************** | |
ok: [your_host -> localhost] => { | |
"msg": "alice@example.com; bob@example.com" | |
} | |
PLAY RECAP ***************************************************************************************************************************************************************************** | |
your_host : ok=1 changed=0 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment