What am I supposed to do after running `trellis up`?

If I do

trellis new example.com

followed by

cd example.com && trellis up

and get the post vagrant up message:

==> default: Your Trellis Vagrant box is ready to use!
==> default: * Composer and WP-CLI commands need to be run on the virtual machine
==> default:   for any post-provision modifications.
==> default: * You can SSH into the machine with `vagrant ssh`.
==> default: * Then navigate to your WordPress sites at `/srv/www`
==> default:   or to your Trellis files at `/home/vagrant/trellis`.

What am I supposed to do at this point? If I navigate to http://example.test in the browser I get example.test refused to connect.. However if I then run vagrant halt and refresh the browser, it tries to connect for a long time.

Seems like there’s something misconfigured on the VM but I have no idea what. Note I haven’t touched wordpress_sites.yaml or vault.yml as some docs I read implied defaults are set automatically.

Please tell me what I’m doing wrong :pray:

Edit: MacOS 12.4, trellis-cli 1.7.0, trellis 1.14.0, bedrock 1.20.0.

Anyone? Sorry if it’s a stupid question…

With upped Trellis, does example.test resolve, and to what IP , localhost (as 127.0.0.1 for the usual IPv4 localhost)? Try ping example.test, does it resolve to an IP and can it be pinged?

Thanks @strarsis

It does, here’s the output of ping example.test:

PING example.test (192.168.56.5): 56 data bytes
64 bytes from 192.168.56.5: icmp_seq=0 ttl=64 time=1.794 ms
64 bytes from 192.168.56.5: icmp_seq=1 ttl=64 time=0.300 ms
64 bytes from 192.168.56.5: icmp_seq=2 ttl=64 time=0.287 ms
64 bytes from 192.168.56.5: icmp_seq=3 ttl=64 time=0.290 ms
64 bytes from 192.168.56.5: icmp_seq=4 ttl=64 time=0.232 ms
64 bytes from 192.168.56.5: icmp_seq=5 ttl=64 time=0.250 ms
64 bytes from 192.168.56.5: icmp_seq=6 ttl=64 time=0.280 ms
^C
--- example.test ping statistics ---
7 packets transmitted, 7 packets received, 0.0% packet loss
round-trip min/avg/max/stddev = 0.232/0.490/1.794/0.533 ms

I’m not quite sure what you’re asking about regarding localhost though.

So the Trellis vagrant box can be pinged, that’s good.

Can you wget http://example.test or curl http://examle.test?
When it doesn’t work using the browser, does it work in the terminal using those commands?

And does trellis ssh development work and you can ssh into the Trellis vagrant box?

1 Like

Really appreciate your help :man_bowing:

wget/curl fails just like the browser…

> wget http://example.test                                                              
--2022-06-08 19:25:47--  http://example.test/
Resolving example.test (example.test)... 192.168.56.5
Connecting to example.test (example.test)|192.168.56.5|:80... failed: Connection refused.
> curl http://example.test                                                          
curl: (7) Failed to connect to example.test port 80 after 1010 ms: Connection refused

…but I can ssh in:

> trellis ssh development                                                          
Running command => ssh vagrant@example.test
Welcome to Ubuntu 20.04.3 LTS (GNU/Linux 5.4.0-91-generic x86_64)

 * Documentation:  https://help.ubuntu.com
 * Management:     https://landscape.canonical.com
 * Support:        https://ubuntu.com/advantage

  System information as of Wed 08 Jun 2022 09:29:58 AM UTC

  System load:  0.0                Processes:             115
  Usage of /:   12.1% of 30.88GB   Users logged in:       0
  Memory usage: 25%                IPv4 address for eth0: 10.0.2.15
  Swap usage:   0%                 IPv4 address for eth1: 192.168.56.5


This system is built by the Bento project by Chef Software
More information can be found at https://github.com/chef/bento
Last login: Mon Jun  6 08:47:41 2022 from 10.0.2.2
-bash: warning: setlocale: LC_ALL: cannot change locale (en_AU.UTF-8)
vagrant@example:~$ ls /srv/www
example.com

When being sshed into the Trellis Vagrant box, check the service status of nginx (service nginx status), does it run? Also try out netstat, is port 80 listened on by any process (something like netstat -tulpn | grep :80)?

