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

How to properly provide multiple ssh extra args #140

Closed
rhugga opened this issue Feb 29, 2024 · 3 comments
Closed

How to properly provide multiple ssh extra args #140

rhugga opened this issue Feb 29, 2024 · 3 comments
Labels
bug Something isn't working v2.0.0

Comments

@rhugga
Copy link

rhugga commented Feb 29, 2024

I'm hitting an issue where I'm getting an error trying to use more than one ssh extra arg:

This is the command that the library ends up running. This works when I run it manually.

/opt/homebrew/bin/ansible-playbook --extra-vars {"ansible_sudo_pass":"REDACTED"} --forks 5 --inventory 192.168.1.2, --ssh-extra-args ' -o StrictHostKeyChecking=accept-new -o UserKnownHostsFile=/dev/null' --timeout 300 --user myuser --become-method sudo --become-user root /var/folders/3z/4hf8d_g93h77jtsj82y3ysb80000gn/T/.ansible-3124354280

When I run this via my go code and this library:

            "tasks": [
                {
                    "hosts": {
                        "192.168.1.2": {
                            "action": "gather_facts",
                            "changed": false,
                            "msg": "Failed to connect to the host via ssh: command-line line 0: keyword stricthostkeychecking extra arguments at end of line",
                            "unreachable": true
                        }
                    },
                    "task": {
                        "duration": {
                            "end": "2024-02-29T16:37:06.509821Z",
                            "start": "2024-02-29T16:37:06.492520Z"
                        },
                        "id": "66d3b971-6cc6-a701-202c-000000000009",
                        "name": "Gathering Facts",
                        "path": "/var/folders/3z/4hf8d_g93h77jtsj82y3ysb80000gn/T/.ansible-3124354280:1"
                    }
                }
            ]

options.AnsibleConnectionOptions.SSHExtraArgs is just a string so how should multiple arguments be specified?

My connection options is being constructed like so:

    "Connection": {
        "AskPass": false,
        "Connection": "",
        "PrivateKey": "",
        "SCPExtraArgs": "",
        "SFTPExtraArgs": "",
        "SSHCommonArgs": "",
        "SSHExtraArgs": " -o StrictHostKeyChecking=accept-new -o UserKnownHostsFile=/dev/null",
        "Timeout": 300,
        "User": "myuser"
    },
@apenella
Copy link
Owner

apenella commented Mar 4, 2024

Hi @rhugga!
Thank you very much for raising that issue. Let me take a look at this.
Just letting you know, I will work on fixing that over the v2.0.0.

I keep you updated!

@apenella
Copy link
Owner

Hi @rhugga
I have been working on that issue and I found the solution: eba64fd

I also prepared an example with a simple environment to validate it. Here you have a link to the example:
https://github.com/apenella/go-ansible/tree/version-2.0.0-prerelease-2/examples/ansibleplaybook-ssh

The fix is not yet released.

I keep you updated.

@apenella apenella added v2.0.0 bug Something isn't working and removed Pending Analysis labels Mar 15, 2024
@apenella
Copy link
Owner

apenella commented Apr 4, 2024

Available in v2.0.0-rc-3

@apenella apenella closed this as completed Apr 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working v2.0.0
Projects
None yet
Development

No branches or pull requests

2 participants