Reputation: 1519
I have a ansible playbook with below tasks and when I run it, I get an error:
tasks:
- shell: timeout 5 ps aux | grep app
register: result
ignore_errors: True
- name: Run your shell command
shell: "(ssh -o StrictHostKeyChecking=no abc.com 'ls -1 /var/lib/jenkins/workspace/copy/stuff/*' | parallel -j20 'scp -o StrictHostKeyChecking=no abc.com:{} /data/records/')"
when: result.rc != 124 && result.rc != 0
Error is:
{"msg": "The conditional check 'result.rc != 124 && result.rc != 0' failed. The error was: template error while templating string: unexpected char u'&' at 23. String: {% if result.rc != 124 && result.rc != 0 %} True {% else %} False {% endif %}\n\nThe error appears to have been in '/var/lib/jenkins/workspace/proc/test.yml': line 10, column 9, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n\n - name: copy files\n ^ here\n"}
Any idea what wrong I am doing here?
Upvotes: 0
Views: 3232
Reputation: 68074
Correct syntax is
when:
- result.rc != 124
- result.rc != 0
or
when: (result.rc != 124) and (result.rc != 0)
Upvotes: 2