【问题标题】:ansible not finding roles when installed using pipenv使用 pipenv 安装时 ansible 找不到角色
【发布时间】:2017-09-20 11:04:52
【问题描述】:

我一直在寻找测试 ansible 剧本的不同方法,并偶然发现了 Jeff Geerling 的这篇博文。

复制他的确切示例有效,但是,当我复制它但通过 pipenv 安装管理 python(和 ansible)时,我收到以下错误

ERROR! the role 'ansible-test' was not found in /Users/philip/Desktop/ansible-test/tests/roles:/Users/philip/ansible-test:/Users/philip/Desktop/ansible-test/tests

The error appears to have been in '/Users/philip/Desktop/ansible-test/tests/test.yml': line 4, column 7, but may
be elsewhere in the file depending on the exact syntax problem.

The offending line appears to be:

  roles:
    - ansible-test
      ^ here

test.yml的内容是

- hosts: localhost
  remote_user: root
  roles:
    - ansible-test

通过yamllint 很好。

ansible.cfg 包含

[defaults]
roles_path = ../../ansible-test

我猜这与处于 Virtualenv 中有关,但无法解释。

【问题讨论】:

    标签: ansible virtualenv pipenv


    【解决方案1】:

    角色s路径是所有角色s的路径。

    Ansible 使用roles_path 中的角色名称搜索目录。如果角色名为ansible-test,则将角色名称放入roles_path 是错误的。

    这样设置roles_path

    [defaults]
    roles_path = ../..
    

    当您拨打ansible-playbook 时,请确保您位于正确的目录中。

    【讨论】:

    • 完美。谢谢你的解释!
    猜你喜欢
    • 2016-08-25
    • 1970-01-01
    • 2016-10-25
    • 2018-01-30
    • 2018-12-27
    • 2014-10-03
    • 2021-03-10
    • 2021-08-06
    • 1970-01-01
    相关资源
    最近更新 更多