gpt4 book ai didi

ansible - Molecule - 来自其他目录的测试角色

转载 作者:行者123 更新时间:2023-12-03 23:47:19 28 4
gpt4 key购买 nike

我想测试我在其他目录中的角色。
在我的项目结构下面:
Project Structure

当我尝试使用分子时,它找不到角色目录中的角色。

❯ sudo molecule converge
--> Test matrix

└── default
├── dependency
├── create
├── prepare
└── converge

--> Scenario: 'default'
--> Action: 'dependency'
Skipping, missing the requirements file.
Skipping, missing the requirements file.
--> Scenario: 'default'
--> Action: 'create'
Skipping, instances already created.
--> Scenario: 'default'
--> Action: 'prepare'
Skipping, prepare playbook not configured.
--> Scenario: 'default'
--> Action: 'converge'
--> Sanity checks: 'docker'
ERROR! the role 'curl' was not found in /home/belluu/programming/Ansible-Posthog/molecule/default/roles:/root/.cache/molecule/Ansible-Posthog/default/roles:/home/belluu/programming:/root/.ansible/roles:/usr/share/ansible/roles:/etc/ansible/roles:/home/belluu/programming/Ansible-Posthog/molecule/default

The error appears to be in '/home/belluu/programming/Ansible-Posthog/molecule/default/converge.yml': line 5, column 7, but may
be elsewhere in the file depending on the exact syntax problem.

The offending line appears to be:

roles:
- role: curl
^ here

分子试图找到正确的目录但没有成功。
是否可以为他提供带有角色的目录的路径?

最佳答案

简单的回答:是的
在您的分子.yml 文件中,在 env: 下添加以下行:

provisioner:
name: ansible
...
env:
ANSIBLE_ROLES_PATH: "../../roles"
此外,您还可以将 Molecule 链接到其他“路径”:
provisioner:
name: ansible
...
env:
ANSIBLE_CONFIG: ../../ansible.cfg
inventory:
links:
group_vars: ../../inventory/group_vars
host_vars: ../../inventory/host_vars

关于ansible - Molecule - 来自其他目录的测试角色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61856958/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com