theforeman / foreman-ansible-modules

Ansible modules for interacting with the Foreman API and various plugin APIs such as Katello
GNU General Public License v3.0
147 stars 163 forks source link

Add and Remove Hosts from Host Collection #1178

Open jamesmarshall24 opened 3 years ago

jamesmarshall24 commented 3 years ago
SUMMARY

Expand a module or add a new module which allows hosts to be added/removed from host collections

ISSUE TYPE
wbclark commented 3 years ago

This is a valid feature request. We have host and host_collection modules, and either should be able to manage host <-> host_collection associations

lcrownover commented 1 year ago

I'd love to have this functionality. I'm looking to use host collections as my data source for ansible groups. I'm aware that I could do this using host groups, but I prefer to use host collections because host groups have other configuration associated with them, such as OS version, PXE templates, etc.

kkeane commented 1 year ago

I would also like to have this functionality.

As a stopgap, I hacked together a module that has this functionality and put it in https://github.com/kkeane/theforeman-addon

It is not code I'm most proud of, and not suitable as a contribution to the collection, but serves the purpose for me, and hopefully for others until this functionality is added to the collection itself.

parmstro commented 1 year ago

I will try to pick this up after Tech Exchange.

gardar commented 1 year ago

I would also like to have this functionality.

As a stopgap, I hacked together a module that has this functionality and put it in https://github.com/kkeane/theforeman-addon

It is not code I'm most proud of, and not suitable as a contribution to the collection, but serves the purpose for me, and hopefully for others until this functionality is added to the collection itself.

Any chance you will be submitting it to this collection? Since nobody else seems to be working on this.

kkeane commented 1 year ago

@gardar That had been my original plan, but I found that it is not trivial to fit into the collection. The collection has a specific, and very complex, way of mapping attributes between Ansible and the API, and I'm plain not experienced enough with it to make it work

If you want to take a stab at it, feel free - my code is open source, after all. As usual, just keep it open source, give me credit, yadayada. You may need to rewrite it from scratch to fit into the collection, if it can be done at all. I suspect that the issue is deeper, that the architecture of the collection itself may not fit for host collections (and a few of the other missing pieces that I also put into my own collection). That's probably why nobody else worked on it despite a clear need from the community.

gardar commented 1 year ago

@kkeane understood, unfortunately I'm not familiar enough with the collection myself to be able to shed some light into what needs to be done, I'm assuming you've seen these docs: https://theforeman.org/plugins/foreman-ansible-modules/ But perhaps @evgeni or @parmstro can give pointers?

With that being said, could you package your module as a ansible collection? That way it would be easy to install it as a dependency.

tuxpreacher commented 10 months ago

I'm trying to revive this dead issue. :-) Does anyone have time to look into it? Unfortunately I'm not experienced enough at Python to contribute.

afeefghannam89 commented 5 months ago

Hi,

we are using the Red Hat Satellite and looking forward to being able to add and remove hosts on host collections using theforeman.foreman.host_collection module or a new one. I think, the host module would not be the proper one, when the users are not using it to manage their hosts.

@evgeni @parthaa @mdellweg what do you think?