It would be nice to be able to search for roles and atoms using more filters than just name. We could support searching for things like descriptions, atom members and hosts they are applied to.
New options
policy list_roles
-description: List roles with the given description
-atom: List roles containing the given atom
-host: List roles applied to the given host (Maybe? host info already lists roles, but only the names!)
policy list_atoms
-description: List atoms with a given description
-host: List atoms applied to the given host through its roles
Examples
Find all roles with a description containing the phrase web:
policy list_roles * -description *web*
Find all roles with the atom is_web_server
policy list_roles * -atom is_web_server
Find all atoms applied to a host through its roles:
policy list_atoms * -host host1.example.com
Suggestion: Make the FILTER argument optional
> policy list_roles --help
usage: mreg-cli policy list_roles [-h] FILTER
List all roles by given filters
positional arguments:
FILTER Role name, or part of name. You can use * as a wildcard.
options:
-h, --help show this help message and exit
It could be a good idea to make the positional FILTER argument optional if a positional argument is provided, since it's likely that one primarily wants to search through all roles when narrowing down by things such as atom members.
I.e.
policy list_roles -atom is_web_server
However, we should still support having a filter if they user wants to narrow it down by name in addition to members:
policy list_roles *foo* -atom is_web_server
Disclaimer
I am aware the name and description filtering functionality is largely achievable with policy list_{roles,atoms} * | <regex>, but that does not differentiate between name and description, and it has limited filtering potential beyond that.
It would be nice to be able to search for roles and atoms using more filters than just name. We could support searching for things like descriptions, atom members and hosts they are applied to.
New options
policy list_roles-description: List roles with the given description-atom: List roles containing the given atom-host: List roles applied to the given host (Maybe?host infoalready lists roles, but only the names!)policy list_atoms-description: List atoms with a given description-host: List atoms applied to the given host through its rolesExamples
Find all roles with a description containing the phrase web:
Find all roles with the atom
is_web_serverFind all atoms applied to a host through its roles:
Suggestion: Make the
FILTERargument optionalIt could be a good idea to make the positional
FILTERargument optional if a positional argument is provided, since it's likely that one primarily wants to search through all roles when narrowing down by things such as atom members.I.e.
However, we should still support having a filter if they user wants to narrow it down by name in addition to members:
Disclaimer
I am aware the name and description filtering functionality is largely achievable with
policy list_{roles,atoms} * | <regex>, but that does not differentiate between name and description, and it has limited filtering potential beyond that.