packer/local vs remote, service restart failure

Having a problem with a packer/local vs normal ansible remote provision.

Remote

On the remote, I provision mysql, then change the mysql settings and restart mysql - everything goes swimmingly.

  • file: path={{ item }} state=absent
    with_items:

  • /var/lib/mysql/ib_logfile0

  • /var/lib/mysql/ib_logfile1

  • /var/lib/mysql/ib_logfile2
    notify: restart-mysql
    tags: mysql

  • name: restart-mysql
    service: name=mysql state=restarted sleep=10

Remote:

NOTIFIED: [mysql | restart-mysql] *********************************************
<192.168.56.101> REMOTE_MODULE service name=mysql state=restarted
<192.168.56.101> EXEC [‘/bin/sh’, ‘-c’, ‘mkdir -p $HOME/.ansible/tmp/ansible-tmp-1417087683.16-109709247336195 && chmod a+rx $HOME/.ansible/tmp/ansible-tmp-1417087683.16-109709247336195 && echo $HOME/.ansible/tmp/ansible-tmp-1417087683.16-109709247336195’]
<192.168.56.101> PUT /tmp/tmpUOthBA TO /home/vagrant/.ansible/tmp/ansible-tmp-1417087683.16-109709247336195/service
<192.168.56.101> EXEC /bin/sh -c ‘sudo -k && sudo -H -S -p “[sudo via ansible, key=ufnibuoyecqmoknrwhhfsbkwbevetxkc] password: " -u root /bin/sh -c '”’“‘echo SUDO-SUCCESS-ufnibuoyecqmoknrwhhfsbkwbevetxkc; LANG=C LC_CTYPE=C /usr/bin/python /home/vagrant/.ansible/tmp/ansible-tmp-1417087683.16-109709247336195/service; rm -rf /home/vagrant/.ansible/tmp/ansible-tmp-1417087683.16-109709247336195/ >/dev/null 2>&1’”‘"’’
changed: [192.168.56.101] => {“changed”: true, “name”: “mysql”, “state”: “started”}

PLAY RECAP ********************************************************************

Local

On a local provision, I do the same as above from within the VM and everything goes swimmingly.

Packer/Local

If I run the above from packer i.e. local build, no matter what service I try to restart it fails:

virtualbox-iso: NOTIFIED: [mysql | restart-mysql] *********************************************
virtualbox-iso: <192.168.56.101> REMOTE_MODULE service name=mysql state=restarted sleep=10
virtualbox-iso: <192.168.56.101> EXEC [‘/bin/sh’, ‘-c’, ‘mkdir -p $HOME/.ansible/tmp/ansible-tmp-1417090379.74-133308290545382 && chmod a+rx $HOME/.ansible/tmp/ansible-tmp-1417090379.74-133308290545382 && echo $HOME/.ansible/tmp/ansible-tmp-1417090379.74-133308290545382’]
virtualbox-iso: <192.168.56.101> PUT /tmp/tmpidQgBv TO /home/vagrant/.ansible/tmp/ansible-tmp-1417090379.74-133308290545382/service
virtualbox-iso: <192.168.56.101> EXEC /bin/sh -c ‘sudo -k && sudo -H -S -p “[sudo via ansible, key=pfctarqsvenqtrfjkqxhizisscmtqntc] password: " -u root /bin/sh -c '”’“‘echo SUDO-SUCCESS-pfctarqsvenqtrfjkqxhizisscmtqntc; LANG=C LC_CTYPE=C /usr/bin/python /home/vagrant/.ansible/tmp/ansible-tmp-1417090379.74-133308290545382/service; rm -rf /home/vagrant/.ansible/tmp/ansible-tmp-1417090379.74-133308290545382/ >/dev/null 2>&1’”‘"’’
virtualbox-iso: failed: [192.168.56.101] => {“failed”: true}
virtualbox-iso: msg: start: Job failed to start

Ansible version in all instances is 1.7.2

Any guidance?

I don’t use Packer often, but I’m unclear on why anyone would want to use the remote version, to be honest.

It seems the local version would always be simpler.