ansible installation on Mac issue

59 views
Skip to first unread message

dmastrop

unread,
Aug 7, 2023, 10:45:07 AM8/7/23
to Ansible Project
hi all

I have an issue with the ansible installation on Mac.
I was able to install ansible without issue on a Cloud9 ubuntu compute instance, EC2 instances, etc, but I am having a permissions issue on the Mac.



I have to run with sudo 
With sudo this is the ansibile --version

% sudo ansible --version
Password:
ansible [core 2.15.2]
  config file = None
  configured module search path = ['/Users/xxxx/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/ansible
  ansible collection location = /Users/xxxx/.ansible/collections:/usr/share/ansible/collections
  executable location = /Library/Frameworks/Python.framework/Versions/3.11/bin/ansible
  python version = 3.11.4 (v3.11.4:d2340ef257, Jun  6 2023, 19:15:51) [Clang 13.0.0 (clang-1300.0.29.30)] (/Library/Frameworks/Python.framework/Versions/3.11/bin/python3.11)
  jinja version = 3.1.2

  libyaml = True




I am logged into the Mac as user xxxx with administrator privileges.



when I run the ansible version without sudo I get the following backtrace.  (I don't know why it is referencing python 3.7. It initially installed with module location of 3.7 but that was fixed and from output above it has the 3.11 module location).




% ansible --version

Unhandled error:

Traceback (most recent call last):

  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/ansible/config/manager.py", line 605, in update_config_data

    value, origin = self.get_config_value_and_origin(config, configfile)

  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/ansible/config/manager.py", line 543, in get_config_value_and_origin

    value = ensure_type(value, defs[config].get('type'), origin=origin)

  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/ansible/config/manager.py", line 124, in ensure_type

    value = tempfile.mkdtemp(prefix=prefix, dir=value)

  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/tempfile.py", line 366, in mkdtemp

    _os.mkdir(file, 0o700)

PermissionError: [Errno 13] Permission denied: '/Users/xxxx/.ansible/tmp/ansible-local-506222opmhr9x'

 

 

Traceback (most recent call last):

  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/ansible/config/manager.py", line 605, in update_config_data

    value, origin = self.get_config_value_and_origin(config, configfile)

  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/ansible/config/manager.py", line 543, in get_config_value_and_origin

    value = ensure_type(value, defs[config].get('type'), origin=origin)

  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/ansible/config/manager.py", line 124, in ensure_type

    value = tempfile.mkdtemp(prefix=prefix, dir=value)

  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/tempfile.py", line 366, in mkdtemp

    _os.mkdir(file, 0o700)

PermissionError: [Errno 13] Permission denied: '/Users/xxxx/.ansible/tmp/ansible-local-506222opmhr9x'

 

During handling of the above exception, another exception occurred:

 

Traceback (most recent call last):

  File "/Library/Frameworks/Python.framework/Versions/3.7/bin//ansible", line 63, in <module>

    import ansible.constants as C

  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/ansible/constants.py", line 181, in <module>

    config = ConfigManager()

  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/ansible/config/manager.py", line 310, in __init__

    self.update_config_data()

  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/ansible/config/manager.py", line 617, in update_config_data

    raise AnsibleError("Invalid settings supplied for %s: %s\n" % (config, to_native(e)), orig_exc=e)

ansible.errors.AnsibleError: Invalid settings supplied for DEFAULT_LOCAL_TMP: [Errno 13] Permission denied: '/Users/xxxx/.ansible/tmp/ansible-local-506222opmhr9x'

. [Errno 13] Permission denied: '/Users/xxxx/.ansible/tmp/ansible-local-506222opmhr9x'








It seems to be an issue with this tmp directory:

 

'/Users/xxxx/.ansible/tmp/ansible-local-506222opmhr9x'

 

I tried getting into the this tmp directory and get permission denied as it is owned by root

 

% ls -la

total 0

drwxr-xr-x   4 root            staff   128 May 23 18:01 .

drwxr-xr-x+ 50 xxx  staff  1600 Aug  3 18:08 ..

drwx------   2 root            staff    64 May 23 18:02 cp

drwx------   2 root            staff    64 Aug  3 18:23 tmp



Is there a fix for this?


warm regards

Dave



Dick Visser

unread,
Aug 7, 2023, 12:11:53 PM8/7/23
to ansible...@googlegroups.com
You should not need to run ansible as root, nor should you have other
administrative privileges for running it.
Also the installation with pip should not need root/admin:
Follow https://docs.ansible.com/ansible/latest/installation_guide/intro_installation.html#installing-and-upgrading-ansible-with-pip
> --
> You received this message because you are subscribed to the Google Groups "Ansible Project" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/0f41a82e-cf87-4290-b9c3-487ba54821c2n%40googlegroups.com.

dmastrop

unread,
Aug 7, 2023, 10:25:12 PM8/7/23
to Ansible Project
Hi Dick

Thanks.

I had tried installing based on the docs last week and just tried again and see the below output.

 I think I need to uninstall the current installation so that I can do a clean install.


======
 % python3 -m pip -V
pip 23.1.2 from /Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/pip (python 3.11)


python3 -m pip install --user ansible
Requirement already satisfied: ansible in /Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages (8.2.0)
Requirement already satisfied: ansible-core~=2.15.2 in /Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages (from ansible) (2.15.2)
Requirement already satisfied: jinja2>=3.0.0 in /Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages (from ansible-core~=2.15.2->ansible) (3.1.2)
Requirement already satisfied: PyYAML>=5.1 in /Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages (from ansible-core~=2.15.2->ansible) (6.0.1)
Requirement already satisfied: cryptography in /Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages (from ansible-core~=2.15.2->ansible) (41.0.3)
Requirement already satisfied: packaging in /Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages (from ansible-core~=2.15.2->ansible) (23.1)
Requirement already satisfied: resolvelib<1.1.0,>=0.5.3 in /Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages (from ansible-core~=2.15.2->ansible) (1.0.1)
Requirement already satisfied: MarkupSafe>=2.0 in /Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages (from jinja2>=3.0.0->ansible-core~=2.15.2->ansible) (2.1.3)
Requirement already satisfied: cffi>=1.12 in /Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages (from cryptography->ansible-core~=2.15.2->ansible) (1.15.1)
Requirement already satisfied: pycparser in /Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages (from cffi>=1.12->cryptography->ansible-core~=2.15.2->ansible) (2.21)

[notice] A new release of pip is available: 23.1.2 -> 23.2.1
[notice] To update, run: pip3 install --upgrade pip




I also tried an upgrade python3 -m pip install --upgrade --user ansible 
But I get the same output as above


So I need to uninstall the current 8.2.0 package.

======




% python3 -m pip list
Package      Version
------------ --------
ansible      8.2.0
ansible-core 2.15.2
certifi      2023.5.7
cffi         1.15.1
cryptography 41.0.3
Jinja2       3.1.2
MarkupSafe   2.1.3
packaging    23.1
pip          23.1.2
pycparser    2.21
PyYAML       6.0.1
resolvelib   1.0.1
setuptools   65.5.0

[notice] A new release of pip is available: 23.1.2 -> 23.2.1
[notice] To update, run: pip3 install --upgrade pip

====================

I tried running the command below without sudo but get permissions errors(see below)

Should I attempt to uninstall the current 8.2.0 package using sudo, i.e.,

Sudo python3 -m pip uninstall ansible   ?





=============

Here is the NON-sudo 

Python3 -m pip uninstall ansible

Proceed (Y/n)? y

ERROR: Exception:

Traceback (most recent call last):

  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/shutil.py", line 825, in move

    os.rename(src, real_dst)

PermissionError: [Errno 13] Permission denied: '/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/ansible-8.2.0.dist-info/' -> '/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/~nsible-8.2.0.dist-info'

 

During handling of the above exception, another exception occurred:

 

Traceback (most recent call last):

  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/pip/_internal/cli/base_command.py", line 169, in exc_logging_wrapper

    status = run_func(*args)

             ^^^^^^^^^^^^^^^

  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/pip/_internal/commands/uninstall.py", line 105, in run

    uninstall_pathset = req.uninstall(

                        ^^^^^^^^^^^^^^

  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/pip/_internal/req/req_install.py", line 680, in uninstall

    uninstalled_pathset.remove(auto_confirm, verbose)

  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/pip/_internal/req/req_uninstall.py", line 381, in remove

    moved.stash(path)

  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/pip/_internal/req/req_uninstall.py", line 272, in stash

    renames(path, new_path)

  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/pip/_internal/utils/misc.py", line 313, in renames

    shutil.move(old, new)

  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/shutil.py", line 838, in move

    raise PermissionError("Cannot move the non-empty directory "

PermissionError: Cannot move the non-empty directory '/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/ansible-8.2.0.dist-info/': Lacking write permission to '/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/ansible-8.2.0.dist-info/'.






Warm regards
Dave
Reply all
Reply to author
Forward
0 new messages