Trellis/Ubuntu 16.04/DO

Just wondering if there’s a timeframe to update trellis to 16.04 . DO already has the capability to create 16.04 VPS’s.

Would be great just know.

Thanks!

jD

No real timeframe yet. Probably a couple of months off to let it stabilize first.

3 Likes

So I had a go at provisioning a Ubuntu 16.04 server with Trellis today and thought I’d leave some notes in case they’re useful to anyone else…

Disclaimer - I am not a sysadmin.


Ubuntu 16.04 comes with Python 3.5.1 instead of 2.7 and Ansible requires Python 2 to work.

This means that Trellis 0.9.7 gets stuck determining which user to proceed as:

$ ansible-playbook server.yml -e env=production

PLAY [Ensure necessary variables are defined] **********************************

TASK [Ensure environment is defined] *******************************************
skipping: [localhost]

PLAY [Determine Remote User] ***************************************************

TASK [remote-user : Determine whether to connect as root or admin_user] ********
ok: [example.com -> localhost]

TASK [remote-user : Set remote user for each host] *****************************
ok: [example.com]

TASK [remote-user : Announce which user was selected] **************************
Note: Ansible will attempt connections as user = admin
ok: [example.com]

PLAY [WordPress Server - Install LEMP Stack with PHP 7.0 and MariaDB MySQL] ****

TASK [setup] *******************************************************************
System info:
  Ansible 2.0.2.0; Darwin
  Trellis at "Fix #569 - Only skip subdomains for non-www domains"
---------------------------------------------------
Failed to connect to the host via ssh.
fatal: [example.com]: UNREACHABLE! => {"changed": false, "unreachable": true}
    to retry, use: --limit @server.retry

PLAY RECAP *********************************************************************
example.com             : ok=3    changed=0    unreachable=1    failed=0
localhost                  : ok=0    changed=0    unreachable=0    failed=0

as it cannot find a Python interpreter:

$ ansible production -m ping -u root
example.com | FAILED! => {
    "changed": false,
    "failed": true,
    "module_stderr": "",
    "module_stdout": "/bin/sh: 1: /usr/bin/python: not found\r\n",
    "msg": "MODULE FAILURE",
    "parsed": false
}

To fix this, you must first install Python 2.7 onto the server (related SO question)

You can either SSH into the server and install it yourself:

sudo apt-get install -y python

or you could get Ansible to do it for you by adding the following to trellis/server.yml, above the “Determine Remote User” task :

- name: Install Python 2 on the server so Ansible can talk to it
  hosts: web:&{{ env }}
  gather_facts: false
  vars:
    - ansible_ssh_user: "root"
  tasks:
    - raw: sudo apt-get install -y python

(which is the way I initially did it) however this method means that you can now only connect as root to provision as I couldn’t quite work out how to run the first command as root and then let the remote-user role determine whether to switch to the admin user.

Which means it’s probably best to install Python 2 with an ad-hoc Ansible command before you provision the server:

# from example.com/trellis
ansible production -m raw -a 'apt-get install -y python' -u root
# python 2 installs
ansible-playbook server.yml -e env=production
# server is provisioned using whichever admin user you chose to use

There are probably more things that I’ve missed in upgrading as I’ve only done it the once on the one site but this at least gets you a provisioned server you can deploy to.

Alternatives

Hope this comes in useful to someone

6 Likes

You may also want to use https://atlas.hashicorp.com/geerlingguy/boxes/ubuntu1604 for the vagrant box: the official Xenial box has some issues at the moment.

2 Likes