I think we’re getting somewhere:

vagrant@example:~$ service nginx status
Unit nginx.service could not be found.
vagrant@example:~$ netstat
-bash: netstat: command not found
vagrant@example:~$

also

vagrant@example:~$ php
-bash: php: command not found

When you trellis up, do you see any warnings/errors during the provision process (that uses ansible) of the spun up Vagrant Ubuntu box?
Can you destroy the Vagrant box (you haven’t stored anything non-persisted/inside the Vagrant box that is precious I suppose) and trellis up again, does it result in the same issue?

Oh hey, sorry if this is relevant. The one thing I did different to the guide was edit /Users/{me}/projects/example.com/trellis/roles/python_interpreter/tasks/main.yml and change line 9 from

    when: ubuntu_version.stdout | trim is version('18.04', '>=')

to

    when: ubuntu_version.stdout

because without that change, trellis up fails with

The conditional check 'ubuntu_version.stdout | trim is version('18.04',
'>=')' failed. The error was: Version comparison: '<' not supported between
instances of 'str' and 'int'

The error appears to be in '/Users/{me}/projects/example.com/trellis/roles/pyt
hon_interpreter/tasks/main.yml': line 6, column 5, but may
be elsewhere in the file depending on the exact syntax problem.

The offending line appears to be:

    changed_when: false
  - name: Set ansible_python_interpreter for Ubuntu >= 18.04
    ^ here
fatal: [default]: FAILED! => {}

PLAY RECAP *********************************************************************
default                    : ok=1    changed=0    unreachable=0    failed=1    skipped=0    rescued=0    ignored=0

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

I’ll try destroying the vagrant box now and report back.

Current Trellis requires Ubuntu 20.04 (“Focal”) LTS:

Using an older Ubuntu can indeed make the provisioning fail as at least the packages may not be compatible with the older Ubuntu version.

But when you don’t change that configuration and force an older Ubuntu version, the process also fails… Are you sure that you updated your Trellis to latest version?

Here’s the full output from trellis up, and this is with a fresh project (trellis new blah.com)

trellis up                                                                               ~/projects/blah.com/trellis
Starting galaxy role install process
- composer (1.9.0) is already installed, skipping.
- ntp (2.2.0) is already installed, skipping.
- logrotate (v0.0.5) is already installed, skipping.
- swapfile (v2.0.32) is already installed, skipping.
- mailhog (2.2.0) is already installed, skipping.

Running command => vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Importing base box 'bento/ubuntu-20.04'...
==> default: Matching MAC address for NAT networking...
==> default: Checking if box 'bento/ubuntu-20.04' version '202206.03.0' is up to date...
==> default: Setting the name of the VM: blah.test
==> default: Fixed port collision for 22 => 2222. Now on port 2201.
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
    default: Adapter 1: nat
    default: Adapter 2: hostonly
==> default: Forwarding ports...
    default: 22 (guest) => 2201 (host) (adapter 1)
==> default: Running 'pre-boot' VM customizations...
==> default: Booting VM...
==> default: Waiting for machine to boot. This may take a few minutes...
    default: SSH address: 127.0.0.1:2201
    default: SSH username: vagrant
    default: SSH auth method: private key
    default:
    default: Vagrant insecure key detected. Vagrant will automatically replace
    default: this with a newly generated keypair for better security.
    default:
    default: Inserting generated public key within guest...
    default: Removing insecure key from the guest if it's present...
    default: Key inserted! Disconnecting and reconnecting using new SSH key...
==> default: Machine booted and ready!
==> default: Checking for guest additions in VM...
==> default: Setting hostname...
==> default: Configuring and enabling network interfaces...
==> default: Installing NFS client...
==> default: Exporting NFS shared folders...
==> default: Preparing to edit /etc/exports. Administrator privileges will be required...
==> default: Mounting NFS shared folders...
==> default: Mounting shared folders...
    default: /vagrant => /Users/imr/projects/blah.com/trellis
==> default: Checking for bindfs in VM...
    default: Package manager detected: apt-get
    default: Fuse kernel module is installed
    default: Fuse kernel module is loaded
