Split monolithic module into several collection modules #34
Split monolithic module into several collection modules #34marmarek merged 15 commits intoQubesOS:mainfrom
Conversation
Keep a symlink in old locations to avoid breaking changes
2dd94cd to
9a8d92e
Compare
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #34 +/- ##
==========================================
+ Coverage 73.34% 81.30% +7.96%
==========================================
Files 1 1
Lines 529 214 -315
==========================================
- Hits 388 174 -214
+ Misses 141 40 -101
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
9a58c91 to
bd2ece0
Compare
b1db702 to
25600a3
Compare
|
PipelineRetry |
deddfe6 to
967ad2f
Compare
All tests must still work without any modification to prevent breaking changes. Currently, the only identified braking change is the wait param which is no more supported (it will not fail but if using wait: false, the module will ignore the option)
2c63a95 to
608d218
Compare
Old playbook stopped working. It's here: https://github.com/QubesOS/openqa-tests-qubesos/tree/main/extra-files/ansible |
| "netvm", | ||
| ]: | ||
| value = self.wants.properties.get(property) | ||
| if value in (None, "dom0", "*default*"): |
There was a problem hiding this comment.
It used to accept also empty string as None (existing playbooks rely on that).
There was a problem hiding this comment.
This probably also wants a test for setting any of the VM-type properties to None.
| if key not in PROPS: | ||
| return VIRT_FAILED, {"Invalid property": key} | ||
| raise ValidationFailure({"Invalid property": key}) | ||
| if type(val) != PROPS[key]: |
There was a problem hiding this comment.
This is unfortunate given the new module doesn't accept empty string as None anymore, yet this line rejects real None...
| continue | ||
|
|
||
| try: | ||
| vm = self.helper.get_vm(value) |
There was a problem hiding this comment.
This validation is too early. This prevents creating a (disposable template) qube that has itself as its default_dispvm. It used to be possible.
|
Thanks for the review @marmarek. Should be good for the openqa playbook. Ansible doesn't like Enum in returned data... Now we can set an empty string or None in a qube property and qube existence is skipped when specifying the managed qube in a property. Some tests added too. |
Fixes QubesOS/qubes-issues#10670
This PR brings some architectural changes to this repository.
1. Introduction of collections
Ansible collections allow to distribute a set of plugins, roles and modules into a self-contained, reusable and versioned package.
The
qubesosmodule allow to do a lot of different things, many of which are not directly related. Splitting it into 3 modules helps for maintenance and for usage in playbooks.2 collections are introduced:
qubesos.corefor everything related to QubesOS managementqubesos.securityfor Ansible-related security features (basically, thequbes-proxyand thequbesos_strategy_guard)The
qubesosmodule has been splitted into 3 different modules:qubesos.core.qube: to manage the qubesqubesos.core.command: non indempotent commands (required to keep compatibility with the old module)qubesos.core.host_devices_facts: gather facts about available devices on the hostOther plugins (connection, strategy and callback) have been moved into a collection but may still be called using their old name.
qubesqubesos.core.qubesqubes_proxyqubesos.security.qubes_proxyqubes_strategy_guardqubesos.security.qubes_strategy_guard2. Legacy module
To prevent breaking changes, the
qubesosmodule is still present but is considered deprecated and may be removed in a future release.The module takes the same options and will try to translate to calls to the new
modules with the appropriate options.
Option
waithas no more effect. The module will always wait for the actions (qube start, stop...)to finish before starting a new task to prevent unexpected behaviors.
3. A word about
module_utilsThe files in the
modulesdirectory contains only the module documentation while the entire module code is stored in the directorymodule_utils. The reason of that split is the legacy modulequbesos. As described above, this module is responsible of taking the same input as the previous module and based on the input, it will call the new modules.However, Ansiballz framework doesn't include other modules in the generated archive making imports fail. Putting modules logic into
module_utilsmake the code available to other modules, and so available toqubesosmodule.4. Documentation
The documentation is now automatically generated based on modules docstrings and is available in the project Gitlab Pages.
Focusing on documenting modules using the official way allow to generate the documentation with the common Ansible format while also making it available using
ansible-docscommand.