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

Add 'type: string' to connection options to make sure they are actually strings #549

Merged
merged 2 commits into from
Jun 14, 2023

Conversation

felixfontein
Copy link
Contributor

SUMMARY

As opposed to modules, the plugin config system uses type: raw as a default for type, and not type: str. Therefore options that do not specify type can end up as non-strings.

This caused a problem in ansible-collections/community.routeros#175 when users had passwords that could be interpreted as integers. Specifying ansible_ssh_pass=1234567890 in the inventory caused strange errors in the bowels of network_cli (i.e. without stack traces since the errors happened on the other side of the JSON RPC connection). Once @BSMaximN figured out this is caused by passwords that look like integers, I was able to reproduce this with network_cli via libssh. (I have some trouble getting paramiko to work so I cannot reproduce it there.)

The problem seems to boil down to Ansible's plugin config manager having a different default for type than the module argument spec: if you omit type, then the values are kept as-is (for modules, they are converted to strings).

Therefore the password ended up being an integer and not a string, which trips up both paramiko and libssh.

I've added type: string to all options which do not have other types for the connection plugins; adding type: string to libssh's password field solved the problem for me, and I guess there are many similar problems where other values are assumed to be strings that potentially aren't. (There are also a lot of to_native()s everywhere, so some of them got converted to strings already before.)

ISSUE TYPE
  • Bugfix Pull Request
  • Docs Pull Request
COMPONENT NAME

connection plugins

@codecov
Copy link

codecov bot commented Jun 11, 2023

Codecov Report

Merging #549 (4d27a82) into main (1737de2) will not change coverage.
The diff coverage is n/a.

@@           Coverage Diff           @@
##             main     #549   +/-   ##
=======================================
  Coverage   64.47%   64.47%           
=======================================
  Files          31       31           
  Lines        3868     3868           
  Branches      685      685           
=======================================
  Hits         2494     2494           
  Misses       1231     1231           
  Partials      143      143           

see 3 files with indirect coverage changes

@felixfontein
Copy link
Contributor Author

felixfontein commented Jun 11, 2023

