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

issue with community.routeros.command and community.routeros.facts when there is a dash in the username #17

Closed
agpy opened this issue Dec 23, 2020 · 3 comments · Fixed by #18

Comments

@agpy
Copy link

agpy commented Dec 23, 2020

SUMMARY

If the username contains a dash "-" (something like "ssh-admin"), the connection timeout error will appear.

ISSUE TYPE
  • Bug Report
COMPONENT NAME
ANSIBLE VERSION
2.9.16 and 2.10.2
CONFIGURATION
DEFAULT_ASK_PASS(/home/phil/ansible/ansible.cfg) = False
DEFAULT_HOST_LIST(/home/phil/ansible/ansible.cfg) = ['/home/phil/ansible/myhosts']
DEPRECATION_WARNINGS(/home/phil/ansible/ansible.cfg) = False
OS / ENVIRONMENT

Debian buster

STEPS TO REPRODUCE

Make the username with a dash inside it (eg ssh-admin) for login on routeros device. And then try to start playbook with him.

- name: RouterOS test with network_cli connection
  hosts: mikrotik_server
  gather_facts: false
  tasks:

   - community.routeros.command:
      commands:
        - /system resource print
    register: system_resource_print
  - debug:
      var: system_resource_print.stdout_lines

 - community.routeros.facts:
  - debug:
      msg: "First IP address: {{ ansible_net_all_ipv4_addresses[0] }}"
EXPECTED RESULTS

PLAY [RouterOS test with network_cli connection] ************************************************************************************************************

TASK [community.routeros.command] ***************************************************************************************************************************
ok: [172.16.10.172]

TASK [debug] ************************************************************************************************************************************************
ok: [172.16.10.172] => {
"system_resource_print.stdout_lines": [
[
"uptime: 1w3d23h36m54s",
" version: 6.46.8 (long-term)",
" build-time: Oct/29/2020 08:29:55",
" free-memory: 189.3MiB",
" total-memory: 224.0MiB",
" cpu: Intel(R)",
" cpu-count: 4",
" cpu-frequency: 2400MHz",
" cpu-load: 0%",
" free-hdd-space: 31.3MiB",
" total-hdd-space: 63.5MiB",
" write-sect-since-reboot: 3600",
" write-sect-total: 3601",
" architecture-name: x86_64",
" board-name: CHR",
" platform: MikroTik"
]
]
}

TASK [community.routeros.facts] *****************************************************************************************************************************
ok: [172.16.10.172]

TASK [debug] ************************************************************************************************************************************************
ok: [172.16.10.172] => {
"msg": "First IP address: 172.16.10.172"
}

PLAY RECAP **************************************************************************************************************************************************
172.16.10.172 : ok=4 changed=0 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0

ACTUAL RESULTS

The full traceback is:
File "/tmp/ansible_community.routeros.command_payload_jqwdps2f/ansible_community.routeros.command_payload.zip/ansible_collections/community/routeros/plugins/module_utils/routeros.py", line 74, in get_capabilities
capabilities = Connection(module._socket_path).get_capabilities()
File "/tmp/ansible_community.routeros.command_payload_jqwdps2f/ansible_community.routeros.command_payload.zip/ansible/module_utils/connection.py", line 195, in rpc
raise ConnectionError(to_text(msg, errors='surrogate_then_replace'), code=code)
fatal: [172.16.10.172]: FAILED! => {
"ansible_facts": {
"discovered_interpreter_python": "/usr/bin/python"
},
"changed": false,
"invocation": {
"module_args": {
"commands": [
"/system resource print"
],
"interval": 1,
"match": "all",
"retries": 10,
"wait_for": null
}
},
"msg": "timeout value 30 seconds reached while trying to send command: b'/system resource print'"
}


@felixfontein
Copy link
Collaborator

Did you see https://github.com/ansible-collections/community.routeros#prerequisites ? Maybe it's because of that.

@agpy
Copy link
Author

agpy commented Dec 23, 2020

Thank you, I verify identities on my devices and they are ok (have not arbitrary symbols). Problem appears if I insert dash in the username. If I remove a dash from the username the problem goes away.

@heuels
Copy link
Collaborator

heuels commented Dec 23, 2020

@felixfontein, I guess we could support that — most operating systems allow alphanumeric characters, underscores and hyphens in the username. Will open a PR tomorrow, if you don't mind.

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 a pull request may close this issue.

3 participants