2026-01-14 16:17:44 +01:00
---
# Configure invitation stage for enrollment flow
- name : Use bootstrap token for API access
set_fact :
authentik_api_token : "{{ client_secrets.authentik_bootstrap_token }}"
- name : Wait for Authentik API to be ready
uri :
url : "https://{{ authentik_domain }}/api/v3/root/config/"
method : GET
validate_certs : no
status_code : 200
register : api_result
until : api_result.status == 200
retries : 12
delay : 5
2026-01-18 17:06:04 +01:00
ignore_errors : yes
failed_when : false
2026-01-14 16:17:44 +01:00
- name : Create blueprints directory on server
file :
path : /opt/config/authentik/blueprints
state : directory
mode : '0755'
2026-01-18 17:06:04 +01:00
when : api_result.status is defined and api_result.status == 200
2026-01-14 16:17:44 +01:00
2026-01-15 11:22:53 +01:00
- name : Copy public enrollment flow blueprint to server
2026-01-14 16:17:44 +01:00
copy :
2026-01-15 11:22:53 +01:00
src : enrollment-flow.yaml
dest : /opt/config/authentik/blueprints/enrollment-flow.yaml
2026-01-14 16:17:44 +01:00
mode : '0644'
2026-01-15 11:22:53 +01:00
register : enrollment_blueprint_copied
2026-01-18 17:06:04 +01:00
when : api_result.status is defined and api_result.status == 200
2026-01-14 16:17:44 +01:00
2026-01-15 11:22:53 +01:00
- name : Copy enrollment blueprint into authentik-worker container
2026-01-14 16:17:44 +01:00
shell : |
2026-01-15 11:22:53 +01:00
docker cp /opt/config/authentik/blueprints/enrollment-flow.yaml authentik-worker:/blueprints/enrollment-flow.yaml
2026-01-18 17:06:04 +01:00
when : api_result.status is defined and api_result.status == 200
2026-01-14 16:17:44 +01:00
2026-01-15 11:22:53 +01:00
- name : Copy enrollment blueprint into authentik-server container
2026-01-14 16:17:44 +01:00
shell : |
2026-01-15 11:22:53 +01:00
docker cp /opt/config/authentik/blueprints/enrollment-flow.yaml authentik-server:/blueprints/enrollment-flow.yaml
2026-01-18 17:06:04 +01:00
when : api_result.status is defined and api_result.status == 200
2026-01-14 16:17:44 +01:00
2026-01-15 11:22:53 +01:00
- name : Wait for enrollment blueprint to be discovered and applied
2026-01-14 16:17:44 +01:00
shell : |
2026-01-15 11:22:53 +01:00
echo "Waiting for public enrollment blueprint to be discovered and applied..."
2026-01-14 16:17:44 +01:00
sleep 10
# Check if blueprint instance was created
i=1
while [ $i -le 24 ]; do
result=$(docker exec authentik-server curl -sf -H 'Authorization : Bearer {{ authentik_api_token }}' \
'http://localhost:9000/api/v3/managed/blueprints/' 2 >/dev/null || echo '')
2026-01-15 11:22:53 +01:00
if echo "$result" | grep -q 'public-enrollment-flow'; then
2026-01-14 16:17:44 +01:00
echo "Blueprint instance found"
2026-01-15 11:22:53 +01:00
if echo "$result" | grep -A 10 'public-enrollment-flow' | grep -q 'successful'; then
2026-01-14 16:17:44 +01:00
echo "Blueprint applied successfully"
exit 0
fi
fi
sleep 5
i=$((i+1))
done
echo "Blueprint deployment in progress (may take 1-2 minutes)"
2026-01-15 11:22:53 +01:00
register : enrollment_blueprint_result
2026-01-14 16:17:44 +01:00
changed_when : false
2026-01-18 17:06:04 +01:00
when : api_result.status is defined and api_result.status == 200
2026-01-14 16:17:44 +01:00
2026-01-15 11:22:53 +01:00
- name : Verify enrollment flow was created
2026-01-14 16:17:44 +01:00
shell : |
docker exec authentik-server curl -sf -H 'Authorization : Bearer {{ authentik_api_token }}' \
2026-01-15 11:22:53 +01:00
'http://localhost:9000/api/v3/flows/instances/?slug=default-enrollment-flow' | \
2026-01-14 16:17:44 +01:00
python3 -c "import sys, json; d = json.load(sys.stdin); print(json.dumps({'found': len(d.get('results', [])) > 0, 'count': len(d.get('results', []))}))"
2026-01-15 11:22:53 +01:00
register : enrollment_flow_check
2026-01-14 16:17:44 +01:00
changed_when : false
failed_when : false
2026-01-18 17:06:04 +01:00
when : api_result.status is defined and api_result.status == 200
2026-01-14 16:17:44 +01:00
2026-01-15 11:22:53 +01:00
- name : Display public enrollment flow configuration status
2026-01-14 16:17:44 +01:00
debug :
msg : |
========================================
2026-01-15 11:22:53 +01:00
Authentik Public Enrollment Flow
2026-01-14 16:17:44 +01:00
========================================
Configuration Method : YAML Blueprints
2026-01-15 11:22:53 +01:00
Blueprint File : /blueprints/enrollment-flow.yaml
2026-01-14 16:17:44 +01:00
2026-01-15 11:22:53 +01:00
✓ Blueprint Deployed : {{ enrollment_blueprint_copied.changed | default(false) }}
2026-01-18 17:06:04 +01:00
✓ Blueprint Applied : {{ 'In Progress' if (enrollment_blueprint_result is defined and enrollment_blueprint_result.rc is defined and enrollment_blueprint_result.rc != 0) else 'Complete' }}
2026-01-14 16:17:44 +01:00
2026-01-15 11:22:53 +01:00
Verification : {{ enrollment_flow_check.stdout | default('{}') }}
Features :
2026-01-19 14:06:48 +01:00
- Invitation-only enrollment (requires valid invitation token)
2026-01-15 11:22:53 +01:00
- User prompts : username, name, email, password
- Automatic user creation and login
2026-01-14 16:17:44 +01:00
2026-01-19 14:06:48 +01:00
Note : Brand enrollment flow is NOT auto-configured (API restriction).
Flow is accessible via direct URL even without brand configuration.
2026-01-14 16:17:44 +01:00
2026-01-19 14:06:48 +01:00
To use enrollment :
1. Create invitation : Directory > Invitations > Create Invitation
2. Share invitation link : https://{{ authentik_domain }}/if/flow/default-enrollment-flow/?itoken=TOKEN
To verify :
2026-01-14 16:17:44 +01:00
- Login to https://{{ authentik_domain }}
2026-01-15 11:22:53 +01:00
- Check Admin > Flows for "default-enrollment-flow"
2026-01-19 14:06:48 +01:00
- Test enrollment URL : https://{{ authentik_domain }}/if/flow/default-enrollment-flow/
2026-01-14 16:17:44 +01:00
========================================
2026-01-18 17:06:04 +01:00
when : api_result.status is defined and api_result.status == 200