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

Bad Ansible integration #26

Closed
innofocus opened this issue Jan 29, 2018 · 5 comments
Closed

Bad Ansible integration #26

innofocus opened this issue Jan 29, 2018 · 5 comments

Comments

@innofocus
Copy link

While embedded Tests were working well, once trying to use the module in a real env, ansible isn't able to find the module, even with module _utils settled:
Exception type: class ansible.errors.AnsibleParserError

Hint : the module_utils setting is a bad idea since it may break other modules environment.

@zahodi
Copy link
Owner

zahodi commented Jan 29, 2018

@innofocus what Ansible version are you running and how are you including the mikrotik modules in your environment?

@innofocus
Copy link
Author

innofocus commented Jan 30, 2018 via email

@zahodi
Copy link
Owner

zahodi commented Jan 30, 2018

@innofocus. I just tested in my environment on 2.3.3.0, 2.4.0.0, and 2.4.2.0 with no issues.
We are setting up our ANSIBLE_MODULE_UTILS in our environment:
export ANSIBLE_MODULE_UTILS='./ansible-mikrotik/pythonlibs/'

See if that works for you.

@fairytaletrash
Copy link

fairytaletrash commented Mar 26, 2018

I'm also struggling to get this module working and any assistance would be appreciated. I'm fairly new to ansible (only been looking at it for a couple of days now) so am probably missing something incredibly obvious to a more seasoned user.

Running ansible 2.4.2 on centos 7.4 with python 2.7.5
python and ansible installed from yum

this module cloned into /usr/share/my_modules/ansible-mikrotik

PYTHONPATH previously unset. Now set to /usr/share/my_modules/ansible-mikrotik/pythonlibs

echo $PYTHONPATH
/usr/share/my_modules/ansible-mikrotik/pythonlibs

creating a separate role that currently only has one task that i basically copied from the tests

---
- name: set interface comment
  mt_interfaces:
    hostname: "{{ inventory_hostname }}"
    username: "{{ mt_user }}"
    password: "{{ mt_pass }}"
    settings: "{{ item.settings }}"
    parameter: "ethernet"
  with_items:
    - settings:
      name: ether1
      comment: "Ansible controlled ether1"

running ansible-playback gives 'could not find imported module support code' error:

ansible-playbook routers.yml -vvvv

ansible-playbook 2.4.2.0
  config file = /etc/ansible/ansible.cfg
  configured module search path = [u'/usr/share/my_modules']
  ansible python module location = /usr/lib/python2.7/site-packages/ansible
  executable location = /usr/bin/ansible-playbook
  python version = 2.7.5 (default, Aug  4 2017, 00:39:18) [GCC 4.8.5 20150623 (Red Hat 4.8.5-16)]
Using /etc/ansible/ansible.cfg as config file
setting up inventory plugins
Parsed /etc/ansible/hosts inventory source with ini plugin
Loading callback plugin default of type stdout, v2.0 from /usr/lib/python2.7/site-packages/ansible/plugins/callback/__init__.pyc

PLAYBOOK: routers.yml ***************************************************************************************************************************************************************

1 plays in routers.yml

PLAY [192.168.88.1] *****************************************************************************************************************************************************************

META: ran handlers

TASK [mikrotik : set ip address] ****************************************************************************************************************************************************

task path: /etc/ansible/roles/mikrotik/tasks/main.yml:2
fatal: [192.168.88.1]: FAILED! => {
    "msg": "Could not find imported module support code for mt_interfaces.  Looked for either MikrotikIdempotent.py or mt_common.py"
}
        to retry, use: --limit @/etc/ansible/routers.retry

PLAY RECAP **************************************************************************************************************************************************************************

192.168.88.1               : ok=0    changed=0    unreachable=0    failed=1

I'm targeting an actual mikrotik device, not the vagrant simulation. Using a mAP 2nD (https://mikrotik.com/product/RBmAP2nD)

@zahodi
Copy link
Owner

zahodi commented Mar 26, 2018

Hi @fairytaletrash, it looks like you are not actually import the mikrotik module libraries properly. They should be in /library or in your roles/role/library

@zahodi zahodi closed this as completed Jun 8, 2022
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

No branches or pull requests

3 participants