首页 文章

ansible-galaxy角色失败,“没有权限修改/ etc / ansible / roles /”

提问于
浏览
13

tl;dr = How do OS X users recommend working around this permissions error?

我在OS X 10.10.1上,我最近安装了Ansible,运行以下内容:

sudo pip install ansible --quiet
sudo pip install ansible --upgrade

我想从一个galaxy角色开始安装自制软件,并运行以下错误:

$ 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.

虽然我看到 /etc 由root拥有,但我没有看到文档中的任何注释说我应该 chmod .

以供参考:

$ ansible --version
ansible 1.8.2
  configured module search path = None

这是预期的还是我的安装错误?

3 回答

  • 2

    角色的默认位置是 /etc/ansible/roles (版本<= 2.3 . 自v2.4起,默认位置已更改为 ~/.ansible/roles/an issue has been raised) . 使用 ansible-galaxy 时需要指定 --roles-path . 这是 ansible-galaxy install --help 所说的:

    -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)
    

    你也可以在 ansible.cfg 中设置 roles_path ; see the documentation for details .

  • 4

    或者您可以使用 brew 来安装 ansible . 要做到这一点,你需要运行:

    brew install ansible
    

    如果您之前有任何安装,您可能会看到如下消息:

    错误:brew链接步骤未成功完成公式已构建,但未符号链接到/ usr / local无法符号链接bin / ansible目标/ usr / local / bin / ansible已存在 . 你可能想删除它:rm'/ usr / local / bin / ansible'强制链接并覆盖所有冲突的文件:brew链接--overwrite ansible列出所有要删除的文件:brew链接--overwrite - dry-run ansible可能有冲突的文件是:/ 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

    所以,运行 brew link --overwrite ansible 来解决这个问题 . 现在,您将能够在没有 sudo 的情况下安装任何角色 .

    例:

    »ansible-galaxy install bennojoy.redis - 下载角色'redis',由bennojoy拥有 - 从https://github.com/bennojoy/redis/archive/master.tar.gz下载角色 - 将bennojoy.redis解压缩到/ usr /local/etc/ansible/roles/bennojoy.redis - bennojoy.redis已成功安装

  • 17

    正如我所看到你使用“sudo”来安装Ansible,我想可以继续使用“sudo”来安装ansible-galaxy . 这就是我刚才所做的 .

相关问题