From 6b5b28f31ec9e5f93684938ed1be33d37bcd43de Mon Sep 17 00:00:00 2001 From: Ewoud Kohl van Wijngaarden Date: Mon, 19 Aug 2024 15:29:49 +0200 Subject: [PATCH] Use native cloud-init modules to register a host with subman --- .../cloud_init/cloud_init_default.erb | 33 +++++++++++++++++-- 1 file changed, 30 insertions(+), 3 deletions(-) diff --git a/app/views/unattended/provisioning_templates/cloud_init/cloud_init_default.erb b/app/views/unattended/provisioning_templates/cloud_init/cloud_init_default.erb index 6df0e79c2b4..62a19125b46 100644 --- a/app/views/unattended/provisioning_templates/cloud_init/cloud_init_default.erb +++ b/app/views/unattended/provisioning_templates/cloud_init/cloud_init_default.erb @@ -39,6 +39,36 @@ hostname: <%= @host.name %> fqdn: <%= @host %> manage_etc_hosts: true users: {} +<% if host_param_true?('subscription_manager') || host_param('kt_activation_keys') -%> +<% + if host_param('kt_activation_keys') + subscription_manager_org = @host.rhsm_organization_label + activation_key = host_param('kt_activation_keys') + else + subscription_manager_org = host_param('subscription_manager_org') + activation_key = host_param('activation_key') + end +-%> +write_files: +- content: | +<%= indent(4) { foreman_server_ca_cert } %> + path: /etc/rhsm/ca/katello-server-ca.pem +ca_certs: + trusted: + -| +<%= indent(6) { foreman_server_ca_cert } %> +rh_subscription: +<% if activation_key -%> + activation-key: "<%= activation_key %>" +<% end -%> + org: "<%= subscription_manager_org %>" +<% if plugin_present?('katello') -%> + rhsm-baseurl: "<%= @pulp_content_url %>" + server-hostname: "<%= @rhsm_url&.host %>" +<% end -%> + # TODO: server-port and path from rhsm_url aren't supported +# TODO syspurpose +<% end -%> runcmd: - | <%= indent(2) { snippet 'fix_hosts' } -%> @@ -51,9 +81,6 @@ runcmd: - | <%= indent(2) { snippet 'epel' } -%> <% end -%> -- | -<%= indent(2) { snippet 'redhat_register' } -%> -<% end -%> <% if host_enc['parameters']['realm'] && @host.realm && (@host.realm.realm_type == 'FreeIPA' || @host.realm.realm_type == 'Red Hat Identity Management') -%> - | <%= indent(2) { snippet 'freeipa_register' } %>