Cannot import customered module in module_utils in rhel8

Skip to first unread message

jianhan MA

Nov 1, 2021, 5:19:48 AM11/1/21
to Ansible Development
When I try use my own module in rhel8 based on,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?

lib dir: /home/dev/platformx_core_4.4/sdk/library/
module_utils dir: /home/dev/platformx_core_4.4/sdk/module_utils/
the code in
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)]
Reply all
Reply to author
0 new messages