==> default: Bindfs seems to not be installed on the virtual machine, installing now
    default: Bindfs 1.14.1 is installed
==> default: Machine is ready to use bindfs!
==> default: Creating bind mounts after synced_folders...
    default: /vagrant-nfs-blah.com => /srv/www/blah.com/current
    default: /ansible-nfs => /home/vagrant/trellis
==> default: [vagrant-hostmanager:guests] Updating hosts file on active guest virtual machines...
==> default: [vagrant-hostmanager:host] Updating hosts file on your workstation (password may be required)...
==> default: Running provisioner: ansible...
    default: Running ansible-playbook...

PLAY [Set ansible_python_interpreter] ******************************************

TASK [python_interpreter : Get Ubuntu version] *********************************
ok: [default]

TASK [python_interpreter : Set ansible_python_interpreter for Ubuntu >= 18.04] ***
System info:
  Ansible 2.10.16; Vagrant 2.2.18; Darwin
  Trellis 1.14.0: February 16th, 2022
---------------------------------------------------
The conditional check 'ubuntu_version.stdout | trim is version('18.04',
'>=')' failed. The error was: Version comparison: '<' not supported between
instances of 'str' and 'int'

The error appears to be in '/Users/imr/projects/blah.com/trellis/roles/python
_interpreter/tasks/main.yml': line 6, column 5, but may
be elsewhere in the file depending on the exact syntax problem.

The offending line appears to be:

    changed_when: false
  - name: Set ansible_python_interpreter for Ubuntu >= 18.04
    ^ here
fatal: [default]: FAILED! => {}

PLAY RECAP *********************************************************************
default                    : ok=1    changed=0    unreachable=0    failed=1    skipped=0    rescued=0    ignored=0

Ansible failed to complete successfully. Any error output should be
visible above. Please fix these errors and try again.
exit status 1
[1] > trellis up                                                                           ~/projects/blah.com/trellis
[130] > trellis-cli                                                                        ~/projects/blah.com/trellis
zsh: command not found: trellis-cli
[127] > trellis --version                                                                  ~/projects/blah.com/trellis
1.7.0

Looks like I’m on the right ubuntu version and latest trellis. Anything jump out at you?

The only other thing I can think of that might be non-standard is I installed trellis-cli by downloading trellis_1.7.0_Darwin_x86_64.tar.gz and mv trellis /usr/local/bin. I’ve noticed some of the docs clone the trellis repo instead, is it worth giving that a shot?

This indicates that the provisioning failed, no wonder that there is no nginx and everything else installed on that Vagrant box.

This was removed in recent Trellis:

Looks like some python 2/3 interpreter incompatibility (Version comparison: '<' not supported between instances of 'str' and 'int' · Issue #70014 · ansible/ansible · GitHub).

But this line doesn’t exist anymore in recent Trellis anyway. So your Trellis is probably somehow outdated.

Ok cool, thanks. So it’d be trellis-cli that I need to update? I deleted my usr/local/bin/trellis that I got from the github releases, installed homebrew just to try it 100% as per the docs, and I get the same result (Version comparison: '<' not supported between instances of 'str' and 'int'). Makes sense since it’s the same file in both cases.

I really have no idea how I’d be running an older trellis, > trellis --version outputs 1.7.0 and if I delete the executable or brew uninstall trellis-cli and which trellis, I get trellis not found.

Again, I really appreciate your help because I am baffled.

Hm, please note that Trellis CLI is not the same as Trellis (they both complement each other).

Trellis CLI is a (basically optional) helper tool that prepares things for Trellis to run smoothly.
Trellis itself is an Ansible based project with server, deploy and rollback playbooks.
So you have to check your Trellis project to be recent and correct, not just the Trellis CLI helper that can be invoked by command line.

So what currently is in that project directory from within you invoke trellis (Trellis CLI) is the first line?

The first line of ~/projects/blah.com/trellis/CHANGELOG.md is

### 1.14.0: February 16th, 2022

So it looks up to date, but then I’ve also got a roles/python_interpreter directory, which doesn’t match what’s on github. Seems heavily implied here but to be explicit, the python_interpreter directory shouldn’t be there with trellis 1.14.0 right?