Reputation: 261
Good Day guys
I have installed ansible on my mac, it was successfully installed but then when I run the command ansible --version
it throws me a n error:
Unhandled error:
Traceback (most recent call last):
File "/Library/Python/2.7/site-packages/ansible/config/manager.py", line 559, in update_config_data
value, origin = self.get_config_value_and_origin(config, configfile)
File "/Library/Python/2.7/site-packages/ansible/config/manager.py", line 503, in get_config_value_and_origin
value = ensure_type(value, defs[config].get('type'), origin=origin)
File "/Library/Python/2.7/site-packages/ansible/config/manager.py", line 124, in ensure_type
value = tempfile.mkdtemp(prefix=prefix, dir=value)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/tempfile.py", line 339, in mkdtemp
_os.mkdir(file, 0700)
OSError: [Errno 13] Permission denied: '/Users/patrick/.ansible/tmp/ansible-local-37505vvsQNX'
Traceback (most recent call last):
File "/usr/local/bin/ansible", line 62, in <module>
import ansible.constants as C
File "/Library/Python/2.7/site-packages/ansible/constants.py", line 174, in <module>
config = ConfigManager()
File "/Library/Python/2.7/site-packages/ansible/config/manager.py", line 291, in __init__
self.update_config_data()
File "/Library/Python/2.7/site-packages/ansible/config/manager.py", line 571, 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/patrick/.ansible/tmp/ansible-local-37505vvsQNX'
Appreciate your help guys.
Upvotes: 4
Views: 4601
Reputation: 4870
I kept getting error
ERROR: Unhandled exception when retrieving DEFAULT_LOCAL_TMP:
[Errno 13] Permission denied: '~/.ansible/tmp/ansible-local-738828nkwy1p1'. [Errno 13] Permission denied: '~/.ansible/tmp/ansible-local-738828nkwy1p1'
ERROR: ... requires at least Ansible 4+/core 2.11 installed. Please run ./setup to upgrade Ansible
My folder ~/.ansible/tmp
exists, but it lacked permissions. After doing
sudo chmod 777 ~/.ansible/tmp
Now ansible --version
works!
Upvotes: 1
Reputation: 1
In the control plane, check the permissions of the ".ansible" folder. In this case, it seems to be in the folder /Users/patrick folder. Make sure the user who is executing ansible has proper permissions to that .ansible folder. If not, set the correct permissions using chown command.
Upvotes: 0
Reputation: 1
I have disabled 'gathering' in ansible.cfg to fix the issue.
# gathering = False
Below error occurring before commenting this.
~ % ansible
Unhandled error:
Traceback (most recent call last):
File "/opt/homebrew/Cellar/ansible/6.6.0/libexec/lib/python3.10/site-packages/ansible/config/manager.py", line 627, in update_config_data
value, origin = self.get_config_value_and_origin(config, configfile)
File "/opt/homebrew/Cellar/ansible/6.6.0/libexec/lib/python3.10/site-packages/ansible/config/manager.py", line 586, in get_config_value_and_origin
raise AnsibleOptionsError('Invalid value "%s" for configuration option "%s", valid values are: %s' %
ansible.errors.AnsibleOptionsError: Invalid value "False" for configuration option "setting: DEFAULT_GATHERING ", valid values are: implicit, explicit, smart
Upvotes: 0
Reputation: 1
~/.ansible/tmp is probably root, so not accessible. chown it to user
Upvotes: 0
Reputation: 1323025
Check if this is similar to iiab/iiab/issue 1212:
After some more digging, I found the real source of this problem was hardcoded paths in ansible.cfg
Or the more recent ansible/galaxy-dev
issue 107, which leads to PR 110:
The default ansible temp dir
~/.ansible/tmp
is accessed byansible-doc
via thegalaxy-importer
.
This works OK in thegalaxy-dev
local env, but on the CI environment it attempts to create dir/.ansible/tmp
and fails.This PR changes the default ansible temp dir to
/tmp/ansible
which is outside the user home (and in the local env,/tmp
has greater permissions)
Try and change DEFAULT_LOCAL_TMP
to /tmp
.
Upvotes: 4