name: Output current env details
debug:
msg: “{{ webpage.content }}”
name: Get the group passcode
command: “echo {{ webpage.content }} | grep -oP ‘(?<=).*?(?=)’”
delegate_to: localhost
register: passcode
`
I assumed I could just debug out the webpage.content again, but I get an error
TASK [ansible-ohp-win-installer : Output current env details] **********************************************************
fatal: [192.168.50.4]: FAILED! => {“msg”: “The task includes an option with an undefined variable. The error was: ‘dict object’ has no attribute ‘content’\n\nThe error appears to have been in ‘/mnt/c/Work/ansible/roles/ansible-ohp-win-installer/tasks/main.yml’: line 185, column 7, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n\n - name: Output current env details\n ^ here\n\nexception type: <class ‘ansible.errors.AnsibleUndefinedVariable’>\nexception: ‘dict object’ has no attribute ‘content’”}
I assumed I could just debug out the webpage.content again, but I get an
error
TASK [ansible-ohp-win-installer : Output current env details]
**********************************************************
fatal: [192.168.50.4]: FAILED! => {"msg": "The task includes an option with
an undefined variable. The error was: 'dict object' has no attribute
'content'\n\nThe error appears to have been in
'/mnt/c/Work/ansible/roles/ansible-ohp-win-installer/tasks/main.yml': line
185, column 7, but may\nbe elsewhere in the file depending on the exact
syntax problem.\n\nThe offending line appears to be:\n\n\n - name:
Output current env details\n ^ here\n\nexception type: <class
'ansible.errors.AnsibleUndefinedVariable'>\nexception: 'dict object' has no
attribute 'content'"}
Your host 192.168.50.4 is not groups["backend_nodes"][0]
"Get OHP Group Passcode" run only on one host 'groups["backend_nodes"][0]' because of the when statement.
But your debug task run on all the host in the playbook, but they don't have the variable webpage, so you get the error message on them, so you need to include the when on the debug task also.