troykinsella / concourse-ansible-playbook-resource

A Concourse CI resource for running Ansible playbooks
MIT License
40 stars 19 forks source link

Unable to SSH to any remote systems #9

Closed bisshwajitsamanta closed 3 years ago

bisshwajitsamanta commented 5 years ago

Hi, am i missing something while using this resource is what i am curious about. Concourse Pipeline:-


resource_types:

resources:

jobs:

Ansible Playbook which i am intend to run across Multiple remote system:-



Host.yml under inventory directory:-


all: hosts: test: ansible_connection: ssh ansible_host: "13.x.x.x" ansible_port: 22 ansible_user: cloud_user

After having all this i am getting unable to connect via ssh .. I dont know how to proceed from here. Can you help me here please?

troykinsella commented 5 years ago

Are you able to ssh to the target instance from the Concourse worker machine using the configured private key? It appears that you're using the same ssh-key for both the git and ansible resources. Are you sure that the private key of cloud_user is the same as the one used to access git? That typically isn't true for my use cases. I don't see anything wrong with your use of the ansible-playbook resource.

bisshwajitsamanta commented 5 years ago

I tried using seperate keys but i cannot still able to ssh.. though if i hijack the container i can ssh into the system.. i can see it is taking the new ansible-ssh-private-keys but it is still not working.

Output:-


TASK [Current Working Directory] ***** task path: /tmp/build/put/source-code/site.yml:7 Friday 22 November 2019 08:19:47 +0000 (0:00:00.113) 0:00:00.113 * <35.154.46.153> ESTABLISH SSH CONNECTION FOR USER: cloud_user <35.154.46.153> SSH: EXEC ssh -C -o ControlMaster=auto -o ControlPersist=60s -o Port=22 -o 'IdentityFile="/tmp/ansible-playbook-resource-ssh-private-key"' -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o 'User="cloud_user"' -o ConnectTimeout=10 -o ControlPath=/root/.ansible/cp/0f7e6746af 35.154.46.153 '/bin/sh -c '"'"'echo ~cloud_user && sleep 0'"'"'' <35.154.46.153> (255, b'', b'') fatal: [test]: UNREACHABLE! => { "changed": false, "msg": "Failed to connect to the host via ssh: ", "unreachable": true }

eric-gunn commented 4 years ago

I have this same issue, though I cannot SSH into the target machine with the SSH key even when I hijack the container. I can use the same key on other systems to log into the machine just fine. DNS in the container works fine, and the target system is reachable.

rk-p2p commented 4 years ago

@eric-gunn try to add a new line to ssh private key file. Like:

-----END OPENSSH PRIVATE KEY-----
# new line
eric-gunn commented 4 years ago

@rk-p2p Apologies for the seriously delayed response, but all is well. Thanks!

troykinsella commented 3 years ago

Fixed in #20