Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes #3860 - automated discovery provisioning #97

Closed
wants to merge 1 commit into from

Conversation

lzap
Copy link
Member

@lzap lzap commented Nov 7, 2014

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 is
likely to be true. Here are some rules to start with which can be created via
rails console:

=> [#<DiscoveryRule id: 1, name: "Database server rule", query: "facts.architecture = i386", hostgroup_id: 4, hostname: "test<%= facts['macaddress'] %>", max_count: 0, priority: 10, enabled: true, created_at: "2014-11-07 11:37:18", updated_at: "2014-11-07 11:37:18">,
 #<DiscoveryRule id: 2, name: "Web server rule", query: "facts.architecture = x86_64", hostgroup_id: 3, hostname: "test<%= facts['macaddress'] %>", max_count: 5, priority: 20, enabled: true, created_at: "2014-11-07 11:37:52", updated_at: "2014-11-07 11:37:52">,
 #<DiscoveryRule id: 3, name: "Web server drained rule", query: "facts.architecture = x86_64", hostgroup_id: 3, hostname: "test<%= facts['macaddress'] %>", max_count: 2, priority: 15, enabled: true, created_at: "2014-11-07 13:13:02", updated_at: "2014-11-07 13:13:02">,
 #<DiscoveryRule id: 4, name: "Disabled dummy rule", query: "facts.architecture = x86_64", hostgroup_id: 3, hostname: "test<%= facts['macaddress'] %>", max_count: 0, priority: 50, enabled: false, created_at: "2014-11-07 13:20:59", updated_at: "2014-11-07 13:20:59">]

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:

  • hammer CLI
  • UI
  • hostname setting via safe_mode
  • validation of hostgroups
  • testing

@lzap
Copy link
Member Author

lzap commented Nov 10, 2014

This got replaced with #97

@lzap lzap closed this Nov 10, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants