One of the things I dislike about our current test setup is the fact that we create a new file for every version we test in forklift. This makes creating new pipelines tedious (esp reviewing PRs that add them) and adds a bit of drift where “new stuff” gets added to the newly created pipe, but does not get backported to older ones. And I’d like to change that
add new pipelines without writing much boilerplate ansible
adjust existing pipelines easily
review only the relevant parts of a newly added pipeline
As a developer I want to
have a single command to run a pipeline on my workstation that corresponds 100% to what Jenkins runs nightly
The developer one is already implemented today and is only listed here so that we don’t break that experience.
Proposal
Instead of having each pipeline in a separate file, I’d like to introduce a “generic” pipeline for each topic (Foreman, Katello, Katello Upgrade, etc). These pipelines will be version-agnostic in their definition and will load a version-specific file using Ansbile’s vars_files directive. This will allow us to only submit new variable files when we add new pipelines and adjustments to the main pipeline file will benefit all versions instantly.
The invocation of the pipeline will slightly change from ansible-playbook pipeplines/pipeline_<type>_<version>.yml to ansible-playbook pipeplines/pipeline_<type>.yml -e version=<version> and thus remain the “one command rules them all” requirement.
Big to DRYing it up. It has always annoyed me. In the past I’ve done a PoC to generate these files but also realized there should be an ansible-native way of doing it.
I’ve also been wondering if we could reuse our config/versions.yaml since it has the version info already. Perhaps we could restructure it as versions/x.y.yaml and make them ansible vars files. We can change the box loader we already have.
Another point I’m wondering about is the installer arguments we define in the pipeline. I’d like to reuse them in the upgrade scenario as well.
Yeah, splitting up config/versions.yaml into config/versions/X.Y.yaml and reformatting these as Ansible vars files is probably a good idea!
Not sure what you mean but the installer arguments. foreman_installer_options_internal_use_only? These are just two lines for the server itself: --disable-system-checks and the password. We only set a huge set on the proxy, and that’s not in the upgrade test (yet).
As vars_files overwrites vars, you could just add bats_tests: <whatever> to vars_katello_<specialversion>.yml and the pipeline for that version would execute a different set of tests.
That answers part of my question. Let’s take a real world example that I know of today. In 3.9 we introduced a foreman_client_repositories role that must be used with 3.9+ but not any version before that. Therefore, the pipeline for 3.9 will look different than 3.8 as well as upgrade pipelines given it requires both role and variable differences. How will this handle that scenario?
I think that is a good way to handle this. Even if we have to add versions to the when blocks it’s still a huge reduction in boiler plate. +1 from me for this.