pulibrary / princeton_ansible

Ansible Roles and Playbooks for Princeton University Library
11 stars 4 forks source link

Deduplicate role inclusion for molecule testing? #2685

Open acozine opened 2 years ago

acozine commented 2 years ago

We're running dependencies like the common role multiple times per test run for some projects. For example, when the tests run for the lib_jobs role, molecule runs:

In production, of course, the duplication may be needed where different roles run on different servers, so the dependencies must run on each server, but it seems inefficient for testing. Can anything be done to streamline the test runs?

hackartisan commented 2 years ago

it's very curious. shouldn't ansible deduplicate the meta.yml entries and only run each once?

https://docs.ansible.com/ansible/latest/user_guide/playbooks_reuse_roles.html#running-role-dependencies-multiple-times-in-one-play

acozine commented 2 years ago

I don't think Ansible deduplicates down the nested tree, and we have a lot of nested dependencies. For example, the dependency tree for the lib_jobs role looks like this:

hackartisan commented 2 years ago

This makes me think we should move away from using meta for dependencies and toward just putting everything in playbooks.

acozine commented 2 years ago

That's a good idea, and would help with visibility. We can do this one role at a time.

Steps to implement:

Anything else?

acozine commented 2 years ago

See also this SO post.

hackartisan commented 2 years ago

@carolyncole I'd interested if you have thoughts here, since you and @kayiwa worked so much on the molecule setup.

acozine commented 2 years ago

Okay, I tried a quick "proof of concept" (#2693), which showed me how complex this change would be. Definitely something to discuss broadly.

acozine commented 2 years ago

At the level of an individual role, refactoring the way we maintain role dependencies will require:

For each role dependency we remove from the meta/main.yml file of Role A:

hackartisan commented 2 years ago

If we do decide to move forward on this we can close #1204 as wontfix.

acozine commented 2 years ago

Also related to #2892, which fixed a failure caused by dependency testing.