I am having this playbook
---
- hosts: all
handlers:
- name: user-create
user: name=oracle state=present
tasks:
- name: "check user"
command: /usr/bin/id oracle
register: output
notify: user-create
when: output.rc == 1
But whenever i run this on a system where oracle user is not there, running into this error
"failed": true, "msg": "The conditional check 'output.rc == 1' failed. The error was: error while evaluating conditional (output.rc == 1): 'output' is undefined\n\nThe error appears to have been in '/user-check.yml': line 10, column 5, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n tasks:\n - name: \"check user\"\n ^ here\n"
when
statement is evaluated before task execution, andoutput
variable is populated after task execution. What is your goal? – Konstantin Suvorovstate=absent
if you want to always recreate user. – Konstantin Suvorov