Cannot get past local development setup

I keep running into the same issue and cannot figure out how to get past this.

Dev machine is running ubuntu 16.04 LTS
Ansible version 2.2.1.0 (installed via pip)
VirtualBox version 5.1.18
Vagrant version 1.9.2

I am able to install the required programs successfully.
I am able to create the directory structure and clone trellis and bedrock as well as successfully run the ansible-galaxy install.
I configure wordpress_sites.yml and vault.yml in /group_vars/development/ to match site keys, set site host, and admin_email.
When I run vagrant up from the trellis directory, it goes all the way through the installation/setup process and then at the very end it says:

TASK [setup] *********************************************************************************
System info:
    Ansible 2.2.1.0; Vagrant 1.9.2; Linux
    Trellis at "Allow customization of PHP extensions"
--------------------------------------------------------------
Cannot write to ControlPath /home/<user>/.ansible/cp
fatal: [default]: FAILED! => {"failed": true}
            to retry, use: --limit @/home/<user>/Code/<site>/trellis/dev.retry

PLAY RECAP *********************************************************************
default    : ok=0 change=0 unreachable=0 failed=1

Ansible failed to complete successfully. Any error output should be visible above. Please fix these errors and try again.

There are no other errors listed. This boots the VM and it is running yet the site is unreachable. I am able to ssh into the box but it does not look like there are any web servers running.

I have removed and purged Ansible, VirtualBox, and Vagrant multiple times to make sure it was not an issue with them. I feel like it has to be an issue with permissions or a dependency. Any assistance is greatly appreciated.

I am going to add the install process that I go through to make sure it is correct.

Ansible

sudo easy_install pip
sudo pip install ansible

VirtualBox

add deb http://download.virtualbox.org/virtualbox/debian xenial contrib to /etc/apt/sources.list

wget -q https://www.virtualbox.org/download/oracle_vbox_2016.asc -0- | sudo apt-key add -
sudo apt-get update
sudo apt-get install virtualbox-5.1

Vagrant

Download vagrant deb file

sudo dpkg -i vagrant_1.9.2_x86_64.deb

vagrant-bindfs

vagrant plugin install vagrant-bindfs

vagrant-hostmanager

vagrant plugin install vagrant-hostmanager

All of these installations complete without any errors.

The post below may apply if your home folder is encrypted:

If that’s applicable, you could see if there’s a good place to add a note in the docs (maybe on the Installing Trellis page). You can PR the docs at https://github.com/roots/docs

1 Like

Unfortunately, this does not apply to my situation. I do not have the home folder encrypted. I appreciate the response, though!

I think you could try to address the permissions issue. If that fails, maybe you can avoid the issue by preventing Ansible from attempting to write a control socket to the problematic ControlPath.

Addressing Permissions

What permissions do you see on this directory?

ls -alh $HOME/.ansible

Here’s mine:

drwx------   4 philip  staff   136B Mar 17 18:45 .
drwxr-xr-x+ 75 philip  staff   2.5K Mar 17 19:36 ..
drwx------   2 philip  staff    68B Mar 17 19:30 cp
drwxr-xr-x  33 philip  staff   1.1K Mar 17 19:30 tmp

Maybe you’ll have to chown or chmod the ~/.ansible/cp directory, but I don’t know how or why ownership or permission would be off.

It looks like in Ansible 2.3 you’ll be able to specify the control_path_dir to something else (more notes), which may get around the issue. However, I don’t recommend installing Ansible 2.3 yet, because there is not yet a stable release.

Avoiding Writing to ControlPath

The control_path docs say:

This setting is ignored if -o ControlPath is set in ssh_args.

Testing briefly, however, I found that although ssh_args seems respected while connecting to remote servers, it seemed ignored in connecting to a Vagrant VM. Setting ControlPath in ssh_args did NOT prevent the control socket from being written to ~/.ansible/cp. (Edit: added the crucial “not”)

The only thing I found to prevent a control socket from being written to the ~/.ansible/cp directory was to add a line to my Vagrantfile (right after this line), specifying ControlMaster=no in the ansible provisioner’s raw_ssh_args, like this:

# Vagrantfile

      if vars = ENV['ANSIBLE_VARS']
        extra_vars = Hash[vars.split(',').map { |pair| pair.split('=') }]
        ansible.extra_vars.merge(extra_vars)
      end
+     ansible.raw_ssh_args = ['-o ControlMaster=no']
    end

You could try adding that line, then provisioning the VM again:

vagrant provision
2 Likes

I ended up wiping my dev machine and starting from scratch. It does seem that the permissions in my home directory were not set correct. I just finished running through the setup process and verified that everything installed and worked as expected this time. Hopefully this information can be used if someone else runs into a similar issue. I would like to thank you again for your help.

1 Like