Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/ant/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ansible 来自其他目录的分子测试角色_Ansible_Molecule - Fatal编程技术网

Ansible 来自其他目录的分子测试角色

Ansible 来自其他目录的分子测试角色,ansible,molecule,Ansible,Molecule,我想测试我在其他目录中的角色。 以下是我的项目结构: 当我尝试使用Molecular时,它找不到roles目录中的角色 ❯ sudo molecule converge --> Test matrix └── default ├── dependency ├── create ├── prepare └── converge --> Scenario: 'default' --> Action: 'dependency' Skipping,

我想测试我在其他目录中的角色。 以下是我的项目结构:

当我尝试使用Molecular时,它找不到roles目录中的角色

❯ 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
我试图找到正确的目录,但没有成功。 可以给他角色目录的路径吗?

简单回答:可以

在molecular.yml文件中,在
env:
下添加以下行:

provisioner:
  name: ansible
  ...
  env:
    ANSIBLE_ROLES_PATH: "../../roles"
此外,您还可以将分子链接到其他“路径”:

provisioner:
  name: ansible
  ...
  env:
    ANSIBLE_CONFIG: ../../ansible.cfg
  inventory:
    links:
      group_vars: ../../inventory/group_vars
      host_vars: ../../inventory/host_vars