Ansible's paths crossed? or need to install python 3 in right folder?

81 views
Skip to first unread message

Kristina Bressler

unread,
Mar 24, 2021, 12:51:16 AM3/24/21
to Ansible Project
Was trying to fix a problem in my project with Vagrant. I got this error:
`System info:
  Ansible 2.7.1; Vagrant 2.2.14; Darwin
  Trellis 1.0.3: April 30th, 2019
---------------------------------------------------
MODULE FAILURE
See stdout/stderr for the exact error
Traceback (most recent call last):
  File "<stdin>", line 113, in <module>
  File "<stdin>", line 105, in _ansiballz_main
  File "<stdin>", line 48, in invoke_module
  File "/usr/lib/python3.6/imp.py", line 235, in load_module
    return load_source(name, filename, file)
  File "/usr/lib/python3.6/imp.py", line 170, in load_source
    module = _exec(spec, sys.modules[name])
  File "<frozen importlib._bootstrap>", line 618, in _exec
  File "<frozen importlib._bootstrap_external>", line 678, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in
_call_with_frames_removed
  File "/tmp/ansible_setup_payload_1p7_kmoy/__main__.py", line 127, in
<module>
ImportError: attempted relative import with no known parent package

An exception occurred during task execution. To see the full traceback, use -vvv. The error was: ImportError: attempted relative import with no known parent package
fatal: [default]: FAILED! => {"changed": false, "module_stdout": "", "rc": 1}
to retry, use: --limit @/Users/kiki/Code/project/trellis/dev.retry

PLAY RECAP *********************************************************************
default                    : ok=2    changed=0    unreachable=0    failed=1

/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/multiprocessing/resource_tracker.py:216: UserWarning: resource_tracker: There appear to be 78 leaked semaphore objects to clean up at shutdown
  warnings.warn('resource_tracker: There appear to be %d '
Ansible failed to complete successfully. Any error output should be
visible above. Please fix these errors and try again.`

I looked in my folders at /usr/lib/ and I don't see python3 folder in this location. I can only find python2.7 folder. I even ran brew install python to install the latest version and I can see that it's downloading to /usr/local/lib/ where I can see two folders, python2.7 and python3.9.

So the conclusion I got was that Ansible was trying to find python3 in wrong folder? So I think I have 2 options:

  1. try to brew install python in /usr/lib
  2. try to fix the Ansible's path to point to or find in usr/local/lib

So how do I do either one of the options or which is the best/alternative option?

Do I type in the command line "ansible_python_interpreter = usr/local/lib"?

My ansible version is 2.7.1. 

My pip3 version is pip 21.0.1 from /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/pip (python 3.9)

Sincerely,

Kristina

Brian Coca

unread,
Mar 24, 2021, 3:22:43 PM3/24/21
to Ansible Project
I suspect you are not suing teh ansible supplied 'setup.py', try
executing with -vvvv and look for 'Using module file ...' in the
output.
If what im' guessing is correct you have a 'library' directory
adjacent to play that is proving the 'right names' but incorrect code.


--
----------
Brian Coca

Kristina Bressler

unread,
Mar 29, 2021, 12:41:45 PM3/29/21
to Ansible Project
Hi,
I'm not sure what you mean. 
So what I can gather from your message is what I did:
1. type in ansible -vvvv
2. I don't see anything like "Using module file..."
3. What I'm seeing are Module_Path: prepend colon-separated path(s) to module library
                        (default=['/Users/kiki/.ansible/plugins/modules',
                        '/usr/share/ansible/plugins/modules'])
4. I also see at the end 
Some modules do not make sense in Ad-Hoc (include, meta, etc)
ERROR! Missing target hosts

Do I copy over the python3.9 folder over to /usr/lib from /usr/local/lib?

-Kristina

Kristina Bressler

unread,
Mar 29, 2021, 12:58:03 PM3/29/21
to Ansible Project
Hi,
Additionally, everything was fine when I start up a project with "vagrant up" but when I checked with "vagrant provision", I got this error mentioned in my first email.  I was just wondering if "vagrant provision" does play a role in getting this error?

-Kristina

Brian Coca

unread,
Mar 30, 2021, 12:46:07 PM3/30/21
to Ansible Project
Something is injecting a 'setup.py' into the modules path that is not
the same setup.py as ansible uses for fact gathering. I would start
with new simple install and add layers until you find what causes it.

--
----------
Brian Coca

Reply all
Reply to author
Forward
0 new messages