This directory contains Ansible integration for validating SCIM 2.0 payloads using scim-sanity.
The Ansible Action Plugin allows you to validate SCIM resources directly in your Ansible playbooks, ensuring that SCIM payloads are correct before they reach a SCIM server. Supports User, Group, Agent, and AgenticApplication resource types.
-
Install scim-sanity on the Ansible control node:
pip install scim-sanity
-
Copy the action plugin to your Ansible action plugins directory:
# Option 1: Use in a specific playbook directory mkdir -p playbooks/action_plugins cp ansible/action_plugins/scim_validate.py playbooks/action_plugins/ # Option 2: Install system-wide (requires Ansible configuration) # Copy to your Ansible action_plugins directory (check ansible.cfg for location)
-
Verify installation:
ansible-playbook --version python -c "import scim_sanity; print('scim-sanity installed')"
- name: Validate SCIM user payload
scim_validate:
payload: "{{ user_payload }}"
operation: full
register: validation_result
- name: Fail if validation fails
fail:
msg: "SCIM validation failed"
when: not validation_result.validpayload(dict or string, optional): SCIM payload as a dictionary or JSON stringfile(string, optional): Path to a JSON file containing SCIM payloadoperation(string, optional): Validation operation typefull(default): Validate a full SCIM resource (POST/PUT)patch: Validate a SCIM PATCH operation
fail_on_error(boolean, optional): Whether to fail the task if validation fails (default:true)
Note: Either payload or file must be provided, but not both.
valid(boolean): Whether the SCIM payload is validerrors(list): List of validation errors (if any)- Each error contains:
message: Error messagepath: Attribute path where error occurredline: Line number (if available)
- Each error contains:
msg(string): Human-readable message about validation result
- name: Validate user payload
scim_validate:
payload:
schemas:
- "urn:ietf:params:scim:schemas:core:2.0:User"
userName: "user@example.com"
operation: full
register: result- name: Validate SCIM payload from file
scim_validate:
file: "/path/to/user-payload.json"
operation: full
register: result- name: Validate PATCH operation
scim_validate:
payload: "{{ patch_payload }}"
operation: patch
register: result- name: Validate but don't fail
scim_validate:
payload: "{{ user_payload }}"
operation: full
fail_on_error: false
register: result
- name: Handle validation result
debug:
msg: "Validation {{ 'passed' if result.valid else 'failed' }}"- name: Validate before provisioning
scim_validate:
payload: "{{ user_payload }}"
operation: full
register: validation
- name: Provision user if valid
uri:
url: "https://api.example.com/scim/v2/Users"
method: POST
body: "{{ user_payload | to_json }}"
when: validation.valid
- name: Report validation errors
debug:
var: validation.errors
when: not validation.validIdentity providers such as Microsoft Entra ID and Google Workspace act as SCIM clients — they push provisioning data to your application's SCIM server. Use the linter to validate payloads your SCIM server will handle, and the probe to verify your server is ready to receive them.
See the Entra ID and Google Workspace integration guides for IdP-specific payload examples and architecture details.
scim-sanity also includes a probe subcommand that tests live SCIM servers for RFC 7643/7644 conformance. You can run it from Ansible using the command module:
- name: Probe SCIM server for conformance
command: >
scim-sanity probe {{ scim_endpoint }}
--token {{ scim_token }}
--json-output
--i-accept-side-effects
register: probe_result
- name: Parse probe results
set_fact:
probe_report: "{{ probe_result.stdout | from_json }}"
- name: Fail if probe detected conformance issues
fail:
msg: "SCIM server has {{ probe_report.summary.failed }} conformance failures"
when: probe_report.summary.failed > 0The probe creates, modifies, and deletes real test resources on the target server. The --i-accept-side-effects flag is required. See the main scim-sanity documentation for full probe options.
The plugin returns detailed error information:
- name: Validate and handle errors
scim_validate:
payload: "{{ user_payload }}"
operation: full
fail_on_error: false
register: validation
- name: Display errors
debug:
msg: "Error at {{ item.path }}: {{ item.message }}"
loop: "{{ validation.errors }}"
when: not validation.valid- Validate before provisioning: Always validate SCIM payloads before they reach a SCIM server
- Use in CI/CD: Integrate validation into your deployment pipelines
- Fail fast: Use
fail_on_error: true(default) to catch issues early - Store valid payloads: Only proceed with provisioning if validation passes
- Log validation results: Register results and use them for reporting
Install scim-sanity on the Ansible control node:
pip install scim-sanityEnsure the action plugin is in the correct location:
- For playbook-specific:
playbooks/action_plugins/scim_validate.py - For system-wide: Check
ansible.cfgforaction_pluginspath
Check that:
- Payload is valid JSON
- Required SCIM attributes are present
- Schema URIs are correct
- Operation type matches payload type