Cannot import customered module in module_utils in rhel8

Visto 88 veces
Saltar al primer mensaje no leído

jianhan MA

no leída,
1 nov 2021, 5:19:481/11/21
a Ansible Development
When I try use my own module in rhel8 based on https://docs.ansible.com/ansible/latest/dev_guide/developing_module_utilities.html#:~:text=Ansible%20provides%20a%20number%20of%20module%20utilities%2C%20or,Python%20Ansible%20modules%20must%20import%20something%20from%20ansible.module_utils.
it shows me an error called:
Unable to import sdk_shared(my own function) due to invalid syntax
However it can be worked in rhel7, it seems because rhel8 is using python3 and rhel7 is using python2.
But the import function should not has difference between python2 and 3, could someone give me a suggestion?

Environment:
lib dir: /home/dev/platformx_core_4.4/sdk/library/yum_repo_snapshot.py
module_utils dir: /home/dev/platformx_core_4.4/sdk/module_utils/sdk_shared.py
the code in yum_repo_snapshot.py:
from ansible.module_utils.sdk_shared import *

ansible 2.9.25 config file = /etc/ansible/ansible.cfg configured module search path = ['/root/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules'] ansible python module location = /usr/lib/python3.6/site-packages/ansible executable location = /usr/bin/ansible python version = 3.6.8 (default, Aug 12 2021, 07:06:15) [GCC 8.4.1 20200928 (Red Hat 8.4.1-1)]
Responder a todos
Responder al autor
Reenviar
0 mensajes nuevos