Fixes #3860 - automated discovery provisioning #97
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is a WIP.
This implements simple rule engine which allows to assign host groups according
to scoped_search queries. Currently all our facts are strings, so searching is
little bit limited, but it works just fine.
Good testing query is something like
facts.architecture = x86_64
which islikely to be true. Here are some rules to start with which can be created via
rails console:
There is no UI support yet, I am providing (untested) V2 API for rules CRUD. To
get this working in real-world scenario with Discovery 2.0, you need this patch
because systemd is too quick with shutdown:
theforeman/smart-proxy#235
To test this, checkout the branch and do migration. Then create some rules via
V2 API. Once a discovery node is found, it should automaticaly start
provisioning (reboot can fail rolling back the transaction because of the shell
API provider issue). You can re-initiate auto-provisioning using an API call
(PUT discovery_rules/execute action).
Make sure the discovery_auto option is set to true when you want new nodes to
be automatically picked up for provisioning.
Also we need to make sure the host group has everything set for provisioning,
otherwise the provisioning will fail (and possibly can end up in a loop). You
need to make sure root password is set as well. I think we need some kind of
check somewhere (in the Foreman core perhaps)?
TODO items: