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?
Galaxy can use git to add other role sources, such as GitHub. You can initialize a new galaxy role using ansible-galaxy init , or you can install a role directly from the Ansible Galaxy role store by executing the command ansible-galaxy install <name of role> .
Ansible is an open-source configuration management tool while Ansible Galaxy is a repository for Ansible roles. Ansible Galaxy for Ansible is what PyPI is for Python, or what Maven is for Java.
The ansible-galaxy command comes bundled with Ansible, and you can use it to install roles from Galaxy or directly from a git based SCM.
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.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With