Background/Motivation:
----------------------
There's a lot of confusion today around how the atomic approach on the tasks inside playbooks is done. With atomic approach we mean the ability to execute just one specific task instead of the entire playbook.
Some roles uses tags, some others variables or nothing.
We need to find out a common way to make the tasks of the playbooks optional.
Proposed change:
----------------
The proposal is to get rid of all the tags declaration and replace them with specific "step_" variables declared inside each role defaults/main.yml file, in a specific (and hopefully commented) section (the beginning will be logically best).
To make an example, today the first task of baremetal-undercloud.yml playbook contains this:
- name: Baremetal undercloud install
hosts: localhost
roles:
- baremetal-undercloud
tags:
- baremetal-undercloud
...
...
And inside the main task of the role we have:
- include: machine-provisioning.yml
tags:
- machine-provision
- include: machine-setup.yml
tags:
- machine-setup
After the proposed change, this will be inside roles/baremetal-undercloud/defaults/main.yml:
step_baremetal_undercloud: true
step_machine_provision: true
step_machine_setup: true
This inside the playbook:
- name: Baremetal undercloud install
hosts: localhost
roles:
- baremetal-undercloud
when: step_baremetal_undercloud|bool
And this inside of the main task:
- include: machine-provisioning.yml
when: step_machine_provision|bool
- include: machine-setup.yml
when: step_machine_setup|bool
So, no more tags.
Desired outcome:
----------------
After this the user should be able to invoke quickstart by passing extra vars to omit certain steps, like this:
/quickstart.sh \
--ansible-debug \
--bootstrap \
--no-clone \
--playbook baremetal-undercloud.yml \
--extra-vars step_machine_provision=false \
--release $RELEASE \
<HOSTNAME>
In this case everything will be executed, except the machine provision step.
Open questions/Considerations:
------------------------------
- This modification will be somehow huge, since there are a lot of tags used today on the playbooks;
- The reason why we should use "step_" name convention is that we already have a huge amount of variables with this name, and so keeping this will save some work;
- Other ideas are welcome but we need to consider that even if we choose to use just tasks then we will still use also variables, since they are already used to control infra-task steps;
Thanks for the write-up Raoul, this has been one of my major annoyances about quickstart for a while.