compound-finance/gateway

Unreachable remote host using provided ansible setup

Closed this issue · 2 comments

Issue Description

Following the README instructions in gateway/ops I cannot seem to setup and run the gateway application using the provided Ansible chain playbook. The terraform setup correctly creates the described infrastructure on aws, and it correctly generates a hosts and ssh_config file. However the below mentioned command fails due to an ssh/key issue.

I am not too familiar with Ansible so any help would be appreciated!

Expected Behavior

  • Successfully sets up and starts the Gateway application on remote instances

Current Behavior

Setting up Gateway application

ansible-playbook -i hosts --ssh-extra-args "-F ./ssh_config" ansible/playbooks/chain.yml

Upon running the above command I get the below error message. I am able to ssh into the instances which is why this error confuses me.

PLAY [full_node,authority_node] **************************************************************************************************************************************************

TASK [Gathering Facts] ***********************************************************************************************************************************************************
fatal: [xxxx]: UNREACHABLE! => {"changed": false, "msg": "Failed to connect to the host via ssh: kex_exchange_identification: Connection closed by remote host", "unreachable": true}
fatal: [xxx]: UNREACHABLE! => {"changed": false, "msg": "Failed to connect to the host via ssh: kex_exchange_identification: Connection closed by remote host", "unreachable": true}
fatal: [xxxx]: UNREACHABLE! => {"changed": false, "msg": "Failed to connect to the host via ssh: kex_exchange_identification: Connection closed by remote host", "unreachable": true}

PLAY RECAP ***********************************************************************************************************************************************************************
xxxxxxxx                : ok=0    changed=0    unreachable=1    failed=0    skipped=0    rescued=0    ignored=0
xxxxxxxx                : ok=0    changed=0    unreachable=1    failed=0    skipped=0    rescued=0    ignored=0
xxxxxxxx                : ok=0    changed=0    unreachable=1    failed=0    skipped=0    rescued=0    ignored=0

To Reproduce

Steps to reproduce the behavior:

  1. Follow instructions outlined in gateway/ops

Specification

  • commit tag: m8
  • operating system: macos

additional links:

I have reviewed this issue on stackoverflow but with no luck. I am not really sure this is an Ansible issue but any direction/guidance would be appreciated. Thanks.

Hello @dutterbutter ,

First I would recommend running your above command with -vvvv added, which prints everything ansible with the most verbosity possible.

The logs should explain your error in more detail. But, in the mean time, there are two things that come to my mind that could be likely.

It is possible that the private ssh key is not being correctly passed with ansible. If not, it will default to commonly named ssh keys such as id_rsa. You can set it explicitly in the command line, or like so in the inventory file:

[authority_node]
xx.x.x.xxx  ansible_ssh_private_key_file=~/.ssh/<YOUR_SSH_PRIV_KEY>

[bastion]
xx.x.x.xxx ansible_ssh_private_key_file=~/.ssh/<YOUR_SSH_PRIV_KEY>

[full_node]
xx.x.x.xxx ansible_ssh_private_key_file=~/.ssh/<YOUR_SSH_PRIV_KEY>
xx.x.x.xxx ansible_ssh_private_key_file=~/.ssh/<YOUR_SSH_PRIV_KEY>

This may be your problem, but there is another problem you could be hitting as well. (Or you could have both).

One thing you need to do with ansible is use ssh-agent for forwarding. This blog explains well what you need to do with a bastion node and ssh forwarding. I recommend reading through it all, but likely all you will have to run is:

ssh-add ~/.ssh/<YOUR_SSH_PRIV_KEY>
ansible-playbook -i hosts --ssh-extra-args "-F ./ssh_config" ansible/playbooks/chain.yml

Let me know if you have any questions!

Thanks @davekaj that seemed to work!