backups:
mongodb:
postgresql:
- sonarqube
- other
"/opt":
"/etc":
backups.postgresql does not exist, it is backups[1]
To get what you want the data would have to look like this:
backups:
mongodb
postgresql:
- sonarqube
- other
"/opt"
"/etc"
-- Todd
% cat foo.yml
---
- name: list to dict
hosts: localhost
become: false
gather_facts: false
vars:
backups:
- mongodb
- postgresql:
- sonarqube
- other
- /opt
- /etc
tasks:
- debug: var=backups
% ansible-playbook -i localhost, foo.yml
PLAY [list to dict] ****************************************************************************************************
TASK [debug] ***********************************************************************************************************
ok: [localhost] => {
"backups": [
"mongodb",
{
"postgresql": [
"sonarqube",
"other"
]
},
"/opt",
"/etc"
]
}
PLAY RECAP *************************************************************************************************************
localhost : ok=1 changed=0 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0
--
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 ansible-proje...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/d9bd0bf0-11b4-45db-8b94-2cd445a093a9n%40googlegroups.com.
% cat foo.yml
---
- name: list to dict
hosts: localhost
become: false
gather_facts: false
vars:
backups:
mongodb:
postgresql:
- sonarqube
- other
/opt:
/etc:
tasks:
- debug: var=backups
- debug: var=backups.postgresql
PLAY [list to dict] ****************************************************************************************************
TASK [debug] ***********************************************************************************************************
ok: [localhost] => {
"backups": {
"/etc": null,
"/opt": null,
"mongodb": null,
"postgresql": [
"sonarqube",
"other"
]
}
}
TASK [debug] ***********************************************************************************************************
ok: [localhost] => {
"backups.postgresql": [
"sonarqube",
"other"
]
}
PLAY RECAP *************************************************************************************************************
localhost : ok=2 changed=0 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/7910AFC7-18E1-4952-B8B9-F764461E0405%40nist.gov.