This RFC is part of an ongoing effort to simplify the registration process of the hosts into the Foreman. It’s not about provisioning new hosts from Foreman, but about registering already existing (running) hosts to Foreman and running user defined commands from the registration templates. That is especially useful in brown-field deployments, where people don’t provision the existing infrastructure from scratch, but want to start managing existing hosts by Foreman.
This RFC further investigates a part of an earlier RFC - RFC: Client workflows and tooling, namely the “foreman-bootstrap” part.
Motivation & Goals
Make the host registration simple and easy. We should allow users to register and set up hosts with one command.
Ideal Use Case
One command rule them all:
- User will call curl | bash command, for example something like this:
curl --user admin:changeme https://foreman.com/templates/register-new-host | bash
- Foreman will generate Global registration template with commands for host registration to Foreman
- After host creation Foreman will render the host-registration template with commands for host set up.
Introduce Global-Registration template
- Not scoped to host object, the template can’t rely on @host or any other host specific variables and macros
- Contains commands for host registration to Foreman, at first using subscription-manager however this should be configurable for platforms not having this option
- Also contains second
curl | bashafter the registration, that will fetch specific host-registration template (see below)
API endpoint for Global-registration template render
- Render template from Default global registration template setting
- Could allow the user to pass parameters to template (Organization id, activation key …)
- Authentication by login/password or by user’s API token
Host-registration template (scoped to @host)
- Already implemented in PR#6813
- This template allows host-specific bootstrap logic to be executed, this template can be affected by parameters stored per Host group, OS, Subnet, Domain, Organization, Location or as a Global parameter.
- Enable built mode for unmanaged hosts (see Questions & Ideas)
- New Provisioning setting "Default global registration template"
What should we do in the templates?
Global registration template
- (Check root privileges)
- (RHEL only) Check if subscription-manager is installed, if not install it.
- Run host registration (RHEL with subman, for other systems use different tools)
- Get host’s id from Foreman (based on subscription UUID)
- Render Host-registration template for created host, we know the host id to render it for from step 4
(each step should be parameterized in Foreman)
- Upgrade to newest subscription-manager
- Setting up SSH keys for REX
- Puppet setup
- Insights setup
- Install Katello-host tools
- CNAME support (bootstrap.py has it, supported since 6.8)
- (… another steps from bootstrap.py - see the WF)
- ??? Anything else, any ideas?
Questions & Ideas
Katello client bootstrap
Bootstrap.py already covers a lot of logic regarding to host registration to Foreman. Maybe we could use it, or we could move the logic from bootstrap to Foreman templates. We need to consider all cons and pros.
Unmanaged hosts vs. managed hosts
By default a host registered via subscription-manager is unmanaged, this won’t allow us to switch host to build mode during the run. It seems we can however allow building the host easily even if it’s unmanaged. Build mode traditionally meant complete (re)provisioning. Would it be acceptable to consider building also bootstrapping existing machine?
Another option is to introduce a new host state - Registration / Registering. Since build mode is used for complete reprovisioning, adding a new state could be more user friendly than changing the meaning of “build mode”.
Support for different distros
How about debian based distros? ATIX worked on porting subscription-manager for debian, is that available today? We prefer to use subscription-manager, since it already sends some basic facts we can use to determine OS and hence OS specific parameters can tailor the host-registration template. Other agents that send facts (puppet, chef, salt) need some infrastructure to exist or their installation is more complicated.
For debian-based systems without subscription-manager we can collect required data manually (hostname, ip …) and create unmanaged the host via Foreman’s api.
Template example (POC)
An example how simple Global registration could look-like: https://pastebin.com/HxJhGv3R