The ansible-lint error is unrelated, it also applies to the main branch. (#550 fixes CI.)

@softwarefactory-project-zuul
Copy link
Contributor

Build failed.
https://ansible.softwarefactory-project.io/zuul/buildset/9ab0df4292a9480998a3f01c2f58ed4d

ansible-test-network-integration-junos-vsrx-netconf-python36-stable29 FAILURE in 14m 19s (non-voting)
✔️ ansible-test-network-integration-junos-vsrx-netconf-python36-stable211 SUCCESS in 1h 13m 20s
ansible-test-network-integration-junos-vsrx-netconf-python39-stable212 RETRY_LIMIT in 6m 00s
✔️ ansible-test-network-integration-junos-vsrx-netconf-python39 SUCCESS in 51m 07s
ansible-test-network-integration-junos-vsrx-network_cli-python36-stable29 FAILURE in 13m 19s (non-voting)
ansible-test-network-integration-junos-vsrx-network_cli-python36-stable211 RETRY_LIMIT in 5m 55s
✔️ ansible-test-network-integration-junos-vsrx-network_cli-python39-stable212 SUCCESS in 17m 07s
✔️ ansible-test-network-integration-junos-vsrx-network_cli-python39 SUCCESS in 15m 37s
ansible-test-network-integration-junos-vsrx-network_cli-libssh-python36-stable29 FAILURE in 15m 35s (non-voting)
ansible-test-network-integration-junos-vsrx-network_cli-libssh-python36-stable211 FAILURE in 16m 11s
✔️ ansible-test-network-integration-junos-vsrx-network_cli-libssh-python39-stable212 SUCCESS in 16m 04s
✔️ ansible-test-network-integration-junos-vsrx-network_cli-libssh-python39 SUCCESS in 15m 08s
ansible-test-network-integration-nxos-cli-python39-scenario01 NODE_FAILURE Node request 200-0006091509 failed in 0s (non-voting)
✔️ ansible-test-network-integration-nxos-cli-python39-scenario02 SUCCESS in 34m 45s (non-voting)
✔️ ansible-test-network-integration-nxos-cli-python39-scenario03 SUCCESS in 33m 30s (non-voting)
✔️ ansible-test-network-integration-nxos-cli-python39-scenario04 SUCCESS in 32m 33s (non-voting)
✔️ ansible-test-network-integration-eos-network_cli-python39 SUCCESS in 52m 44s (non-voting)
✔️ ansible-test-network-integration-eos-httpapi-python39 SUCCESS in 42m 15s (non-voting)
✔️ ansible-test-network-integration-eos-network_cli-libssh-python39 SUCCESS in 51m 59s (non-voting)
ansible-ee-integration-ios-latest FAILURE in 28m 38s (non-voting)
ansible-ee-integration-ios-stable-2.9 FAILURE in 28m 43s (non-voting)
ansible-ee-integration-ios-stable-2.11 FAILURE in 27m 27s (non-voting)
ansible-ee-integration-ios-stable-2.12 FAILURE in 27m 04s (non-voting)
ansible-ee-integration-ios-libssh-latest FAILURE in 55m 44s (non-voting)
ansible-ee-integration-ios-libssh-stable-2.9 FAILURE in 53m 49s (non-voting)
ansible-ee-integration-ios-libssh-stable-2.11 FAILURE in 55m 08s (non-voting)
ansible-ee-integration-ios-libssh-stable-2.12 FAILURE in 55m 48s (non-voting)
ansible-test-network-integration-vyos-paramiko-python39-devel NODE_FAILURE Node request 200-0006091524 failed in 0s
ansible-test-network-integration-vyos-paramiko-python39-stable214 NODE_FAILURE Node request 200-0006091525 failed in 0s
ansible-test-network-integration-vyos-paramiko-python39-stable213 NODE_FAILURE Node request 200-0006091526 failed in 0s
ansible-test-network-integration-vyos-paramiko-python39-stable212 NODE_FAILURE Node request 200-0006091527 failed in 0s
ansible-test-network-integration-vyos-paramiko-python36-stable29 NODE_FAILURE Node request 200-0006091528 failed in 0s (non-voting)
ansible-test-network-integration-vyos-libssh-python39-devel NODE_FAILURE Node request 200-0006091529 failed in 0s
ansible-test-network-integration-vyos-libssh-python39-stable214 NODE_FAILURE Node request 200-0006091530 failed in 0s
ansible-test-network-integration-vyos-libssh-python39-stable213 NODE_FAILURE Node request 200-0006091531 failed in 0s
ansible-test-network-integration-vyos-libssh-python39-stable212 NODE_FAILURE Node request 200-0006091532 failed in 0s
ansible-test-network-integration-vyos-libssh-python36-stable29 NODE_FAILURE Node request 200-0006091533 failed in 0s
✔️ build-ansible-collection SUCCESS in 14m 49s
✔️ ansible-test-network-integration-ansible-netcommon-junos-vsrx-netconf-python39 SUCCESS in 12m 31s
✔️ ansible-tox-linters SUCCESS in 10m 56s
✔️ ansible-galaxy-importer SUCCESS in 4m 23s

@softwarefactory-project-zuul
Copy link
Contributor

Build failed.
https://ansible.softwarefactory-project.io/zuul/buildset/2da25871e9d249f5b8fc10ca03291f2b

ansible-test-network-integration-junos-vsrx-netconf-python36-stable29 FAILURE in 13m 35s (non-voting)
✔️ ansible-test-network-integration-junos-vsrx-netconf-python36-stable211 SUCCESS in 1h 20m 37s
✔️ ansible-test-network-integration-junos-vsrx-netconf-python39-stable212 SUCCESS in 1h 04m 18s
✔️ ansible-test-network-integration-junos-vsrx-netconf-python39 SUCCESS in 52m 24s
ansible-test-network-integration-junos-vsrx-network_cli-python36-stable29 FAILURE in 13m 19s (non-voting)
✔️ ansible-test-network-integration-junos-vsrx-network_cli-python36-stable211 SUCCESS in 17m 16s
✔️ ansible-test-network-integration-junos-vsrx-network_cli-python39-stable212 SUCCESS in 15m 34s
✔️ ansible-test-network-integration-junos-vsrx-network_cli-python39 SUCCESS in 16m 11s
ansible-test-network-integration-junos-vsrx-network_cli-libssh-python36-stable29 FAILURE in 28m 34s (non-voting)
✔️ ansible-test-network-integration-junos-vsrx-network_cli-libssh-python36-stable211 SUCCESS in 18m 21s
ansible-test-network-integration-junos-vsrx-network_cli-libssh-python39-stable212 FAILURE in 13m 38s
✔️ ansible-test-network-integration-junos-vsrx-network_cli-libssh-python39 SUCCESS in 17m 43s
✔️ ansible-test-network-integration-nxos-cli-python39-scenario01 SUCCESS in 29m 41s (non-voting)
✔️ ansible-test-network-integration-nxos-cli-python39-scenario02 SUCCESS in 36m 06s (non-voting)
✔️ ansible-test-network-integration-nxos-cli-python39-scenario03 SUCCESS in 33m 11s (non-voting)
✔️ ansible-test-network-integration-nxos-cli-python39-scenario04 SUCCESS in 35m 16s (non-voting)
✔️ ansible-test-network-integration-eos-network_cli-python39 SUCCESS in 54m 39s (non-voting)
✔️ ansible-test-network-integration-eos-httpapi-python39 SUCCESS in 43m 18s (non-voting)
✔️ ansible-test-network-integration-eos-network_cli-libssh-python39 SUCCESS in 54m 16s (non-voting)
ansible-ee-integration-ios-latest FAILURE in 16m 45s (non-voting)
ansible-ee-integration-ios-stable-2.9 FAILURE in 15m 51s (non-voting)
ansible-ee-integration-ios-stable-2.11 FAILURE in 15m 50s (non-voting)
ansible-ee-integration-ios-stable-2.12 FAILURE in 16m 33s (non-voting)
ansible-ee-integration-ios-libssh-latest FAILURE in 42m 40s (non-voting)
ansible-ee-integration-ios-libssh-stable-2.9 FAILURE in 39m 29s (non-voting)
ansible-ee-integration-ios-libssh-stable-2.11 FAILURE in 44m 57s (non-voting)
ansible-ee-integration-ios-libssh-stable-2.12 FAILURE in 45m 21s (non-voting)
ansible-test-network-integration-vyos-paramiko-python39-devel NODE_FAILURE Node request 200-0006097509 failed in 0s
ansible-test-network-integration-vyos-paramiko-python39-stable214 NODE_FAILURE Node request 200-0006097510 failed in 0s
ansible-test-network-integration-vyos-paramiko-python39-stable213 NODE_FAILURE Node request 200-0006097511 failed in 0s
ansible-test-network-integration-vyos-paramiko-python39-stable212 NODE_FAILURE Node request 200-0006097512 failed in 0s
ansible-test-network-integration-vyos-paramiko-python36-stable29 NODE_FAILURE Node request 200-0006097513 failed in 0s (non-voting)
ansible-test-network-integration-vyos-libssh-python39-devel NODE_FAILURE Node request 200-0006097514 failed in 0s
ansible-test-network-integration-vyos-libssh-python39-stable214 NODE_FAILURE Node request 200-0006097515 failed in 0s
ansible-test-network-integration-vyos-libssh-python39-stable213 NODE_FAILURE Node request 200-0006097516 failed in 0s
ansible-test-network-integration-vyos-libssh-python39-stable212 NODE_FAILURE Node request 200-0006097517 failed in 0s
ansible-test-network-integration-vyos-libssh-python36-stable29 NODE_FAILURE Node request 200-0006097518 failed in 0s
✔️ build-ansible-collection SUCCESS in 14m 29s
ansible-test-network-integration-ansible-netcommon-junos-vsrx-netconf-python39 RETRY_LIMIT in 9m 21s
✔️ ansible-tox-linters SUCCESS in 10m 51s
✔️ ansible-galaxy-importer SUCCESS in 4m 06s

@Qalthos Qalthos merged commit e7267c5 into ansible-collections:main Jun 14, 2023
67 of 68 checks passed
@felixfontein felixfontein deleted the libssh-fix branch June 14, 2023 17:37
@felixfontein
Copy link
Contributor Author

@Qalthos thanks for reviewing and merging!

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.

None yet

2 participants