Furthering Todd's message about needing more colons:
% cat foo.yml
---
- name: list to dict
hosts: localhost
become: false
gather_facts: false
vars:
backups:
mongodb:
postgresql:
- sonarqube
- other
/opt:
/etc:
tasks:
-
It is important to understand the structure of the data. Your backups variable
defines a list, not a dictionary.
% cat foo.yml
---
- name: list to dict
hosts: localhost
become: false
gather_facts: false
vars:
backups:
- mongodb
- postgresql:
-
Needs more colons:
backups:
mongodb:
postgresql:
- sonarqube
- other
"/opt":
"/etc":
On 2/6/24 9:57 AM, Brian Coca wrote:
backups.postgresql does not exist, it is backups[1]
To get what you want the data would have to look
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"
--
--
Brian Coca (he/him/yo)
--
You
i have this:
backups:
- mongodb
- postgresql:
- sonarqube
- other
- /opt
- /etc
later i use it in template task:
- name: template backup script out
template:
src: backup-script.sh.j2
dest: /root/backup.sh
mode: 755
my