Can deploy to production, but not staging

I’m not sure what has happened and I have looked ta several other threads regarding failed deployments and have spent hours trying to debug. I’m running this command:

ansible-playbook deploy.yml -e "site=MYSITE.com env=staging"

But it fails here:

TASK [deploy : Update git remote URL] ********************************************************************************************************************************************************************************************************************
skipping: [staging.MYSITE.com]

TASK [deploy : Clone project files] **********************************************************************************************************************************************************************************************************************
System info:
Ansible 2.7.4; Darwin
Trellis version (per changelog): "Update xdebug tunnel configuration"
---------------------------------------------------
fatal: [staging.MYSITE.com]: FAILED! => {"censored": "the output has been hidden due to the fact that 'no_log: true' was specified for this result", "changed": false}
...ignoring

TASK [deploy : Failed connection to remote repo] *********************************************************************************************************************************************************************************************************
System info:
Ansible 2.7.4; Darwin
Trellis version (per changelog): "Update xdebug tunnel configuration"
---------------------------------------------------
Git repo git@github.com:ACCOUNT/MYSITE.com-wordpress.git cannot be
accessed. Please verify the repository exists and you have SSH forwarding set
up correctly.
More info:
> https://roots.io/trellis/docs/deploys/#ssh-keys
> https://roots.io/trellis/docs/ssh-keys/#cloning-remote-repo-using-ssh-
agent-forwarding

fatal: [staging.MYSITE.com]: FAILED! => {"changed": false}

PLAY RECAP ***********************************************************************************************************************************************************************************************************************************************
localhost                  : ok=0    changed=0    unreachable=0    failed=0
staging.MYSITE.com     : ok=7    changed=0    unreachable=0    failed=1 

Here’s my .ssh/config:

User web
HostName staging.MYSITE.com
ForwardAgent yes

What else can I try?

The error you’re getting indicates that Ansible can’t clone your GitHub repository. Have you forwarded your SSH key (see documentation)? Is the GitHub repo named correctly in your staging wordpress_sites.yml?

Those are the first things I would check.

That I have. What doesn’t make sense is that I can deploy to production which utilizes the same repo. What else could it be? Does my config look right?

I’ve had issues similar to this before where the only way I was able to solve it was by spooling up a new instance of a server and reprovisioning and deploying. It’s not the most fun way to get back up and running and rather annoying but it’s been the case a few times.

Thanks Josh, but that’s something I really don’t want to do. It’s just weird that I can deploy to prod, but not staging.

Is there anything else I should be looking at?

I have double checked everything regarding SSH forwarding on https://developer.github.com/v3/guides/using-ssh-agent-forwarding/

I even re-setup my ~/.ssh/config file too.

Are there any other things/tests that I can look into?

Would this help?

$ ssh-keyscan github.com
# github.com:22 SSH-2.0-babeld-f3847d63
# github.com:22 SSH-2.0-babeld-f3847d63
github.com ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAq2A7hRGmdnm9tUDbO9IDSwBK6TbQa+PXYPCPy6rbTrTtw7PHkccKrpp0yVhp5HdEIcKr6pLlVDBfOLX9QUsyCOV0wzfjIJNlGEYsdlLJizHhbn2mUjvSAHQqZETYP81eFzLQNnPHt4EVVUh7VfDESU84KezmD5QlWpXLmvU31/yMf+Se8xhHTvKSCZIFImWwoG6mbUoWf9nzpIoaSjB+weqqUUmpaaasXVal72J+UX2B+2RPW3RcT0eOzQgqlJL3RKrTJvdsjE3JEAvGq3lGHSZXy28G3skua2SmVi/w4yCE6gbODqnTWlg7+wC604ydGXA8VJiS5ap43JXiUFFAaQ==
# github.com:22 SSH-2.0-babeld-f3847d63

That github.com ssh-rsa line doesn’t match my public key. I saw another post where @fullyint discussed that.

Just spitballin’ here

FWIW I followed the same steps as Josh did in his first post here:

Should running evalssh-agent -s`` return a new agent pid 26167? Each time I run it I get a new pid. I’m not sure if that’s expected behavior.

Also when I $git log -- trellis I don’t show anything being changed there since before deployments to staging stopped working. I realize that not all files were checked into git but trying to determine what had changed and if that change broke staging deployments.

I’ve seen people with the same issue before and it was because they were deploying a non-existent branch. Have you checked which branch you’re deploying and that it exists on your remote repo?

Thanks for the reply. The branch is staging and hasn’t changed. I think it’s likely something with my local. I checked SSH Forwarding, SSH Agent, modified my ssh config, and more.

What else is left? ¯_(ツ)_/¯

Can you SSH in to the server and pull down the repo manually? Not a solution, but it could help diagnose where the problem is occuring.

Has the staging branch been pushed up to GitHub?

edit:

  1. Sorry, just saw that you said production uses the same branch - so sanity check here: Are you deploying your staging branch to production with no problems?
  2. Have you ever been able to deploy to this staging environment? Did provisioning run smoothly?
  1. I meant to say that we have been using the staging for our staging server. While master is used for production. We were able to deploy just fine the other day. I think something on the server got messed up somehow, but I’m not sure what else to try.
  2. Yes and yes.

Thanks for all of your help!

Doesn’t look like that’s an option here since git isn’t deployed to the server.

Trellis deploys by (in part) git cloneing your repository on your remote server (see: https://roots.io/trellis/docs/remote-server-setup/#deploy). If you don’t have git on your remote server, it would be impossible for it to do that.

Thanks for the response. I should have said that git itself isn’t installed, but I do understand that trellis utilizes that to deploy the updates. The same can be said of production too, where deployments work just fine.

Is there anything that I can check that may have been foobarred on the server?

I can successfully provision with $ ansible-playbook server.yml -e "site=SITENAME.com env=staging" but not deploy $ ansible-playbook deploy.yml -e "site=SITENAME.com env=staging"

Any other ideas besides provisioning another fresh server?

Ok, have you tried deploying to staging with your master branch?

Can you show us the contents of your trellis/group_vars/staging/wordpress_sites.yml please?