Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ansible_mitogen: Templated SSH private key file #1181

Merged
merged 1 commit into from
Nov 6, 2024

Conversation

moreati
Copy link
Member

@moreati moreati commented Nov 5, 2024

refs #1083

@moreati moreati force-pushed the issue1083-private_key_file branch 8 times, most recently from bcea062 to ff6bd0c Compare November 5, 2024 18:15
@moreati
Copy link
Member Author

moreati commented Nov 6, 2024

Another case of vanilla Ansible not templating ssh_executable (see #1175). It exhibits slightly differently depending on whether there is an existing connection and/or whether an SSH password is specified (requiring sshpass). It looks like private_key_file option is among those that are correctly templated.

PLAY [integration/ssh/templated_by_play_taskvar.yml] ***************************

TASK [meta _raw_params=reset_connection] ***************************************
task path: /home/runner/work/mitogen/mitogen/tests/ansible/integration/ssh/templated_by_play_taskvar.yml:11
Tuesday 05 November 2024  23:55:56 +0000 (0:00:00.050)       0:00:02.636 ****** 
sending connection check: [b'sshpass', b'-d6', b"{{ 'ssh' | trim }}", b'-vvv', b'-o', b'ControlMaster=auto', b'-o', b'ControlPersist=60s', b'-o', b'ForwardAgent=yes', b'-o', b'HostKeyAlgorithms=+ssh-rsa', b'-o', b'PubkeyAcceptedKeyTypes=+ssh-rsa', b'-o', b'UserKnownHostsFile=/dev/null', b'-o', b'StrictHostKeyChecking=no', b'-o', b'Port=2201', b'-o', b'User="mitogen__has_sudo_nopw"', b'-o', b'ConnectTimeout=30', b'-o', b'ControlPath="/home/runner/.ansible/cp/6326e6fc14"', b'-O', b'check', b'localhost']
No connection to reset: sshpass: Failed to run command: No such file or directory
META: reset connection

TASK [Templated variables in play, password authentication ] *******************
task path: /home/runner/work/mitogen/mitogen/tests/ansible/integration/ssh/templated_by_play_taskvar.yml:12
Tuesday 05 November 2024  23:55:56 +0000 (0:00:00.019)       0:00:02.656 ****** 
Using module file /home/runner/work/mitogen/mitogen/.tox/py313-mode_ansible-ansible10-strategy_linear/lib/python3.13/site-packages/ansible/modules/ping.py
Pipelining is enabled.
<localhost> ESTABLISH SSH CONNECTION FOR USER: mitogen__has_sudo_nopw
<localhost> SSH: EXEC sshpass -d14 ssh -vvv -o ControlMaster=auto -o ControlPersist=60s -o ForwardAgent=yes -o HostKeyAlgorithms=+ssh-rsa -o PubkeyAcceptedKeyTypes=+ssh-rsa -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -o Port=2201 -o 'User="mitogen__has_sudo_nopw"' -o ConnectTimeout=30 -o 'ControlPath="/home/runner/.ansible/cp/6326e6fc14"' localhost '/bin/sh -c '"'"'/usr/bin/python3 && sleep 0'"'"''
<localhost> (0, b'\n{"ping": "pong", "invocation": {"module_args": {"data": "pong"}}}\n', b'OpenSSH_8.2p1 Ubuntu-4ubuntu0.11, OpenSSL 1.1.1f  31 Mar 2020\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\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 = 4204\r\ndebug3: mux_client_request_session: session request sent\r\ndebug3: mux_client_read_packet: read header failed: Broken pipe\r\ndebug2: Received exit status from master 0\r\n')
ok: [tt-bare] => changed=false 
  invocation:
    module_args:
      data: pong
  ping: pong

PLAY [integration/ssh/templated_by_play_taskvar.yml] ***************************

TASK [meta _raw_params=reset_connection] ***************************************
task path: /home/runner/work/mitogen/mitogen/tests/ansible/integration/ssh/templated_by_play_taskvar.yml:25
Tuesday 05 November 2024  23:55:56 +0000 (0:00:00.218)       0:00:02.874 ****** 
sending connection check: [b"{{ 'ssh' | trim }}", b'-vvv', b'-o', b'ControlMaster=auto', b'-o', b'ControlPersist=60s', b'-o', b'ForwardAgent=yes', b'-o', b'HostKeyAlgorithms=+ssh-rsa', b'-o', b'PubkeyAcceptedKeyTypes=+ssh-rsa', b'-o', b'UserKnownHostsFile=/dev/null', b'-o', b'StrictHostKeyChecking=no', b'-o', b'Port=2201', b'-o', b'IdentityFile="/home/runner/work/mitogen/mitogen/tests/data/docker/mitogen__has_sudo_pubkey.key"', b'-o', b'KbdInteractiveAuthentication=no', b'-o', b'PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey', b'-o', b'PasswordAuthentication=no', b'-o', b'User="mitogen__has_sudo_pubkey"', b'-o', b'ConnectTimeout=30', b'-o', b'ControlPath="/home/runner/.ansible/cp/342a74ac40"', b'-O', b'check', b'localhost']

@moreati moreati marked this pull request as ready for review November 6, 2024 06:57
@moreati moreati merged commit 9189c01 into mitogen-hq:master Nov 6, 2024
21 checks passed
@moreati moreati deleted the issue1083-private_key_file branch November 6, 2024 06:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant