First Remote Server Experience

I’m attempting to use Trellis to push to my staging server, which is a remote, shared server.

It isn’t a VPS, so I don’t think I can serve the site through Trellis– but I can still use Trellis to push the Bedrock site to my server, correct?

My ./site directory is the root of my git repo. I added the server info to the hosts/staging, the database and user info to group_vars/staging/wordpress_sites.yml and group_vars/staging/vault.yml

Below is the output of running: ansible-playbook server.yml -e env=staging -vvvv

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

TASK [setup] *******************************************************************
<s313.rackspeed-cloud.de> ESTABLISH SSH CONNECTION FOR USER: nnnnnn
<s313.rackspeed-cloud.de> SSH: EXEC ssh -C -vvv -o ForwardAgent=yes -o ControlMaster=auto -o ControlPersist=60s -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o User=nnnnnn -o ConnectTimeout=10 -o ControlPath=/Users/robgordon/.ansible/cp/ansible-ssh-%h-%p-%r -tt s313.rackspeed-cloud.de '( umask 22 && mkdir -p "$( echo $HOME/.ansible/tmp/ansible-tmp-1457434146.64-240435819543061 )" && echo "$( echo $HOME/.ansible/tmp/ansible-tmp-1457434146.64-240435819543061 )" )'
<s313.rackspeed-cloud.de> PUT /var/folders/dd/hh628ndj4mx6gkwyp4lcf8nr0000gn/T/tmpj24l20 TO /home/nnnnnn/.ansible/tmp/ansible-tmp-1457434146.64-240435819543061/setup
<s313.rackspeed-cloud.de> SSH: EXEC sftp -b - -C -vvv -o ForwardAgent=yes -o ControlMaster=auto -o ControlPersist=60s -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o User=nnnnnn -o ConnectTimeout=10 -o ControlPath=/Users/robgordon/.ansible/cp/ansible-ssh-%h-%p-%r '[s313.rackspeed-cloud.de]'
<s313.rackspeed-cloud.de> ESTABLISH SSH CONNECTION FOR USER: nnnnnn
<s313.rackspeed-cloud.de> SSH: EXEC ssh -C -vvv -o ForwardAgent=yes -o ControlMaster=auto -o ControlPersist=60s -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o User=nnnnnn -o ConnectTimeout=10 -o ControlPath=/Users/robgordon/.ansible/cp/ansible-ssh-%h-%p-%r -tt s313.rackspeed-cloud.de '/bin/sh -c '"'"'sudo -H -S -n -u root /bin/sh -c '"'"'"'"'"'"'"'"'echo BECOME-SUCCESS-ongldvahawkeoaaswmhbbbcurxwndwsu; LANG=en_US.UTF-8 LC_ALL=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8 /usr/bin/python /home/nnnnnn/.ansible/tmp/ansible-tmp-1457434146.64-240435819543061/setup; rm -rf "/home/nnnnnn/.ansible/tmp/ansible-tmp-1457434146.64-240435819543061/" > /dev/null 2>&1'"'"'"'"'"'"'"'"''"'"''
fatal: [s313.rackspeed-cloud.de]: FAILED! => {"changed": false, "failed": true, "invocation": {"module_name": "setup"}, "module_stderr": "OpenSSH_6.2p2, OSSLShim 0.9.8r 8 Dec 2011\ndebug1: Reading configuration data /etc/ssh_config\r\ndebug1: /etc/ssh_config line 20: Applying options for *\r\ndebug1: /etc/ssh_config line 53: Applying options for *\r\ndebug1: auto-mux: Trying existing master\r\ndebug2: fd 3 setting O_NONBLOCK\r\ndebug2: mux_client_hello_exchange: master version 4\r\ndebug3: mux_client_forwards: request forwardings: 0 local, 0 remote\r\ndebug3: mux_client_request_session: entering\r\ndebug3: mux_client_request_alive: entering\r\ndebug3: mux_client_request_alive: done pid = 7154\r\ndebug3: mux_client_request_session: session request sent\r\ndebug1: mux_client_request_session: master session id: 2\r\ndebug3: mux_client_read_packet: read header failed: Broken pipe\r\ndebug2: Received exit status from master 127\r\nShared connection to s313.rackspeed-cloud.de closed.\r\n", "module_stdout": "/bin/sh: sudo: command not found\r\n", "msg": "MODULE FAILURE", "parsed": false}

NO MORE HOSTS LEFT *************************************************************

PLAY RECAP *********************************************************************
localhost                  : ok=0    changed=0    unreachable=0    failed=0
s313.rackspeed-cloud.de    : ok=3    changed=0    unreachable=0    failed=1

Could this be because it’s trying to provision my server, but my server doesn’t need provisioning?

Also is there a different command to run if I’m just trying to push my bedrock site to the server?

( Sorry for the beginner questions~ )

The deploy process in Trellis assumes the server being deployed to is also managed by Trellis. Because of this I wouldn’t recommend using Trellis to deploy to a non-Trellis server.

You should consider using something like Capistrano instead. We have a production ready script that you can more easily tailor to your needs and there’s also a screencast you can buy for additional help: https://github.com/roots/bedrock-capistrano

For reference the Trellis commands are:

// Provision the server
ansible-playbook server.yml -e env=<environment>

// Deploy using the helper
./deploy.sh <environment> <site name>

// Deploy running the playbook directly
ansible-playbook deploy.yml -e "site=<site name> env=<environment>"

// Rollback the latest deployment
ansible-playbook rollback.yml -e "site=<site name> env=<environment>"

As you can see from this list, you attempted to provision the shared server, not make a deployment. Fortunately the SSH connection failed, preventing you from doing any damage. I’m sure your host would appreciate you using a disposable $5 Digital Ocean droplet with any further Trellis tests.

3 Likes

@Foxaii thanks for recommending the screencast. It was a great reference.

I’m almost up and running with bedrock-capistrano except that permissions on my shared host only allowed me to install Composer into my home directory (I also aliased it in ~/.bashrc for good measure) - but I’m still seeing the following error when I run bundle exec cap staging deploy:

INFO[cc17bbc0] Running /usr/bin/env composer install --no-dev --prefer-dist --no-interaction --quiet --optimize-autoloader on s313.rackspeed-cloud.de
DEBUG[cc17bbc0] Command: cd /home/littlesu/www/staging/releases/20160308225358 && ( WP_ENV=staging /usr/bin/env composer install --no-dev --prefer-dist --no-interaction --quiet --optimize-autoloader )
DEBUG[cc17bbc0] 	stdin: is not a tty
DEBUG[cc17bbc0] 	/usr/bin/env:
DEBUG[cc17bbc0] 	composer
DEBUG[cc17bbc0] 	: No such file or directory
DEBUG[cc17bbc0]
cap aborted!
SSHKit::Runner::ExecuteErr

Is there any way to tell Capistrano where composer.phar is located rather than it looking in usr/bin/env (unless I’m misinterpreting what’s happening…)?

Thanks!

@swalkinshaw will correct me if I’m wrong, but you should be able to add the following to your deploy.rb:

# Set path to composer
SSHKit.config.command_map[:composer] = "/path/to/composer"
2 Likes

@Foxaii thanks for all of your help! Starting to get the hang of it :rowboat: