AWS OpsWorks setup_failed for Instance - unable to deploy_branch

121 Views Asked by At

I've had a remote dashboard running fine for a couple of years (written for me by an external developer). It runs on an EC2 instance and is configured using OpsWorks.

Today it's not working, and I see in OpsWorks that the instance is showing as setup_failed.

According to the logs it fails here:

[2021-07-02T15:00:59+00:00] FATAL: Stacktrace dumped to /var/chef/runs/18bc4301-71c1-4393-bb26-eae958791d5a/local-mode-cache/cache/chef-stacktrace.out
[2021-07-02T15:00:59+00:00] FATAL: Please provide the contents of the stacktrace.out file if you file a bug report
[2021-07-02T15:00:59+00:00] ERROR: deploy_branch[/srv/api] (iparcelbox::deploy-api line 45) had an error: Mixlib::ShellOut::ShellCommandFailed: Expected process to exit with [0], but received '255'
---- Begin output of git fetch origin ----
STDOUT: 
STDERR: error: cannot open .git/FETCH_HEAD: Permission denied
---- End output of git fetch origin ----
Ran git fetch origin returned 255

I've checked the recipe file for iparcelbox::deploy-api and line 45 calls a deploy_branch:

deploy_branch server_path do

  user userName
  group groupName

  repository node[:iparcelbox][:git_url]
  revision node[:iparcelbox][:revision]

  enable_submodules false
  migrate false
  shallow_clone true
  git_ssh_wrapper "/tmp/api_git_wrapper.sh"
  rollback_on_error false
  keep_releases 5

  symlink_before_migrate.clear
  purge_before_symlink purge_dirs
  create_dirs_before_symlink []
  symlinks({})

  action :deploy
end

So as I understand it, the deploy_branch is trying to fetch a git repo, and for some reason it's failing? I've checked my GitHub repository for the source files and I can see an ssh 'Deploy Key' which is showing as used within the last week.

If anyone could give me any suggestions as to what else to try, it would be much appreciated!

1

There are 1 best solutions below

0
iParcelBox On

I found an answer to this - I thought the issue was permission denied accessing the git repository, but actually it was because the destination folder on my instance had modified ownership. Setting the ownership back to that specified in the Chef recipe using chown allowed the setup to complete successfully.