Make it easy to discover which groups a server belongs to
Nobody has claimed this yet.
- Dominant language
- Perl
- Stars
- 737
- Forks
- 214
- PR merge metrics
- No merged PRs in 30d
Description
User story
As someone developing a Rex task
I would like to find out which groups a server is in
so I can make decisions based on its group membership
For one service I run, I want to generate different configuration files based on the groups the server belongs to. I have written code to do this, but it's horrid. As far as I can tell, Rex doesn't currently provide a better approach.
Describe the solution you'd like
In my task, I'd like to call something like connection->server->groups or perhaps groups_for($hostname) which returns a list of the groups the server belongs to. Alternatively, it might be easier to run something like server_is_in_group($hostname) which would return a boolean.
Describe alternatives you've considered
My current code calls keys %Rex::Group::groups to get a list of all groups that exist. I feel bad that I depend on an undocumented private variable. I then call get_group_object() and get_servers() from the undocumented Rex::Group module, which also feels awkward.
Additional context
As well as messing about in Rex's internals, my current approach is inefficient as it walks across data structures associated with groups, instead of using data structures that focus on groups. I only work with a few tens of hosts, but if I had thousands, repeatedly iterating over group-centric data structures might slow Rex down.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Read the Rex::Group entry points get_group_object() and get_servers(), and inspect how %Rex::Group::groups is currently used. Compare the proposed connection->server->groups, groups_for($hostname), and server_is_in_group($hostname) interfaces with the existing group data structures. Done means a documented public way to query a server's group membership without relying on private internals.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- perl
- Domain
- devops, infrastructure
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100