Coder Social home page Coder Social logo

ERROR! couldn't resolve module/action 'pm2'. This often indicates a misspelling, missing collection, or incorrect module path. about ansible-modules-pm2 HOT 12 CLOSED

10sr avatar 10sr commented on June 23, 2024
ERROR! couldn't resolve module/action 'pm2'. This often indicates a misspelling, missing collection, or incorrect module path.

from ansible-modules-pm2.

Comments (12)

10sr avatar 10sr commented on June 23, 2024

It may fail if ansible and ansible-modules-pm2 has been installed in other environments...

Could you paste the result of following? :

>>> from importlib.util import find_spec
>>> find_spec("ansible.modules.pm2").origin
>>> find_spec("ansible").origin

from ansible-modules-pm2.

amitdah4 avatar amitdah4 commented on June 23, 2024

Below output is from python 3.6 ... Ansible is using python 3.6

[root@ansible-tower ~]# python3.6
Python 3.6.8 (default, Dec  5 2019, 15:45:45)
[GCC 8.3.1 20191121 (Red Hat 8.3.1-5)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from importlib.util import find_spec
>>> find_spec("ansible.modules.pm2").origin
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'NoneType' object has no attribute 'origin'
>>> find_spec("ansible").origin
'/usr/lib/python3.6/site-packages/ansible/__init__.py'

from ansible-modules-pm2.

amitdah4 avatar amitdah4 commented on June 23, 2024

When I try to install this module from anaconda directory.. I am getting ok output.

[root@ansible-tower bin]# ./pip install ansible-modules-pm2
Collecting ansible-modules-pm2
  Using cached ansible_modules_pm2-0.1.0-py3-none-any.whl (18 kB)
Requirement already satisfied: ansible>=2.2.0 in /root/anaconda3/lib/python3.8/site-packages (from ansible-modules-pm2) (2.9.12)
Requirement already satisfied: cryptography in /root/anaconda3/lib/python3.8/site-packages (from ansible>=2.2.0->ansible-modules-pm2) (2.9.2)
Requirement already satisfied: PyYAML in /root/anaconda3/lib/python3.8/site-packages (from ansible>=2.2.0->ansible-modules-pm2) (5.3.1)
Requirement already satisfied: jinja2 in /root/anaconda3/lib/python3.8/site-packages (from ansible>=2.2.0->ansible-modules-pm2) (2.11.2)
Requirement already satisfied: six>=1.4.1 in /root/anaconda3/lib/python3.8/site-packages (from cryptography->ansible>=2.2.0->ansible-modules-pm2) (1.15.0)
Requirement already satisfied: cffi!=1.11.3,>=1.8 in /root/anaconda3/lib/python3.8/site-packages (from cryptography->ansible>=2.2.0->ansible-modules-pm2) (1.14.0)
Requirement already satisfied: MarkupSafe>=0.23 in /root/anaconda3/lib/python3.8/site-packages (from jinja2->ansible>=2.2.0->ansible-modules-pm2) (1.1.1)
Requirement already satisfied: pycparser in /root/anaconda3/lib/python3.8/site-packages (from cffi!=1.11.3,>=1.8->cryptography->ansible>=2.2.0->ansible-modules

Below output is from Anaconda python

root@ansible-tower ~]# python
Python 3.8.3 (default, Jul  2 2020, 16:21:59)
[GCC 7.3.0] :: Anaconda, Inc. on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from importlib.util import find_spec
>>> find_spec("ansible.modules.pm2").origin
'/root/anaconda3/lib/python3.8/site-packages/ansible/modules/pm2/__init__.py'
>>> find_spec("ansible").origin
'/root/anaconda3/lib/python3.8/site-packages/ansible/__init__.py'

from ansible-modules-pm2.

10sr avatar 10sr commented on June 23, 2024

Umm... this module seems to be installed properly at least for python3.8...
What is the result of following?

which ansible-playbook  # path to the ansible-playbook executable you are using
head `which ansible-playbook`
ls -R /root/anaconda3/lib/python3.8/site-packages/ansible/modules/pm2

from ansible-modules-pm2.

amitdah4 avatar amitdah4 commented on June 23, 2024
[root@ansible-tower ~]# head `which ansible-playbook`
#!/root/anaconda3/bin/python
# -*- coding: utf-8 -*-
# (c) 2012, Michael DeHaan <[email protected]>
#
# This file is part of Ansible
#
# Ansible is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
[root@ansible-tower ~]# ls -R /root/anaconda3/lib/python3.8/site-packages/ansible/modules/pm2
/root/anaconda3/lib/python3.8/site-packages/ansible/modules/pm2:
__init__.py  pm2.py  __pycache__

/root/anaconda3/lib/python3.8/site-packages/ansible/modules/pm2/__pycache__:
__init__.cpython-38.pyc  pm2.cpython-38.pyc

from ansible-modules-pm2.

amitdah4 avatar amitdah4 commented on June 23, 2024

Let me try to change python interpreter for playbook.

from ansible-modules-pm2.

amitdah4 avatar amitdah4 commented on June 23, 2024

Ok... Playbook is working fine when I run it from terminal. And in the remote host service is working fine. No issue at all.

But when I try to run it using Ansible Tower... It start throwing errors. Below is code block

   - name: test
     pm2:
       name: myapp
       state: started
       chdir: /usr/share/nginx/test
       executable: /usr/bin/pm2
       script: /usr/share/nginx/test/test.js

Below is the error when I try to run same code from Tower
image

from ansible-modules-pm2.

amitdah4 avatar amitdah4 commented on June 23, 2024

I found the difference in Ansible output from Tower and Terminal.

Below is verbose output from terminal. It uses python 3.8

ansible-playbook -vvv -i hosts playbook.yaml
ansible-playbook 2.9.12
  config file = /etc/ansible/ansible.cfg
  configured module search path = ['/root/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /root/anaconda3/lib/python3.8/site-packages/ansible
  executable location = /root/anaconda3/bin/ansible-playbook
  python version = 3.8.3 (default, Jul  2 2020, 16:21:59) [GCC 7.3.0]
Using /etc/ansible/ansible.cfg as config file

From Tower, It is showing python 3.6...

ansible-playbook 2.9.11
  config file = /etc/ansible/ansible.cfg
  configured module search path = ['/var/lib/awx/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python3.6/site-packages/ansible
  executable location = /usr/bin/ansible-playbook
  python version = 3.6.8 (default, Dec  5 2019, 15:45:45) [GCC 8.3.1 20191121 (Red Hat 8.3.1-5)]
Using /etc/ansible/ansible.cfg as config file

from ansible-modules-pm2.

amitdah4 avatar amitdah4 commented on June 23, 2024

I am able to install pm2 module in python 3.6...

[root@ansible-tower modules]# pwd
/usr/lib/python3.6/site-packages/ansible/modules
pip3.6 uninstall  ansible-modules-pm2
Uninstalling ansible-modules-pm2-0.1.0:
  /usr/lib/python3.6/site-packages/ansible_modules_pm2-0.1.0.dist-info/INSTALLER
  /usr/lib/python3.6/site-packages/ansible_modules_pm2-0.1.0.dist-info/LICENSE
  /usr/lib/python3.6/site-packages/ansible_modules_pm2-0.1.0.dist-info/METADATA
  /usr/lib/python3.6/site-packages/ansible_modules_pm2-0.1.0.dist-info/RECORD
  /usr/lib/python3.6/site-packages/ansible_modules_pm2-0.1.0.dist-info/WHEEL
  /usr/lib/python3.6/site-packages/ansible_modules_pm2-0.1.0.dist-info/top_level.txt
Proceed (y/n)? y
  Successfully uninstalled ansible-modules-pm2-0.1.0
[root@ansible-tower modules]# pip3.6 install  ansible-modules-pm2 --force
WARNING: Running pip install with root privileges is generally not a good idea. Try `pip3.6 install --user` instead.
Collecting ansible-modules-pm2
  Using cached https://files.pythonhosted.org/packages/d3/12/78872d9eb96716c8075c4627e1f97961ea38fb8a38669230e9182bdb2bba/ansible_modules_pm2-0.1.0-py3-none-any.whl
Requirement already satisfied: ansible>=2.2.0 in /usr/lib/python3.6/site-packages (from ansible-modules-pm2)
Requirement already satisfied: cryptography in /usr/lib64/python3.6/site-packages (from ansible>=2.2.0->ansible-modules-pm2)
Requirement already satisfied: PyYAML in /usr/lib64/python3.6/site-packages (from ansible>=2.2.0->ansible-modules-pm2)
Requirement already satisfied: jinja2 in /usr/lib/python3.6/site-packages (from ansible>=2.2.0->ansible-modules-pm2)
Requirement already satisfied: idna>=2.1 in /usr/lib/python3.6/site-packages (from cryptography->ansible>=2.2.0->ansible-modules-pm2)
Requirement already satisfied: asn1crypto>=0.21.0 in /usr/lib/python3.6/site-packages (from cryptography->ansible>=2.2.0->ansible-modules-pm2)
Requirement already satisfied: six>=1.4.1 in /usr/lib/python3.6/site-packages (from cryptography->ansible>=2.2.0->ansible-modules-pm2)
Requirement already satisfied: cffi!=1.11.3,>=1.7 in /usr/lib64/python3.6/site-packages (from cryptography->ansible>=2.2.0->ansible-modules-pm2)
Requirement already satisfied: MarkupSafe>=0.23 in /usr/lib64/python3.6/site-packages (from jinja2->ansible>=2.2.0->ansible-modules-pm2)
Requirement already satisfied: pycparser in /usr/lib/python3.6/site-packages (from cffi!=1.11.3,>=1.7->cryptography->ansible>=2.2.0->ansible-modules-pm2)
Installing collected packages: ansible-modules-pm2
Successfully installed ansible-modules-pm2-0.1.0
[root@ansible-tower modules]# python3.6
Python 3.6.8 (default, Dec  5 2019, 15:45:45)
[GCC 8.3.1 20191121 (Red Hat 8.3.1-5)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from importlib.util import find_spec
>>> find_spec("ansible.modules.pm2").origin
'/usr/lib/python3.6/site-packages/ansible/modules/ansible/modules/pm2/__init__.py'

But now I am start getting:- "msg": "module (pm2) is missing interpreter line",

from ansible-modules-pm2.

amitdah4 avatar amitdah4 commented on June 23, 2024

@10sr Issue fixed. For Ansible tower: User need to source the awx env using below command before any pip package installation.

[root@ansible-tower test]# . /var/lib/awx/venv/ansible/bin/activate

pip3.6 install  ansible-modules-pm2 --force

Now Tower is working fine. No error or exception.

Thank you @10sr ..

from ansible-modules-pm2.

amitdah4 avatar amitdah4 commented on June 23, 2024

Please close the ticket.

from ansible-modules-pm2.

10sr avatar 10sr commented on June 23, 2024

Great! Thank you for your tries and detailed comments!
I'm thinking of documenting this in README...

from ansible-modules-pm2.

Related Issues (5)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.