waveclaw / puppet-subscription_manager

Handle Client Registration to RedHat Satellite 6 or Katello
https://rhn.redhat.com
Other
6 stars 34 forks source link

rhsm_pool ensure => absent is effectively unusable #37

Closed robert4man closed 8 years ago

robert4man commented 8 years ago

The only option to remove a pool using subscription-manager is remove --serial. Unfortunately, the serial number appears to be unique per node which precludes doing it programmatically. For instance, if there is a pool for vmware tools it would make sense to remove it from physical nodes as it is not really needed.

Since this appears to be a limitation of subscription-manager the only way I can see to work around it would be to include a set of facts mapping pool id's to serial numbers.

waveclaw commented 8 years ago

Yes, the serial number is unique per node. But a provider for a puppet type only views resources from the point of view of the node.

For example, the rhsm_pool type's provider determines local information. Information like the node's serial number for each pool is discovered as the parameters on each resource. These details are unknown to a remote party such as a Puppet Master compiling a catalog written by a developer without access to the node.

Since the serial number is known by the provider it can be supplied to the subscription-manager command to operate on pools. Examine the operation of the subscription_manager provider for the rhsm_pool type. The serial number, a parameter of the existing resource, is provided to the command for operating on rhsm_pool resources.

This behavior of the provider creates an implicit mapping from rhsm_pool IDs to the serial numbers. The serial number are revealed to the user by the puppet resource face. But serial numbers are treated like read-only internal representations. The map means that actions like purging the resource works. The mapping avoids any need to provide the unknown serial numbers in the catalog provided to the agent.

In summary, serial numbers are local information to a node but so are resources created by providers so the type is actual usable this way.