Reputation: 3110
tl;dr
= How do OS X users recommend working around this permissions error?
I'm on OS X 10.10.1 and I recently installed Ansible running the following:
sudo pip install ansible --quiet
sudo pip install ansible --upgrade
I want to start off with a galaxy role to install homebrew and went to run this one with the following error:
$ ansible-galaxy install geerlingguy.homebrew
- downloading role 'homebrew', owned by geerlingguy
- downloading role from https://github.com/geerlingguy/ansible-role-homebrew/archive/1.0.1.tar.gz
- extracting geerlingguy.homebrew to /etc/ansible/roles/geerlingguy.homebrew
- error: you do not have permission to modify files in /etc/ansible/roles/geerlingguy.homebrew
- geerlingguy.homebrew was NOT installed successfully.
- you can use --ignore-errors to skip failed roles.
While I see /etc
is owned by root, I don't see any notes in documentation saying I should chmod
anything.
For reference:
$ ansible --version
ansible 1.8.2
configured module search path = None
Is this expected or is my installation somehow wrong?
Upvotes: 13
Views: 5022
Reputation: 24573
The default location for roles is /etc/ansible/roles
(for version <= 2.3. Since v2.4, the default location has changed to ~/.ansible/roles/
, an issue has been raised). You need to specify --roles-path
when using ansible-galaxy
. Here's what ansible-galaxy install --help
says:
-p ROLES_PATH, --roles-path=ROLES_PATH
The path to the directory containing your roles. The
default is the roles_path configured in your
ansible.cfg file (/etc/ansible/roles if not
configured)
You can also set roles_path
in ansible.cfg
; see the documentation for details.
Upvotes: 17
Reputation: 18070
Or you can use brew
to install ansible
. To do it you would need to run:
brew install ansible
If you had any previous installations, it is possible that you will see a message like this:
Error: The
brew link
step did not complete successfully The formula built, but is not symlinked into /usr/local Could not symlink bin/ansible Target /usr/local/bin/ansible already exists. You may want to remove it: rm '/usr/local/bin/ansible'To force the link and overwrite all conflicting files: brew link --overwrite ansible
To list all files that would be deleted: brew link --overwrite --dry-run ansible
Possible conflicting files are: /usr/local/bin/ansible /usr/local/bin/ansible-console /usr/local/bin/ansible-doc /usr/local/bin/ansible-galaxy /usr/local/bin/ansible-playbook /usr/local/bin/ansible-pull /usr/local/bin/ansible-vault
So, run brew link --overwrite ansible
to fix that. And now you will be able to install any roles without sudo
.
Example:
» ansible-galaxy install bennojoy.redis
- downloading role 'redis', owned by bennojoy
- downloading role from https://github.com/bennojoy/redis/archive/master.tar.gz
- extracting bennojoy.redis to /usr/local/etc/ansible/roles/bennojoy.redis
- bennojoy.redis was installed successfully
Upvotes: 4
Reputation: 58
As I saw you used "sudo" to install Ansible, I suppose it shall be OK to continue using "sudo" for ansible-galaxy installation. And that's what I just did.
Upvotes: 2