ansible/molecule

plugins: add role name to vars context for embedded converge.yml use case

decentral1se opened this issue · 3 comments

Desired Behavior

The default cookiecutter defined converge.yml is:

---
- name: Converge
  hosts: all
  tasks:
    - name: "Include {{ cookiecutter.role_name }}"
      include_role:
        name: "{{ cookiecutter.role_name }}"

Now, if you don't include a converge.yml in your molecule/default and your plugin provides a playbooks/converge.yml file then molecule will load that embedded playbook.

However, we can't embed that in a playbooks dir in the plugin packages because it will not know what the cookiecutter variable is when it is used.

So, we need to inject the role name variable into the context here for this use case.

Seems simple to do.

Continuation of #2671.

This will mean you really can use only molecule/default/molecule.yml as your only config. And if you indeed to use a base config, then migration will become super easy.

I am ok with it. I have some concerns regarding the fact that this may promote lack of real testing from some lazy users. In the end, they are supposed to add something inside verify.yml.

Overall, decent defaults that lower the total number of files needed to added are making much easier to adopt the tool.

Keep in mind that sometimes we do not have a role, not all scenarios are hosted inside a role. When implementing this, be aware of this instead of creating a confusing error about a non existing role.

I am closing this ticket as this is an unlikely use-case and no is expected. Still, keep in mind that a closed ticket does not mean a PR would not not be welcomed, it only means to not expect anyone else to implement it for you.