Ansible Playbook fails: Logs included

Hey guys,

I haven’t built a Roots project from scratch to deployment in a few months so I’ve been catching up tonight. After working through some of the new steps, I’ve got the local env. working just great.

Here’s my current repo.

But when I get ready to deploy it, I get this on the prerequisite step, run:
ansible-playbook server.yml -e env=<environment>

When I run that I get:
PLAY [WordPress Server - Install LEMP Stack with PHP 7.0 and MariaDB MySQL] ****

TASK [setup] *******************************************************************
fatal: [your_server_ip]: UNREACHABLE! => {"changed": false, "msg": "ERROR! SSH encountered an unknown error during the connection. We recommend you re-run the command using -vvvv, which will enable SSH debugging output to help diagnose the issue", "unreachable": true}

PLAY RECAP *********************************************************************
localhost                  : ok=0    changed=0    unreachable=0    failed=0
your_server_ip             : ok=3    changed=0    unreachable=1    failed=0

When I run the command in verbose mode I get:

Masons-iMac:trellis Mason$ ansible-playbook deploy.yml -vvvv -e "site=snapfast.com env=staging"
Using /Users/Mason/Sites/Snapfast-WP1.1/trellis/ansible.cfg as config file
Loaded callback default of type stdout, v2.0
2 plays in deploy.yml

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

TASK [Ensure environment is defined] *******************************************
task path: /Users/Mason/Sites/Snapfast-WP1.1/trellis/variable-check.yml:8
skipping: [localhost] => {"changed": false, "skip_reason": "Conditional check failed", "skipped": true}

PLAY [Deploy WP site] **********************************************************

TASK [setup] *******************************************************************
<your_server_ip> ESTABLISH SSH CONNECTION FOR USER: web
<your_server_ip> 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=web -o ConnectTimeout=10 -o ControlPath=/Users/Mason/.ansible/cp/ansible-ssh-%h-%p-%r -tt your_server_ip '( umask 22 && mkdir -p "$( echo $HOME/.ansible/tmp/ansible-tmp-1458099649.2-30752240970844 )" && echo "$( echo $HOME/.ansible/tmp/ansible-tmp-1458099649.2-30752240970844 )" )'
fatal: [your_server_ip]: UNREACHABLE! => {"changed": false, "msg": "ERROR! SSH encountered an unknown error. The output was:\nOpenSSH_6.9p1, LibreSSL 2.1.7\r\ndebug1: Reading configuration data /Users/Mason/.ssh/config\r\ndebug1: Reading configuration data /etc/ssh/ssh_config\r\ndebug1: /etc/ssh/ssh_config line 21: Applying options for *\r\ndebug1: auto-mux: Trying existing master\r\ndebug1: Control socket \"/Users/Mason/.ansible/cp/ansible-ssh-your_server_ip-22-web\" does not exist\r\nssh: Could not resolve hostname your_server_ip: nodename nor servname provided, or not known\r\n", "unreachable": true}

PLAY RECAP *********************************************************************
localhost                  : ok=0    changed=0    unreachable=0    failed=0
your_server_ip             : ok=0    changed=0    unreachable=1    failed=0

If I had to guess, I’d think it has something to do with either:

  • My etc/hosts file (which has my digital ocean IP in it– 104.236.136.60)
  • My trellis/all/users.yml which appears to be configured correctlly
  • My droplet/ssh itself. I started creating droplets without SSH keys, then linking them after creation because I found I was getting less errors that way.
  • Which leads me to my next theory, it could have to do with paswordless authentication. When you create a droplet without an SSH key and then link it up later (like I’ve been doing lately), it emails you an SSH password and then prompts you to change it upon logging into your SSH.

I know that’s a wide range of theories, but if someone could point me in the right direction, it would be a huge help. Thanks everyone!

P.S. Been catching up on the podcast lately, loving it. You guys are killing it. Keep it going.

Given the error message “Could not resolve hostname your_server_ip,” see if #2 in README’s “Remote server setup” handles it:

Add your server IP/hostnames to hosts/<environment>

2 Likes

Perfect. So simple.

Not sure how I missed the hosts/ configuration.

Thank you Phil.