[GH-ISSUE #350] Issue with Ansible #90

Closed
opened 2026-05-07 00:18:39 +02:00 by BreizhHardware · 1 comment

Originally created by @LucJubeau on GitHub (Nov 7, 2022).
Original GitHub issue: https://github.com/ovh/the-bastion/issues/350

I'm setting up an Ansible that needs to go through the bastion-ovh.
I have a user for ansible who connects to the bastion with an SSH key pair, and from the bastion, connects to the machines I want to manage.

My settings are :

a custom inventory :

all:
children :
Bastion:
hosts:
[my bastion address]:
Git:
hosts:
[my machine address]:

with a file in group_vars/all/all.yml :

ansible_python_interpreter: /usr/bin/python3

bastion_user: [myuser]
bastion_host: [my_bastion address]
bastion_port: 22

ansible_private_key_file: "/home/[myuser]/.ssh/[privatekey]"
ansible_ssh_transfer_method: scp
ansible_ssh_pipelining: 1
ansible_ssh_executable: /[path]/sshwrapper.py

ansible_scp_if_ssh: True
ansible_scp_executable: /[path]/scpbastion.sh

When i 've launched my command : ansible -vvvv Git -i 00_inventory.yml -m ping
i had this error :

[my machine address]| UNREACHABLE! => {
"changed": false,
"msg": "Data could not be sent to remote host "[my machine address]". Make sure this host can be reached over ssh: OpenSSH_8.4p1 Debian-5+deb11u1, OpenSSL 1.1.1n 15 Mar 2022\r\ndebug1: Reading configuration data /etc/ssh/ssh_config\r\ndebug1: /etc/ssh/ssh_config line 19: include /etc/ssh/ssh_config.d/*.conf matched no files\r\ndebug1: /etc/ssh/ssh_config line 21: Applying options for *\r\ndebug3: expanded UserKnownHostsFile '/.ssh/known_hosts' -> '/home/[my user]/.ssh/known_hosts'\r\ndebug3: expanded UserKnownHostsFile '/.ssh/known_hosts2' -> '/home/[my user]/.ssh/known_hosts2'\r\ndebug1: auto-mux: Trying existing master\r\ndebug1: Control socket "/home/[my user]/.ansible/cp/f122c6a8e2" does not exist\r\ndebug2: resolving "none" port 22\r\nssh: Could not resolve hostname none: Name or service not known\r\n",
"unreachable": true

i've looked for solutions, but any of them have solved my issue.

thanks a lot for your answers

Originally created by @LucJubeau on GitHub (Nov 7, 2022). Original GitHub issue: https://github.com/ovh/the-bastion/issues/350 I'm setting up an Ansible that needs to go through the bastion-ovh. I have a user for ansible who connects to the bastion with an SSH key pair, and from the bastion, connects to the machines I want to manage. My settings are : a custom inventory : all: children : Bastion: hosts: [my bastion address]: Git: hosts: [my machine address]: with a file in group_vars/all/all.yml : ansible_python_interpreter: /usr/bin/python3 bastion_user: [myuser] bastion_host: [my_bastion address] bastion_port: 22 ansible_private_key_file: "/home/[myuser]/.ssh/[privatekey]" ansible_ssh_transfer_method: scp ansible_ssh_pipelining: 1 ansible_ssh_executable: /[path]/sshwrapper.py ansible_scp_if_ssh: True ansible_scp_executable: /[path]/scpbastion.sh When i 've launched my command : ansible -vvvv Git -i 00_inventory.yml -m ping i had this error : [my machine address]| UNREACHABLE! => { "changed": false, "msg": "Data could not be sent to remote host \"[my machine address]\". Make sure this host can be reached over ssh: OpenSSH_8.4p1 Debian-5+deb11u1, OpenSSL 1.1.1n 15 Mar 2022\r\ndebug1: Reading configuration data /etc/ssh/ssh_config\r\ndebug1: /etc/ssh/ssh_config line 19: include /etc/ssh/ssh_config.d/*.conf matched no files\r\ndebug1: /etc/ssh/ssh_config line 21: Applying options for *\r\ndebug3: expanded UserKnownHostsFile '~/.ssh/known_hosts' -> '/home/[my user]/.ssh/known_hosts'\r\ndebug3: expanded UserKnownHostsFile '~/.ssh/known_hosts2' -> '/home/[my user]/.ssh/known_hosts2'\r\ndebug1: auto-mux: Trying existing master\r\ndebug1: Control socket \"/home/[my user]/.ansible/cp/f122c6a8e2\" does not exist\r\ndebug2: resolving \"none\" port 22\r\nssh: Could not resolve hostname none: Name or service not known\r\n", "unreachable": true i've looked for solutions, but any of them have solved my issue. thanks a lot for your answers
Author
Owner

@LucJubeau commented on GitHub (Nov 17, 2022):

i have solved this issue with create a home/[myuser]/.bash_profile :

export BASTION_ANSIBLE_INV_OPTIONS='-i /[path to my ansible directory]/00_inventory.yml'

<!-- gh-comment-id:1318372441 --> @LucJubeau commented on GitHub (Nov 17, 2022): i have solved this issue with create a home/[myuser]/.bash_profile : export BASTION_ANSIBLE_INV_OPTIONS='-i /[path to my ansible directory]/00_inventory.yml'
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/the-bastion#90
No description provided.