I have a json content on Consul that I import to my playbook. The json contains account names and passwords:
{
"account_1": "password_1",
"account_2": "password_2",
"account_3": "password_3"
}
After registering it to variable I wish to be able to use every user name and password. Since these jsons may contain different numbers of entries, I was hoping I could use with_items for this. Can someone help me out?
Debugging the whole json works with no issues:
TASK [debug] **************************************************************************
ok: [localhost] => {
"accountsDataFromConsul.data.Value": {
"account_1": "password_1",
"account_2": "password_2",
"account_3": "password_3"
}
}
I try to get to individual entries (user names and passwords). I tried the below code, but it returned only user names:
- debug:
var: item
with_items: "{{accountsDataFromConsul.data.Value}}"
TASK [debug] ******************************************************************************
ok: [localhost] => (item=account_1) => {
"item": "account_1"
}
ok: [localhost] => (item=account_2) => {
"item": "account_2"
}
ok: [localhost] => (item=account_3) => {
"item": "account_3"
}