eigenstate-ipa

HBAC Rule Capabilities

Related docs:

  HBAC RULE PLUGIN     HBAC RULE USE CASES     SELINUX MAP CAPABILITIES     DOCS MAP  

Purpose

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.

Contents

Capability Model

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.

1. Pre-flight Before Deployment — Rule Exists and Is Enabled

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:

2. Validate Access Would Be Granted Before Running Tasks

Use 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:

3. Validate Access Is Denied for Restricted Identities

Use 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:

flowchart 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:

4. Check Rule Scope — Membership or Category

Use 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:

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:

5. Bulk Audit of All HBAC Rules

Use operation=find to enumerate all HBAC rules and report on their state.

Typical cases:

flowchart 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:

6. Pipeline Gate — Abort When Access Policy Is Wrong

Use 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:

7. Cross-Plugin: HBAC Rule State Then SELinux Map Validation

Combine 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.

Quick Decision Matrix

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.