Skip to content

Instantly share code, notes, and snippets.

@leonj1
Created December 19, 2018 19:41
Show Gist options
  • Save leonj1/7db2c37152a7fd1efb141b5e11fd7567 to your computer and use it in GitHub Desktop.
Save leonj1/7db2c37152a7fd1efb141b5e11fd7567 to your computer and use it in GitHub Desktop.
# hostvars where each host includes its private ip
"_meta": {
"hostvars": {
"node2.amazonaws.com": {
"private_ip": "10.1.0.77"
},
"node1.amazonaws.com": {
"private_ip": "10.1.0.64"
}
}
}
# Task trying to create 10.1.0.77;10.1.0.64
- name: Create concatenated string of private ips
set_fact:
my_joined_list: "{{ hostvars[item]['private_ip'] | join(';') }}"
with_items: "{{ play_hosts }}"
# instead it creates this garbage
TASK [debug] ***********
ok: [node1.amazonaws.com] => {
"my_joined_list": "1;0;.;1;.;0;.;6;4"
}
ok: [node2.amazonaws.com] => {
"my_joined_list": "1;0;.;1;.;0;.;6;4"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment