Trellis failing when trying to deploy

I am trying to run a deployment through Trellis rc1. I have ssh keys configured for the bitbucket account, and have ssh key added to the staging server for which I am trying to deploy to and it is configured for password-less login.

Have tried searching with no luck for a fix or solution?

To add, the host_key is added to the know_hosts file in group_vars. It is also the same on another machine that is used to run deployments and it is working fine.

TASK [deploy : Clone project for local build] **************************************************************************************************************************************************************
task path: /home/prestonc/environments/trellis/deploy-hooks/build-before.yml:11
Using module file /usr/local/lib/python2.7/dist-packages/ansible/modules/source_control/git.py
ESTABLISH LOCAL CONNECTION FOR USER: prestonc
EXEC /bin/sh -c '/usr/bin/python && sleep 0’
System info:
Ansible 2.3.2.0; Linux
Trellis 1.0.0-rc.1: April 7th, 2017

git.oit.ohio.edu has an unknown hostkey. Set accept_hostkey to True or
manually add the hostkey prior to running the git module
fatal: [www-test]: FAILED! => {
“changed”: false,
“failed”: true,
“invocation”: {
“module_args”: {
“accept_hostkey”: false,
“bare”: false,
“clone”: true,
“depth”: null,
“dest”: “/tmp/ansible.mrRrP0-main-site-staging”,
“executable”: null,
“force”: false,
“key_file”: null,
“recursive”: true,
“reference”: null,
“refspec”: null,
“remote”: “origin”,
“repo”: “ssh://git@git.oit.ohio.edu:7999/oulib/wp-site-main.git”,
“ssh_opts”: null,
“track_submodules”: false,
“umask”: null,
“update”: true,
“verify_commit”: false,
“version”: “staging”
}
}
}
to retry, use: --limit @/home/prestonc/environments/trellis/deploy.retry

PLAY RECAP *************************************************************************************************************************************************************************************************
localhost : ok=0 changed=0 unreachable=0 failed=0
www-test : ok=13 changed=4 unreachable=0 failed=1

I set hostkey to True (against the warning above the line).

I am now getting this error

The conditional check 'wp_installed.stderr != ""' failed. The error was:
error while evaluating conditional (wp_installed.stderr != ""): 'dict object'
has no attribute 'stderr'
fatal: [www-test]: FAILED! => {
    "failed": true
}

If you’re unable to figure out a solution, hopping on a call with us for 30 minutes via https://roots.io/services/ (at the bottom) would probably be enough time to help you get up and running (it would likely be scheduled with @fullyint, one of the leads for Trellis).

1 Like

Looking at the Trellis CHANGELOG I see that since the release of your version “1.0.0-rc.1: April 7th, 2017” there was an update for “Ansible 2.3 compatibility (#813).” This suggests that you may be running into compatibility issues given that you are running Ansible 2.3.2.0.

:star: I’d suggest rolling back, e.g., pip install ansible==2.2.3.0
or update your trellis. If you are managing this project on two different machines, you might avoid trouble by using the same Trellis and Ansible version on each machine, if you aren’t doing so already.

Trellis now tries to prevent out-of-sync Trellis and Ansible versions. In September 2017 Trellis added a

warning for Ansible versions greater than tested with Trellis
It happens that people update Ansible but not Trellis, then run into problems, not realizing they need to update their Trellis for compatibility, posting on discourse, etc.
[WARNING]: You Ansible version is 2.5.0.0 but this version of Trellis has only been tested for compatability with Ansible 2.4.0.0 -> 2.4.2.0. It is advisable to check for Trellis updates or downgrade your Ansible version.


This suggests something quite unusual happened during the command
wp core is-installed --skip-plugins --skip-themes
You could check what happens when you

  • SSH in to the server (as your web_user)
  • cd /srv/www/example.com/current
  • wp core is-installed --skip-plugins --skip-themes
  • echo $?

I’m guessing the wp core is-installed will give errors for you to look into.

If not, you could add a debug task right after the problem task to check the value of the register variable, posting back the output:

  - name: WordPress Installed?
    command: wp core is-installed --skip-plugins --skip-themes --require={{ deploy_helper.shared_path }}/tmp_multisite_constants.php
    args:
      chdir: "{{ deploy_helper.new_release_path }}"
    register: wp_installed
    changed_when: false
-   failed_when: wp_installed.stderr != ""
+   failed_when: false
+ 
+ - debug:
+     msg: "{{ wp_installed | to_nice_yaml }}"
+ 
+ - fail:
+     msg: just stopping on purpose
1 Like

I attempted the commands that you suggested after ssh’ing into vagrant. I got back no errors for the wp command and a 0 for the final command. Still getting the 2nd error message I posted upon a deploy. I’m currently using ansible 2.3.2 on my machine, and everything works fine. Trying to set this up on my bosses machine and I can’t get it to work on hers.

Could you try replacing this failed_when parameter and see if it prints a more helpful error message on your next deploy attempt?

  changed_when: false
- failed_when: wp_installed.stderr != ""
+ failed_when: wp_installed.stderr | default('') != "" or wp_installed.exception | default('') != ""

I plan to add an adjustment along those lines to Trellis after a little more testing.

If you still get the same 'dict object' has no attribute 'stderr' error message as before, please try my suggestion in earlier post: “you could add a debug task…”