Related docs:
SUDO PLUGIN SUDO USE CASES DOCS MAP
Use this guide to choose the right sudo lookup pattern for your automation.
The plugin reference explains exact option syntax. This page explains when to query a sudo rule, when to query a sudo command or command group, and when a single lookup is enough versus when a broader audit is the better fit.
flowchart LR
need["Privileged workflow question"]
rule["Which sudo rule?\nWho, where, what?"]
cmd["Which sudo command\nor command group?"]
audit["Audit or assert"]
act["Proceed, fail,\nor report drift"]
need --> rule
need --> cmd
rule --> audit
cmd --> audit
audit --> act
The sudo lookup has one core split:
sudo_object='rule' when the question is policy scope, enablement, or
effective allowed and denied command assignmentssudo_object='command' when the question is whether a concrete command
object exists in IdMsudo_object='commandgroup' when the workflow depends on a reusable
command set rather than one command pathUse sudo_object='rule' with operation=show when a play depends on a named
sudo rule being present and enabled before any privileged workflow starts.
Typical cases:
system-ops or cluster-adminWhy this fits:
show returns exists: false for missing rules instead of raisingUse sudo_object='rule' when the workflow depends on the correct users,
groups, hosts, hostgroups, or RunAs identities being in scope.
Typical cases:
users or covered by a groupWhy this fits:
Use sudo_object='rule' when you need to inspect which command paths and
command groups are allowed or denied by a rule.
Typical cases:
systemctl but denies suWhy this fits:
allow_sudocmds, allow_sudocmdgroups, deny_sudocmds, and
deny_sudocmdgroups are all returned in one recordUse sudo_object='commandgroup' when the workflow depends on a named command
group being present and containing the expected commands.
Typical cases:
Why this fits:
commands listUse operation=find when you need the full object set for a type.
Typical cases:
Why this fits:
find makes the plugin useful for day-2 policy audit, not only pre-flight
assertionsresult_format='map_record' is the better shape when later tasks need named
access to specific rules or groups| Need | Query |
|---|---|
| Check that a privileged workflow rule exists and is enabled | sudo_object='rule', operation='show' |
| Check who or what a rule covers | sudo_object='rule', operation='show' |
| Audit allowed and denied commands on a rule | sudo_object='rule', operation='show' |
| Confirm a concrete command object exists | sudo_object='command', operation='show' |
| Inspect membership of a reusable command set | sudo_object='commandgroup', operation='show' |
| Enumerate all rules, commands, or command groups | operation='find' with the appropriate sudo_object |