How does Molecule does the role lookup

时间:2019-03-19 14:39:25

标签: ansible molecule

Using Molecule 2.19.0 to test it on an Ansible role. Molecule and Ansible both work as desired.

I've got a question regarding how molecule executes the Ansible role.

This is my file structure:

| my_role (Root of the role)
* defaults
* files
* molecule
   * default
       * tests
           - molecule.yml
           - playbook.yml
           - Dockerfile.j2
           - tests
* tasks
* templates

Now, in the playbook.yml of molecule I set the role name:

---
- name: Converge
  hosts: all
  roles:
    - role: my_role

When running molecule test or molecule converge, it will run the role (as expected).

But how does Molecule this under the hood? How does it know the role is present in the root directory in this particular use case.

1 个答案:

答案 0 :(得分:0)

Molecule通过为ANSIBLE_ROLES_PATH设置一些合理的默认值来做到这一点: Click me for source code

还有"project directory"的概念,它是分子运行所在的目录。这将是您的角色目录。