# Issue with redhat\_subscription module

**URL:** <https://forum.ansible.com/t/issue-with-redhat-subscription-module/31959>\
**Category:** Ansible Project\
**Created:** [January 13, 2020, 7:18pm UTC](https://forum.ansible.com/t/issue-with-redhat-subscription-module/31959 "2020-01-13T19:18:57Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Adam\_Morris](https://avatars.discourse-cdn.com/v4/letter/a/ecae2f/32.png) [@Adam\_Morris](https://forum.ansible.com/u/Adam_Morris)\
**Post date:** [January 13, 2020, 7:18pm UTC](https://forum.ansible.com/t/issue-with-redhat-subscription-module/31959/1 "2020-01-13T19:18:57Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![cassell](https://avatars.discourse-cdn.com/v4/letter/c/ecae2f/32.png) [@cassell](https://forum.ansible.com/u/cassell)\
**Post date:** [January 13, 2020, 10:44pm UTC](https://forum.ansible.com/t/issue-with-redhat-subscription-module/31959/2 "2020-01-13T22:44:27Z")

</div>

Sounds like a good change to me. Probably fastest solution is to send a PR.

V/r,  
James Cassell
