Roots Discourse

Deployment fails when cloning the project files

Hi Everyone,

I’ve been fighting this trouble for a long time.

Here’s what I do.

  1. Vagrant is running on Windows.
  2. Connect within putty to ssh.
  3. Run the command of deploy.

ansible-playbook deploy.yml -e “site=staging.visitorstore.ch env=staging” -vvvv

  1. Enter password for private key.
    Also I used:

eval ssh-agent -s
ssh-add

  1. Authorization to server is passed.

Then it throws the following:

TASK [deploy : Clone project files] **************************************************************************************************************************************************************************
task path: /home/vagrant/trellis/roles/deploy/tasks/update.yml:16
Using module file /usr/local/lib/python2.7/dist-packages/ansible/modules/source_control/git.py
<104.248.43.139> ESTABLISH SSH CONNECTION FOR USER: web
<104.248.43.139> SSH: EXEC ssh -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=/home/vagrant/.ansible/cp/d5e95318e3 104.248.43.139 '/bin/sh -c '"'"'/usr/bin/python && sleep 0'"'"''
<104.248.43.139> (1, '\n{"msg": "Failed to download remote objects and refs:  error: insufficient permission for adding an object to repository database .git/objects\\nfatal: failed to write object\\nfatal: unpack-objects failed\\n", "failed": true, "cmd": ["/usr/bin/git", "fetch", "--tags", "origin"], "invocation": {"module_args": {"executable": null, "refspec": null, "force": true, "track_submodules": false, "reference": null, "dest": "/srv/www/staging.visitorstore.ch/shared/source", "verify_commit": false, "clone": true, "umask": null, "update": true, "accept_hostkey": true, "ssh_opts": null, "repo": "git@github.com:vdrnn/visitorstore.git", "depth": null, "version": "master", "bare": false, "remote": "origin", "key_file": null, "archive": null, "recursive": true}}}\n', 'OpenSSH_7.2p2 Ubuntu-4ubuntu2.6, OpenSSL 1.0.2g  1 Mar 2016\r\ndebug1: Reading configuration data /home/vagrant/.ssh/config\r\ndebug1: /home/vagrant/.ssh/config line 1: Applying options for *\r\ndebug1: Reading configuration data /etc/ssh/ssh_config\r\ndebug1: /etc/ssh/ssh_config line 3: Applying options for *\r\ndebug3: kex names ok: [curve25519-sha256@libssh.org,diffie-hellman-group-exchange-sha256]\r\ndebug1: /etc/ssh/ssh_config line 20: Deprecated option "useroaming"\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 = 9051\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 1\r\n')
System info:
  Ansible 2.5.3; Linux
  Trellis version (per changelog): "Update wp-cli to 2.0.1"
---------------------------------------------------
Failed to download remote objects and refs:  error: insufficient permission
for adding an object to repository database .git/objects
fatal: failed to write object
fatal: unpack-objects failed

fatal: [104.248.43.139]: FAILED! => {
    "changed": false,
    "cmd": [
        "/usr/bin/git",
        "fetch",
        "--tags",
        "origin"
    ],
    "invocation": {
        "module_args": {
            "accept_hostkey": true,
            "archive": null,
            "bare": false,
            "clone": true,
            "depth": null,
            "dest": "/srv/www/staging.visitorstore.ch/shared/source",
            "executable": null,
            "force": true,
            "key_file": null,
            "recursive": true,
            "reference": null,
            "refspec": null,
            "remote": "origin",
            "repo": "git@github.com:vdrnn/visitorstore.git",
            "ssh_opts": null,
            "track_submodules": false,
            "umask": null,
            "update": true,
            "verify_commit": false,
            "version": "master"
        }
    }
}
...ignoring

TASK [deploy : Failed connection to remote repo] *************************************************************************************************************************************************************
task path: /home/vagrant/trellis/roles/deploy/tasks/update.yml:27
System info:
  Ansible 2.5.3; Linux
  Trellis version (per changelog): "Update wp-cli to 2.0.1"
---------------------------------------------------
Git repo git@github.com:vdrnn/visitorstore.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: [104.248.43.139]: FAILED! => {
    "changed": false
}

Although commands

ssh git@github.com
git clone git@github.com:vdrnn/visitorstore.git

are working fine.

Sure I read those suggested articles.

I created the file:

/home/vagrant/.ssh/config

Host *
ForwardAgent yes

\trellis\group_vars\all\users.yml

users:
  - name: "{{ web_user }}"
    groups:
      - "{{ web_group }}"
    keys:
      - "{{ lookup('file', '~/.ssh/id_rsa.pub') }}"
      - https://github.com/user1.keys
      - https://github.com/user2.keys
      - https://github.com/PaulSamsonov.keys

I made provisioning many times.

Please let me know if you faced anything like that.

Thanks in advance.

If you’re on a Mac try typing ssh-add -K.

I’m on Windows :slight_smile:

The issue is almost definitely that your SSH key is not being forwarded. You’ve set up forwarding as enabled, but you haven’t actually done it yet.

I think we’ll need to consult a Windows user for specifics on how to do this (calling all Windows users on the forum?). You should also confirm that you’ve followed the documentation for Windows SSH forwarding in the docs.

I’ve seen people with the same issue before and it turns out they forgot to create their staging branch or they are deploying a branch that doesn’t exist. Check group_vars/staging/wordpress_sites.yml and that the branch set in there exists on your remote repo.

2 Likes

thanks for your time, a few questions:

  1. should I run ansible via windows? run it via linux on VM is wrong?
  2. deployment process worked, but then it just stopped suddenly
  3. I see this error: insufficient permission, but not Permission denied (publickey) - so maybe forwarding works?

thanks for checking in,

but I have only one branch in the repo - master and the same one here - group_vars/staging/wordpress_sites.yml

This topic was automatically closed after 42 days. New replies are no longer allowed.