使用 pipenv 安装时 ansible 找不到角色
ansible not finding roles when installed using pipenv
我一直在寻找不同的方法来测试 ansible playbooks and came across this blog post by 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 中有关,但无法解释。
角色s路径是所有角色s.
的路径
Ansible 在 roles_path
中搜索具有角色名称的目录。如果角色叫ansible-test
,把角色名放到roles_path
里是错误的。
这样设置roles_path
:
[defaults]
roles_path = ../..
并确保在调用 ansible-playbook
时位于正确的目录中。
我一直在寻找不同的方法来测试 ansible playbooks and came across this blog post by 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 中有关,但无法解释。
角色s路径是所有角色s.
的路径Ansible 在 roles_path
中搜索具有角色名称的目录。如果角色叫ansible-test
,把角色名放到roles_path
里是错误的。
这样设置roles_path
:
[defaults]
roles_path = ../..
并确保在调用 ansible-playbook
时位于正确的目录中。