Related docs:
HBAC RULE PLUGIN HBAC RULE USE CASES SELINUX MAP CAPABILITIES DOCS MAP
Use this guide to choose the right HBAC rule query pattern for your automation.
It is the companion to the hbacrule plugin reference. Use the reference for exact option syntax; use this guide when you are designing an access validation or confinement workflow and need to know which capability fits your situation.
flowchart LR
need["Access policy question"]
config["Rule exists\nand enabled?"]
scope["Who is in scope?\nUsers, hosts, services"]
live["Would this user\nbe allowed now?"]
gate["Assert or report"]
act["Proceed, fail,\nor validate SELinux link"]
need --> config
need --> scope
need --> live
config --> gate
scope --> gate
live --> gate
gate --> act
The hbacrule plugin has two modes: configuration inspection (show,
find) answers whether a rule exists, is enabled, and who is in scope.
Live access test (operation=test) runs the actual FreeIPA hbactest engine
and answers whether a specific user would be permitted.
Use configuration inspection when you are validating that policy is in place. Use access test when you need to confirm that policy is operating correctly for a specific identity, host, and service tuple.
Use eigenstate.ipa.hbacrule with operation=show before a play that deploys
to a host, when the deployment depends on the target having correct access
policy in IdM.
Typical cases:
flowchart LR
check["hbacrule show\nrule name"] --> exists{"exists?"}
exists -->|no| fail["fail - rule not registered in IdM"]
exists -->|yes| enabled{"enabled?"}
enabled -->|no| fail2["fail - rule is disabled"]
enabled -->|yes| deploy["proceed to deploy"]
Why this pattern fits:
show returns exists: false for missing rules rather than raising, so a
single assert covers both the absent and disabled casesUse operation=test to confirm that a specific identity would actually be
allowed access before running tasks that depend on it.
Typical cases:
flowchart LR
test["hbacrule test\nuser, targethost, service"] --> granted{"denied=false?"}
granted -->|no| fail["fail - access would be denied\ncheck matched/notmatched"]
granted -->|yes| proceed["proceed with automation"]
Why this pattern fits:
operation=test calls the same FreeIPA hbactest engine SSSD uses; the
result is authoritative for this IdM server’s current policy statematched and notmatched in the result identify which rules are relevant,
which aids debugging when access is unexpectedly deniedUse operation=test to confirm that identities outside a defined scope cannot
reach a restricted host. This is the inverse of capability #2.
Typical cases:
Important caveat:
denied: true expectation only holds when no broader enabled HBAC rule also grants accessallow_all will still return access granted even when the specific rule under review does not matchmatched or notmatched as intendedflowchart LR
test["hbacrule test\nrestricted-user, prod-host, sshd"] --> denied{"denied=true?"}
denied -->|no| fail["fail - access was granted,\nexpected denial"]
denied -->|yes| pass["access correctly denied"]
Why this pattern fits:
denied: true confirms the access boundary from the outside,
not just from the policy configuration viewmatched field identifies any rule that unexpectedly granted access,
which points directly to what needs to be fixedUse show or find to inspect which identities and hosts are in scope for a
rule, and whether the rule uses category-wide (all) or direct membership
scope.
Typical cases:
usercategory=all or hostcategory=all
(permissive rules that apply universally)flowchart LR
show["hbacrule show\nrule name"] --> cat{"usercategory=all\nor hostcategory=all?"}
cat -->|yes| wide["rule applies universally -\nreport or assert intent"]
cat -->|no| members["check users/groups\nand hosts/hostgroups lists"]
members --> present{"target identity\nin scope?"}
present -->|yes| pass["identity is in scope"]
present -->|no| fail["identity not in scope -\nrule will not match"]
Why this pattern fits:
usercategory=all rules like allow_all match every user; confirming their
enabled state is the important check rather than membership listsUse operation=find to enumerate all HBAC rules and report on their state.
Typical cases:
allow_all scopeflowchart LR
find["hbacrule find"] --> all["all rules in IdM"]
all --> filter["filter by enabled state,\ncategory, or membership"]
filter --> report["report or assert"]
Why this pattern fits:
find returns all rules without requiring knowledge of their namesresult_format=map_record makes it easy to reference rules by name in
subsequent tasksselectattr avoids shell-out to ipa hbacrule-findUse ansible.builtin.assert with the hbacrule record to abort a pipeline
stage when required access policy is absent or incorrect.
Typical cases:
flowchart LR
check["hbacrule show\nall required rules"] --> assert{"all exist\nand enabled?"}
assert -->|yes| deploy["proceed to deploy stage"]
assert -->|no| abort["fail with diagnostic message"]
Why this pattern fits:
result_format=map_record lets the assert reference rules by name, which is
more readable when checking several policies at onceCombine eigenstate.ipa.hbacrule and eigenstate.ipa.selinuxmap to validate
the complete access and confinement model from the access side.
flowchart LR
hbac["hbacrule show\nops-deploy"] --> hbac_ok{"exists\nand enabled?"}
hbac_ok -->|no| fail_hbac["fail - access rule inactive"]
hbac_ok -->|yes| test["hbacrule test\nconfirm access granted"]
test --> granted{"denied=false?"}
granted -->|no| fail_test["fail - access denied"]
granted -->|yes| selinux["selinuxmap show\nops-deploy-map"]
selinux --> conf_ok{"map enabled,\ncorrect context?"}
conf_ok -->|no| fail_conf["fail - confinement inactive or wrong"]
conf_ok -->|yes| pass["access + confinement confirmed"]
Use this pattern in pre-deploy roles that need to confirm both that the identity can reach the target (HBAC) and that it will be confined correctly (SELinux map) when it does.
| Need | Best capability |
|---|---|
| Confirm rule exists and is enabled before deploying | Pre-flight — rule present (#1) |
| Confirm a user would actually be allowed access | Live access test (#2) |
| Confirm a restricted user cannot reach a host | Inverse access test (#3) |
| Check which identities and hosts are in scope | Scope inspection (#4) |
| List all rules and their state | Bulk audit (#5) |
| Abort pipeline if any required rule is wrong | Pipeline gate (#6) |
| Validate access rule and confinement map together | Cross-plugin: hbac + selinuxmap (#7) |
For option-level behavior, field definitions, and exact lookup syntax, return to HBAC RULE PLUGIN.