I suspect that nobody else has run across this particular issue yet. The redhat_subscription module has an error in it. If you are using pool_ids then you can either provide a list of ids, or a list of ids with quantities. Behind the scenes the module translates the former into the latter with a quantity of “1”.
`
- name: Register and subscribe to multiple pools.
redhat_subscription:
state: present
username: joe_user
password: somepass
pool_ids:- 0123456789abcdef0123456789abcdef
- 1123456789abcdef0123456789abcdef
- name: Same as above but consume multiple entitlements.
redhat_subscription:
state: present
username: joe_user
password: somepass
pool_ids:- 0123456789abcdef0123456789abcdef: 2
- 1123456789abcdef0123456789abcdef: 4
`
However a quantity of 1 is not valid for a physical machine with 2 sockets (it should be 2) and so subscription_manager returns a warning on stdout and a return code of 1 (it does the right thing though) this causes Ansible to flag it as having failed.
Given that the module itself uses this piece of code…
`
def subscribe_by_pool_ids(self, pool_ids): |
|
“”" |
|
Try to subscribe to the list of pool IDs |
|
“”" |
|
available_pools = RhsmPools(self.module) |
|
available_pool_ids = [p.get_pool_id() for p in available_pools] |
|
for pool_id, quantity in sorted(pool_ids.items()): |
|
if pool_id in available_pool_ids: |
|
args = [SUBMAN_CMD, ‘attach’, ‘–pool’, pool_id, ‘–quantity’, quantity] |
|
rc, stderr, stdout = self.module.run_command(args, check_rc=True) |
|
else: |
|
self.module.fail_json(msg=‘Pool ID: %s not in list of available pools’ % pool_id) |
|
return pool_ids |
I was wondering if it should be patched to default quantity to 0 and include a check, if quantity is set to 0 then skip the --quantity argument. Any thoughts?