i’m trying to migrate my Oracle installation from Puppet to Ansible. As i need severyl ORACLE_HOME on one server i have defned the following dictionary variable:
I need to loop over the dictionary (oracle_db_homes) to unpack the files (installation_files) for each defined ORACLE_HOME into a directory (unpack_directory).
i'm trying to migrate my Oracle installation from Puppet to Ansible. As i need
severyl ORACLE_HOME on one server i have defned the following dictionary
variable:
I need to loop over the dictionary (oracle_db_homes) to unpack the files
(installation_files) for each defined ORACLE_HOME into a directory
(unpack_directory).
tasks:
- name: Do clever stuff
command: echo {{item.key}}: Oracle version {{item.value.version}} goes into {{item.value.path}}
with_dict: oracle_db_homes
But your data structure looks a bit odd to me: Does each entry in
oracle_db_homes need to have a name? If not, you can define it as an
array rather than a dict/hash:
Thanks for your answer. The name is needed as I need to reference it from another data structure. My problem is really not how to loop over a dict. My problem is the array installation_files where I need to loop additionally.
I need to unpack the installation files for every home
thanks a lot for you help. My first problem is solved :-).
Let me try to explain why i think i need the “dbhome_1” and “dbhome_2”. If one of you guys has a solution for this also than my migration to Ansible can go one.
Second Problem:
I have several databases on one host so i wanted to define another variable like this:
oracle_databases:
DB1:
dbhome: dbhome_1
… some other stuff…
DB2:
dbhome: dbhome_1
DB3:
dbhome: dbhome_2
So my idea (like i do it in Puppet) is to use the value of oracle_database.dbhome to reference to oracle_db_home[dbhome].path.
I stand corrected, it does seem you can use with_subelements with a dictionary. The following (on ansible 1.8-devel) will loop through all the installation_files