ansible-collections / community.routeros

Ansible modules for managing MikroTik RouterOS instances.
https://galaxy.ansible.com/ui/repo/published/community/routeros/
GNU General Public License v3.0
96 stars 45 forks source link

Problem with basic example from readme: Tries to find python interpreter on RouterOS #25

Closed gitatr closed 3 years ago

gitatr commented 3 years ago

Please raise issues via the new interface If I copy&paste the current inventory (ip and creds updated) and playbook example from the readme I get the following error message:

[WARNING]: Platform linux on host router is using the discovered Python interpreter at /usr/bin/python2.7, but future installation of another Python interpreter could change the meaning of that path. See
https://docs.ansible.com/ansible/2.10/reference_appendices/interpreter_discovery.html for more information.
fatal: [router]: FAILED! => {"ansible_facts": {"discovered_interpreter_python": "/usr/bin/python2.7"}, "changed": false, "msg": "paramiko is not installed: No module named 'paramiko'"}

The versions I am using:

Router:

admin@MikroTik] /system> routerboard print 
       routerboard: yes
  model: 951G-2HnD
  firmware-type: ar9344
  factory-firmware: 3.33
  current-firmware: 6.43.2
  upgrade-firmware: 6.44
gitatr commented 3 years ago

Ok, I installed paramiko in the Python 3.8.5 venv (!) which solves this specific part of the error. Messages regarding python2.7 still confusing. I now get authentication failed:

[WARNING]: Platform linux on host router is using the discovered Python interpreter at /usr/bin/python2.7, but future installation of another Python interpreter could change the meaning of that path. See
https://docs.ansible.com/ansible/2.10/reference_appendices/interpreter_discovery.html for more information.
fatal: [router]: FAILED! => {"ansible_facts": {"discovered_interpreter_python": "/usr/bin/python2.7"}, "changed": false, "msg": "Failed to authenticate: Authentication failed."}

Which is more than strange. I use ssh-agent and pubkey auth. running this python script (same env, (same shell in fact)):

import paramiko
client = paramiko.SSHClient()
client.set_missing_host_key_policy(paramiko.AutoAddPolicy())

client.connect("192.168.88.1", username="admin")

stdin, stdout, stderr = client.exec_command("/system resource print")
for line in stdout:
    print(line)

Works absolutely fine (sry for spaces):

$ python paramikotest.py 
                   uptime: 4w1d13h48m54s

                  version: 6.44 (stable)

               build-time: Feb/25/2019 14:11:04

         factory-software: 6.34.4

              free-memory: 101.6MiB

             total-memory: 128.0MiB

                      cpu: MIPS 74Kc V4.12

                cpu-count: 1

            cpu-frequency: 600MHz

                 cpu-load: 11%

           free-hdd-space: 109.7MiB

          total-hdd-space: 128.0MiB

  write-sect-since-reboot: 244626

         write-sect-total: 279947

               bad-blocks: 0%

        architecture-name: mipsbe

               board-name: RB951G-2HnD

                 platform: MikroTik
gitatr commented 3 years ago

And just to make sure there is no confusion about local(!) interpreters:

$ python2.7 paramikotest.py 
Traceback (most recent call last):
  File "paramikotest.py", line 1, in <module>
    import paramiko
ImportError: No module named paramiko
heuels commented 3 years ago

Hey @gitatr, thanks for raising this!

I just looked at my hosts file and this is what I used to suppress the warning on my RouterOS devices: (please excuse my yaml — you'll probably have the hosts file in other format)

all:
  children:
    example:
      hosts:
        example.briskhome.com:
          ansible_host: 192.168.88.1
          ansible_user: ansible+cet1024w
          ansible_ssh_pass: ansible
          ansible_network_os: routeros
          ansible_connection: network_cli
          connection: network_cli
          gather_facts: no
          ansible_python_interpreter: auto_silent
gitatr commented 3 years ago

Thx for your reply! These settings helped! I can now run things on Mikrotiks that I can access directly without jump host etc.