- 
                Notifications
    You must be signed in to change notification settings 
- Fork 258
Closed
Description
Hello,
On my setup, I always get the following error message when trying to provision a new Oracle home/DB:
TASK [opitzconsulting.ansible_oracle.oraswgi_meta : ansible-oracle Collection version] ***
Thursday 10 October 2024  18:23:12 +0300 (0:00:00.027)       0:00:02.919 ******
ok: [abc] => {
    "msg": "ansible-oracle version: 4.11.0"
}
....
TASK [opitzconsulting.ansible_oracle.orahost_meta : Calculate SGA aggregates] ***                                                                                                                   
Thursday 10 October 2024  18:23:13 +0300 (0:00:00.039)       0:00:03.892 ******                                                                                                                     
fatal: [abc]: FAILED! => {"msg": "Invalid data passed to 'loop', it requires a list, got this instead: [{'home': 'db1924_ee', 'oracle_db_name': 'db', 'oracle_db_type': 'si', 'is_contai
ner': false, 'storage_type': 'fs', 'oracle_database_type': 'multipurpose', 'redolog_size': '50m', 'redolog_groups': 3, 'datafile_dest': '/red/data', 'recoveryfile_dest': none, 'listener_nam
e': 'listener', 'listener_port': 1521, 'archivelog': true, 'force_logging': true, 'state': 'present', 'init_parameters': [{'name': 'audit_trail', 'value': 'none', 'scope': 'spfile', 'state': 'pres
ent'}, {'name': 'processes', 'value': '800', 'scope': 'spfile', 'state': 'present', 'dbca': false}, {'name': 'control_management_pack_access', 'value': 'none', 'scope': 'both', 'state': 'present'}
, {'name': 'control_file_record_keep_time', 'value': '30', 'scope': 'both', 'state': 'present'}, {'name': 'db_files', 'value': '200', 'scope': 'spfile', 'state': 'present'}, {'name': 'deferred_seg
ment_creation', 'value': 'false', 'scope': 'both', 'state': 'present'}, {'name': 'filesystemio_options', 'value': 'setall', 'scope': 'spfile', 'state': 'present'}, {'name': 'job_queue_processes', 
'value': '20', 'scope': 'both', 'state': 'present'}, {'name': 'log_archive_dest', 'value': '/red/archlogs/db/admin/db/arch', 'scope': 'both', 'state': 'present'}, {'name': 'log_buffer', '
value': '64m', 'scope': 'spfile', 'state': 'present'}, {'name': 'pga_aggregate_target', 'value': '200m', 'scope': 'both', 'state': 'present'}, {'name': 'sga_target', 'value': '2048m', 'scope': 'sp
file', 'state': 'present'}, {'name': 'recyclebin', 'value': 'off', 'scope': 'spfile', 'state': 'present'}, {'name': 'streams_pool_size', 'value': '152m', 'scope': 'spfile', 'state': 'present'}, {'
name': '_cursor_obsolete_threshold', 'value': '1024', 'scope': 'spfile', 'state': 'present'}, {'name': 'open_cursors', 'value': '500', 'scope': 'both', 'state': 'present', 'dbca': false}, {'name':
 'diagnostic_dest', 'value': '/red/apps/oracle', 'scope': 'both', 'state': 'present'}]}]\n. Hint: If you passed a list/dict of just one element, try adding wantlist=True to your lookup invo
cation or use q/query instead of lookup."}                                                                                                                                                          
The issue I think stems from the way the loop is defined.
loop: |
  {{ (( oracle_databases | default ([]) | selectattr('init_parameters','defined') )
  + ( oracle_asm_instance | default ([]) )) | lower }}
If I replace lower with list (or get rid of the lower filter), it's working (of course, the conditions which assume the parameter name is in lowercase are affected).
Apparently, on my ansible 2.16.6, the lower filter (https://jinja.palletsprojects.com/en/3.1.x/templates/#jinja-filters.lower) converts everything to a string and the loop gets confused. For example, for:
- debug:
    msg: |
      {{ (( oracle_databases | default ([]) | selectattr('init_parameters','defined') )
      + ( oracle_asm_instance | default ([]) )) | lower | type_debug }}
- debug:
    msg: |
      {{ (( oracle_databases | default ([]) | selectattr('init_parameters','defined') )
      + ( oracle_asm_instance | default ([]) )) | type_debug }}
I get the following output:
Thursday 10 October 2024  20:38:05 +0300 (0:00:00.040)       0:00:05.617 ******
ok: [abc] => {
    "msg": "str\n"
}
TASK [opitzconsulting.ansible_oracle.orahost_meta : debug] *********************
Thursday 10 October 2024  20:38:05 +0300 (0:00:00.061)       0:00:05.679 ******
ok: [abc] => {
    "msg": "list\n"
}
I'm not sure if this happens on my setup only or it's something which may affect others as well. Any thoughts on this?
Thanks!