On 10. aug. 2016 16:57, Enjoy The Silence wrote:
> I've made some changes in the script. I still need some help with the
> script.
>
> Here is the updated code.
> - name: Get Hitachi Devices device details
> shell: lsscsi | grep HITACHI | awk '{print $6}'
> register: hitachiDevice
>
>
> - name: Check if the volume is partitioned
> shell: ls -l "{{ hitachiDevice.stdout }}"* | wc -l
> failed_when: hitachiDevice.rc != 1
>
>
>
> Here is the error:
> FAILED! => {"changed": true, "cmd": "ls -l \"/dev/sdg\"* | wc -l", "delta":
> "0:00:00.010330", "end": "2016-08-10 17:35:34.819617", "failed": true,
> "failed_when_result": true, "rc": 0, "start": "2016-08-10 17:35:34.809287",
> "stderr": "", "stdout": "1", "stdout_lines": ["1"], "warnings": []}
As the message say "failed_when_result": true, so you failed_when
triggered. rc = 0 is OK and rc > 0 is an ERROR.
So for you failed_when to make sense it should be != 0.
I also recommend moving the failed_when to the "Get Hitachi Devices
device details" task, since it is that task that fails it will be more
clear and you debugging would be easier.
--
Kai Stian Olstad