Related docs:
SELINUX MAP PLUGIN SELINUX MAP USE CASES HBAC RULE PLUGIN DOCS MAP
Use this guide to choose the right SELinux map query pattern for your automation.
It is the companion to the selinuxmap plugin reference. Use the reference for exact option syntax; use this guide when you are designing a confinement validation workflow and need to know which capability fits your situation.
flowchart LR
need["Confinement state question"]
map["Map exists and enabled?"]
context["Correct SELinux user context?"]
scope["Direct membership or HBAC-linked?"]
gate["Assert or gate"]
act["Proceed or fail"]
need --> map
need --> context
need --> scope
map --> gate
context --> gate
scope --> gate
gate --> act
The selinuxmap plugin is a read-only pre-flight primitive. It does not create or modify IdM objects. Use it to answer confinement state questions and to gate automation that should only proceed when the SELinux map model is correct.
Use eigenstate.ipa.selinuxmap before a play deploys to a host when the
deployment depends on the target having correct SELinux confinement configured
in IdM.
Typical cases:
unconfined_uflowchart LR
check["selinuxmap show\nmap name"] --> exists{"exists?"}
exists -->|no| fail["fail - map not registered in IdM"]
exists -->|yes| enabled{"enabled?"}
enabled -->|no| fail2["fail - map is disabled"]
enabled -->|yes| deploy["proceed to deploy"]
Why this pattern fits:
eigenstate.ipa.selinuxmap returns exists: false when the map is absent
rather than raising an error, so a single assert covers both the absent and
disabled cases cleanlyUse eigenstate.ipa.selinuxmap to assert that a specific SELinux user string
is assigned, not just that the map exists.
Typical cases:
staff_u rather
than unconfined_uunconfined_uflowchart LR
check["selinuxmap show\nmap name"] --> exists{"exists\nand enabled?"}
exists -->|no| fail["fail - map absent or disabled"]
exists -->|yes| context{"selinuxuser is\nexpected value?"}
context -->|no| fail2["fail - wrong context assigned"]
context -->|yes| pass["confinement context confirmed"]
Why this pattern fits:
selinuxuser field is the exact string SSSD and pam_selinux will use;
asserting it here confirms the map delivers the intended confinementunconfined_u provides no confinement at allUse eigenstate.ipa.selinuxmap and eigenstate.ipa.hbacrule together when
the map’s scope comes from an HBAC rule rather than direct membership.
Typical cases:
flowchart LR
selinux["selinuxmap show\nmap name"] --> hbac_linked{"hbacrule\nnot null?"}
hbac_linked -->|no| direct["direct membership -\nassert users/hosts directly"]
hbac_linked -->|yes| hbac["hbacrule show\nlinked rule name"]
hbac --> both{"map enabled\nand rule enabled?"}
both -->|no| fail["fail - confinement or\naccess boundary inactive"]
both -->|yes| pass["full confinement model confirmed"]
Why this pattern fits:
enabled: true; the
HBAC link provides the scope, not a redundant gatemap.hbacrule gives the rule name directly; pass it to eigenstate.ipa.hbacrule
without hardcodingUse eigenstate.ipa.selinuxmap to verify that a confinement map is disabled
before performing maintenance that requires elevated access, then re-assert
that it is re-enabled afterward.
Typical cases:
unconfined_u
access and the play should fail if the map is still activeflowchart LR
pre["selinuxmap show\nbefore maintenance"] --> disabled{"enabled=false?"}
disabled -->|no| fail["fail - map still active,\ndo not proceed"]
disabled -->|yes| work["perform maintenance tasks"]
work --> post["selinuxmap show\nafter maintenance"]
post --> re_enabled{"enabled=true?"}
re_enabled -->|no| alert["alert - confinement not restored"]
re_enabled -->|yes| close["close change window"]
Why this pattern fits:
enabled field reflects the map’s active state in IdM; polling it
before and after maintenance confirms the change management process ran
correctlyignore_errors because an absent map returns
exists: false rather than raisingUse operation=find to enumerate all SELinux user maps and report on their
state.
Typical cases:
unconfined_uflowchart LR
find["selinuxmap find"] --> all["all maps in IdM"]
all --> filter["filter by selinuxuser,\nenabled, or hbacrule"]
filter --> report["report or assert"]
Why this pattern fits:
find returns all maps without requiring knowledge of their namesresult_format=map_record makes it easy to reference maps by name in
subsequent assert or debug tasksselectattr avoids shell-out to ipa selinuxusermap-findUse ansible.builtin.assert with the selinuxmap record to abort a pipeline
stage when required confinement infrastructure is absent.
Typical cases:
flowchart LR
check["selinuxmap show\nall required maps"] --> 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 maps by name, which is
more readable when checking several identities at onceCombine eigenstate.ipa.selinuxmap and eigenstate.ipa.hbacrule in the same
play to validate the complete confinement and access model.
flowchart LR
map["selinuxmap show\nmap name"] --> linked{"has hbacrule?"}
linked -->|no| direct_assert["assert direct\nusers/hosts present"]
linked -->|yes| hbac["hbacrule show\nmap.hbacrule"]
hbac --> hbac_enabled{"rule enabled?"}
hbac_enabled -->|no| fail["fail - HBAC rule inactive"]
hbac_enabled -->|yes| test["hbacrule test\nconfirm access granted"]
test --> pass["full model validated"]
Use this pattern in compliance or pre-deploy roles that need to confirm both
that the SELinux confinement boundary is active and that the access boundary
it depends on is operational. The hbacrule operation=test step adds a live
simulation of whether the identity would be permitted access.
| Need | Best capability |
|---|---|
| Confirm map exists and is enabled before deploying | Pre-flight before deploy (#1) |
| Assert specific SELinux context is assigned | Validate confinement context (#2) |
| Validate map and its linked HBAC rule together | HBAC-linked map validation (#3) |
| Confirm map is disabled during maintenance window | Maintenance window gate (#4) |
| List all maps and their confinement state | Bulk audit (#5) |
| Abort pipeline if any required map is missing | Pipeline gate (#6) |
| Validate confinement + access boundary in one play | Cross-plugin: map + hbacrule (#7) |
For option-level behavior, field definitions, and exact lookup syntax, return to SELINUX MAP PLUGIN.