# ansible.vars.hostvars.HostVarsVars object' has no attribute 'sudo'

**URL:** <https://forum.ansible.com/t/ansible-vars-hostvars-hostvarsvars-object-has-no-attribute-sudo/32829>\
**Category:** AWX Project\
**Created:** [May 1, 2020, 10:12am UTC](https://forum.ansible.com/t/ansible-vars-hostvars-hostvarsvars-object-has-no-attribute-sudo/32829 "2020-05-01T10:12:29Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kumaresan\_M](https://avatars.discourse-cdn.com/v4/letter/k/e19b73/32.png) [@Kumaresan\_M](https://forum.ansible.com/u/Kumaresan_M)\
**Post date:** [May 1, 2020, 10:12am UTC](https://forum.ansible.com/t/ansible-vars-hostvars-hostvarsvars-object-has-no-attribute-sudo/32829/1 "2020-05-01T10:12:29Z")

</div>

Hi,

Could someone help me on subjected issue? I have an playbook which works well when running from command line but the same report an issue running from ansible tower.

FAILED! =\> {“msg”: “The task includes an option with an undefined variable. The error was: ‘ansible.vars.hostvars.HostVarsVars object’ has no attribute ‘sudo’\n\nThe error appears to be in ‘/tmp/awx\_117\_n\_4nr0rt/project/sudoers.yml’: line 46, column 9, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n post\_tasks:\n - name: Sending Mail\n ^ here\n”}

Here is my playbook:

- name: collect sudousers list  
shell: cat /etc/sudoers|grep -i “ALL=(ALL”|egrep -v “#”|egrep -v “root|wheel”|awk -vq=“” ‘{print (q $0 q)}’ ORS=‘,’  
register: sudo

- name: Sending Mail  
mail:  
host: test  
port: 25

---

<div class="post-metadata">

**Author:** ![Selvam\_Elangovan](https://avatars.discourse-cdn.com/v4/letter/s/8c91f0/32.png) [@Selvam\_Elangovan](https://forum.ansible.com/u/Selvam_Elangovan)\
**Post date:** [May 4, 2020, 3:01am UTC](https://forum.ansible.com/t/ansible-vars-hostvars-hostvarsvars-object-has-no-attribute-sudo/32829/2 "2020-05-04T03:01:44Z")

</div>

Hi Kumaresan,

{{ hostvars[host].sudo.stdout }} – Here is the problem. It could not recognize the variable from hostvars[host].sudo.

You did register: sudo but some how the hostsvars[host] is not working in awx. It could be due to the inventory. Have a look again in inventory and also what you have mentioned in hosts: in the playbook.

Thanks & Regards,  
Selvam E.
