Hi On Tue, Nov 18, 2014 at 10:55:42AM -0800, Thomas Krahn wrote: > Hi All > > 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: > > oracle_app_directory=/app > oracle_db_homes: > dbhome_1: > version: 12.1.0 > path: "{{ oracle_app_directory }}/oracle/product/12.1.0/dbhome_1" > installation_files_directory: /share/oracle/12.1.0/patches > installation_files: > - linuxamd64_12c_database_1of2.zip > - linuxamd64_12c_database_2of2.zip > unpack_directory: /share/oracle/12.1.0/unpacked > dbhome_2: > version: 11.2.0 > path: "{{ oracle_app_directory }}/oracle/product/11.2.0/dbhome_1" > installation_files_directory: /share/oracle/11.2.0/patches > installation_files: > - linuxamd64_11g_database_1of2.zip > - linuxamd64_11g_database_2of2.zip > unpack_directory: /share/oracle/11.2.0/unpacked > > 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). > > How can i do that with Ansible ?
http://docs.ansible.com/playbooks_loops.html#looping-over-hashes should help. For example: 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: oracle_db_homes: - version: 12.1.0 path: "{{oracle_app_directory}}/oracle/somewhere/here" - version: 11.2.0 path: "{{oracle_app_directory}}/oracle/somewhere/else" Hope this helps -- Karl E. Jorgensen -- 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-project+unsubscr...@googlegroups.com. To post to this group, send email to ansible-project@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/20141118212945.GA25922%40hawking. For more options, visit https://groups.google.com/d/optout.