combining register: with with_items: fails

Hi List,

I’m trying this (Simplified version):

- name: Oracle | Figure out the paths that exist here
action: shell ls /opt/oracle/product/
register: oracle_versions

- name: Oracle | Now find the specific admin paths
action: shell find /opt/oracle/product/${item} -type d -name admin | grep -i network
with_items:
- ${oracle_versions.stdout_lines}
register: oracle_admin_path

But this fails, it does not set the ${oracle_admin_path.stdout_lines} to the value’s you’d expect from the example.
Leaving out the “with_items” from the example does work however. Like so:

- name: Oracle | Now find the specific admin paths
action: shell find /opt/oracle/product/${item} -type d -name admin | grep -i network
register: oracle_admin_path

Not exactly what I want so I’m asking wether this is correct behaviour and that I just don’t understand?

Thanks,
Mark

with_items when used with register will store the result in an array, it doesn’t fail at all.

check what the value of the thing you registered by using the debug module and running in “-v” mode, and you should see what you get.

Wrong choice of words. sorry. I did mention that I probably did not understand :wink:

Do you mean like this?

- name: Oracle | Ophalen welke versie’s van Oracle er zijn
action: shell ls /opt/oracle/product/
register: oracle_versions

- name: Oracle | Admin pad uitvogelen
action: shell find /opt/oracle/product/ -type d -name admin | grep -i network
with_items:
- ${oracle_versions.stdout_lines}
register: oracle_admin_path

- name: Oracle | DEBUG!!!

action: debug msg=${oracle_admin_path} fail=yes

Because that just gives me:

TASK: [Oracle | DEBUG!!!] *********************
ESTABLISH CONNECTION FOR USER: mmaas on PORT 22 TO taixkitty
failed: [taixkitty] => {“failed”: true, “item”: “”}
msg: {msg:

FATAL: all hosts have already failed – aborting

Thanks,
Mark

looks like you have some spaces in your shell command and it just didn’t work.

The FAIL is of course because you asked it to fail :slight_smile:

I would consider writing an “oracle_facts” module instead.