# Sudo via ansible error

**URL:** <https://forum.ansible.com/t/sudo-via-ansible-error/19765>\
**Category:** Ansible Project\
**Tags:** ubuntu\
**Created:** [November 14, 2015, 2:00am UTC](https://forum.ansible.com/t/sudo-via-ansible-error/19765 "2015-11-14T02:00:26Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ovidio\_B](https://avatars.discourse-cdn.com/v4/letter/o/e79b87/32.png) [@Ovidio\_B](https://forum.ansible.com/u/Ovidio_B)\
**Post date:** [November 14, 2015, 2:00am UTC](https://forum.ansible.com/t/sudo-via-ansible-error/19765/1 "2015-11-14T02:00:26Z")

</div>

Greetings,

I’ve created a simple playbook that adds some packages to an ubuntu system. I’m using packer with the ansible provisioner to get things setup but I keep getting hit with the following error message in verbose mode:

`  
virtualbox-ovf: failed: [127.0.0.1] =\> (item=apache2,git,php5,php5-gd) =\> {“failed”: true, “item”: “apache2,git,php5,php5-gd”, “parsed”: false}

`

`virtualbox-ovf: [sudo via ansible, key=nttwhnattzqhpxjrbhcvutsbslalooch] password:`

Just before that error message I do have some success with the key though:

`virtualbox-ovf: <127.0.0.1> EXEC /bin/sh -c 'sudo -k && sudo -H -S -p "[sudo via ansible, key=nttwhnattzqhpxjrbhcvutsbslalooch] password: " -u root /bin/sh -c '"'"'echo **BECOME-SUCCESS** -nttwhnattzqhpxjrbhcvutsbslalooch; LANG=C LC_CTYPE=C /usr/bin/python /home/vagrant/.ansible/tmp/ansible-tmp-1447465858.15-164219871112034/apt; rm -rf /home/vagrant/.ansible/tmp/ansible-tmp-1447465858.15-164219871112034/ >/dev/null 2>&1'"'"''`

As you can see I’m calling sudo, but I’m still getting the error. I’ve tried the new `become` function but still haven’t had any success. Has anyone seen this before?

`

---

<div class="post-metadata">

**Author:** ![Ovidio\_B](https://avatars.discourse-cdn.com/v4/letter/o/e79b87/32.png) [@Ovidio\_B](https://forum.ansible.com/u/Ovidio_B)\
**Post date:** [November 14, 2015, 5:50pm UTC](https://forum.ansible.com/t/sudo-via-ansible-error/19765/2 "2015-11-14T17:50:03Z")

</div>

Looks like the issue lied in my /etc/sudoers files - fixed it by making the following changes in my packer build:

sed -i -e ‘/Defaults\s+env\_reset/a Defaults\texempt\_group=sudo’ /etc/sudoers  
sed -i -e ‘s/%sudo ALL=(ALL:ALL) ALL/%sudo ALL=NOPASSWD:ALL/g’ /etc/sudoers
