I am trying to provision an Ubuntu Xenial Vagrant guest with Ansible. It worked correctly on Ubuntu 14.04, but fails on 16.04. The error that I get is
chown failed: failed to look up user vagrant
The task that I am running is the following:
- name: Ensure /srv/web exists
become: yes
file:
path: /srv/web
state: directory
mode: 0755
owner: "{{ remote_user }}"
Searching hasn't found much help.
Thanks!
Edit: Further testing on a Digital Ocean 14.04 droplet also shows this issue.
Edit 2: Full output log at -vvvv level
I had the same problem. I am using
ubuntu/xenial64
.I noticed that there is no
vagrant
user. When I SSH in using Vagrant, theubuntu
user is used.I created an
ansible.cnf
:After that I encountered another issue: no python. I fixed this with:
Now, the
ansible ping
module works for my host.SOLOUTION#1
Ubuntu 16.04 has python3, not 2.7.x. and Ansible doesn't support for Python 3 yet.
For Ubuntu 16.04 I use the following play to get Python 2.7 installed.
key line is
gather_facts: no
which prevents Ansible to execute code on the remote server that the remote server cannot yet support.Without this line,play would fail.That provides an
/usr/bin/python2.7
, which I explicitly point to in my inventory file.Note that there is nothing special about the name
xenials
. It's just a group I have defined in my inventory.This
ansible_python_interpreter
only need for the first time, after that you can remove it because we have created the softlink for the python2.7 Hope that help you.SOLOUTION#2
Reason of this error:
I have reviewed the gist that contain the detail log and figured out this:
ubuntu/xenial64
vagrant
user"msg": "chown failed: failed to look up user vagrant"
that's the error trace which help you find the exact error.Solution-1 to this error:
Download some other vagrant box, I recommend this vagrant box
geerlingguy/ubuntu1604
it has really good reputationSolution-2 to this error:
With the official vagrant box, you can do the same as I am doing to mitigate this error. Add the following to your
Vagrantfile
:What it will do is, just create your host login user to the guest and upload the rsa key for it. So you can run the playbook to the vagrant machine as if it is the remote machine. If you'll face any problem further, please let me know.
Hope this help you.