24 hour guest subscription not immediately attached to host at build - puppet won't install at build

Env : Latest Katello 2.2.1

I'm running virtwho for subscriptions, but as stated in this feature/bug -
newly built hosts are not immediately seen by virtwho.
http://projects.theforeman.org/issues/9422

I build a VMWare host and part of the kickstart includes a subscription
manager snippet to register the host in Content Hosts and then enable the
appropriate repositories, then install Puppet.

I watch Content Hosts and see that the host registered but the Subscription
Status is Red stating "Red Hat Enterprise Linux Server - Not supported by
a valid subscription."

About 3 minutes after the host reboots, the host Subscription Status turns
Yellow stating "Guest has not been reported on any host and is using a
temporary unmapped guest subscription."

Because the host is "not supported" for RedHat products during build,
puppet fails to install and therefore manual intervention is required to
get the machine connected to Foreman/Puppet after the host is built.

Am I missing something in ks-subscription-manager or is there something I
need to add to the activation keys? I see in the Foreman issue tracker I
linked to that the temporary subscription is hidden, so I can't add it to
the key in Activation Keys.

Can you paste the subscription-manager command being called during provisioning? The --auto-attach flag to register should pick up the temporary guest subscription.

··· ----- Original Message ----- > > Env : Latest Katello 2.2.1 > > I'm running virtwho for subscriptions, but as stated in this feature/bug - > newly built hosts are not immediately seen by virtwho. > http://projects.theforeman.org/issues/9422 > > I build a VMWare host and part of the kickstart includes a subscription > manager snippet to register the host in Content Hosts and then enable the > appropriate repositories, then install Puppet. > > I watch Content Hosts and see that the host registered but the Subscription > Status is Red stating "Red Hat Enterprise Linux Server - Not supported by > a valid subscription." > > About 3 minutes after the host reboots, the host Subscription Status turns > Yellow stating "Guest has not been reported on any host and is using a > temporary unmapped guest subscription." > > Because the host is "not supported" for RedHat products during build, > puppet fails to install and therefore manual intervention is required to > get the machine connected to Foreman/Puppet after the host is built. > > Am I missing something in ks-subscription-manager or is there something I > need to add to the activation keys? I see in the Foreman issue tracker I > linked to that the temporary subscription is hidden, so I can't add it to > the key in Activation Keys. > > -- > You received this message because you are subscribed to the Google Groups > "Foreman users" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to foreman-users+unsubscribe@googlegroups.com. > To post to this group, send email to foreman-users@googlegroups.com. > Visit this group at http://groups.google.com/group/foreman-users. > For more options, visit https://groups.google.com/d/optout. >

I think I have fixed it - see the last few lines incase of tl;dr. I put
some details about my config which may help someone in the same situation
and may help adjust the defaults shipped with Foreman/Katello. I use
activation keys so --auto-attach is not allowed with register using keys.

Here was the subscription-manager from the snippet :

echo "Registering the System"
subscription-manager register --org="<%= @host.rhsm_organization_label %>"
–name="<%= @host.name %>" --activationkey="<%=
@host.params['kt_activation_keys'] %>"

<% if @host.operatingsystem.name == "RedHat" %>

add the rhel rpms to install katello agent

subscription-manager repos --disable=*
subscription-manager repos --enable=rhelserver-rpms
–enable=MyOrg_Puppet_Labs_
--enable=MyOrg_Katello_Client*
–enable=MyOrg_EPEL*
<% end %>

I added --auto-attach to subscription-manager register but in the log :
Error: Activation keys cannot be used with --auto-attach.

After the system is built, I can use subscription-manager register with
–auto-attach and my user/pass to register the host and get the temporary
guest subscription. This may be unrelated, but my activation key is for
Environment : Prod, but when using my user/pass after the host is built,
the only env I can use is Library

subscription-manager register --org="MyOrg" --name="hostname.myorg.org"

–auto-attach --force
Username: ME
Password:
Environment: Prod
No such environment: Prod
[root@host ~]# subscription-manager register --org="MyOrg"
–name="hostname.myorg.org" --auto-attach --force
Username: ME
Password:
Environment: Library
The system has been registered with ID: <id>

Installed Product Current Status:
Product Name: Red Hat Enterprise Linux Server
Status: Partially Subscribed

Changing my subscription-manager registration snipped to include this
worked - register and attach are two separate commands instead of
–auto-attach in the register line :

echo "Registering the System"
subscription-manager register --org="<%= @host.rhsm_organization_label %>"
–name="<%= @host.name %>" --activationkey="<%=
@host.params['kt_activation_keys'] %>"
subscription-manager attach --auto

<% if @host.operatingsystem.name == "RedHat" %>

add the rhel rpms to install katello agent

subscription-manager repos --disable=*
subscription-manager repos --enable=rhelserver-rpms
–enable=MyOrg_Puppet_Labs_
--enable=MyOrg_Katello_Client*
–enable=MyOrg_EPEL*
<% end %>

Thanks for your help Tom - you got me on the right track.

··· On Monday, June 8, 2015 at 9:54:24 AM UTC-5, Tom McKay wrote: > > > Can you paste the subscription-manager command being called during > provisioning? The --auto-attach flag to register should pick up the > temporary guest subscription. >

I'd like to ask one question (or possibly make a statement) - why so many
"Environments" ? Puppet environments, lifecycle environments, and then
subscription-manager when it requests and "environment" isn't actually
asking for an environment - it's a puppet host group!

I thought I had a good understanding of what is what, but then I encounter
subscription-manager asking for an Environment and it's not one of the two
environments, it's a host group.