'dict object' has no attribute 'stdout'

Latest response

Hello guys,

I am unable to use when condition in ansible playbook. I tried different methods to input the value from the previous to "when" condition but nothing worked. I am using the ansible version 2.6.20. I have used below conditions in the reboot task, but always failing at this condition with error "'dict object' has no attribute 'stdout". Please advise if you have any fix for this.

#when: stat_reboot.results[0].rc != 0
#when: stat_reboot.rc == 0
#when: stat_reboot is failed
#when: '"Reboot" in reboot.stdout'
#when: reboot.stdout.stdout == "Reboot"

Responses

Hi

Can this issue reproduce on latest version Ansible v 2.9.11 ?

Regards Ju

Hello:

I am getting the same error using Ansible core 2.11.3.

This is the error message I am getting:

FAILED! => {"msg": "The task includes an option with an undefined variable. The error was: 'dict object' has no attribute 'stdout'

This is the code:

- name: Verify App/Database are running or not
  shell: if ps -eaf| egrep 'httpd'| grep -v grep > /dev/null; then echo 'process_running'; else echo
'process_not_running'; fi
  ignore_errors: true
  register: appr_proc_check
- debug: msg="{{ appr_proc_check.stdout }}"

I was able to run it without getting the error by adding -K to become "root" or "sudo":

ansible-playbook kernel-patching-pb.yml -K

where this is my playbook calling the role:

- hosts: client1
  become: true
  become_user: root

  roles:
          - kernel-patching-r