Copacetic Container Vulnerability Hotpatch Engine
In-place container OS package hotpatching with SecOps approval gates and post-patch verification.
Move OpenLDAP users between OUs with approval, refint checks, UUID assertions, recovery receipts and independent group membership verification.
id: ldap-user-move-membership-proof
namespace: company.identity
description: Review an OpenLDAP OU move, preserve DN-valued group references
through refint, and verify identity and membership after the real rename.
labels:
team: identity
use-case: ldap-user-move
concurrency:
limit: 1
behavior: QUEUE
inputs:
- id: request_id
type: STRING
defaults: move-alice-001
description: Unique reviewed change ID; reuse only for the same request.
- id: username
type: STRING
defaults: alice
description: Unique uid; bounded letters, digits, dot, underscore and hyphen.
- id: base_dn
type: STRING
defaults: dc=example,dc=org
description: One OpenLDAP MDB naming context; group reads must cover the whole context.
- id: source_ou
type: STRING
defaults: ou=people,dc=example,dc=org
description: Existing source OU within base_dn.
- id: destination_ou
type: STRING
defaults: ou=engineering,dc=example,dc=org
description: Existing destination OU within base_dn; the uid is preserved.
- id: ldap_host
type: STRING
defaults: ldap
description: Directory hostname reachable from worker and task containers.
- id: ldap_port
type: INT
defaults: 389
description: LDAP port reachable from the Kestra worker and Docker tasks.
min: 1
max: 65535
- id: dry_run
type: BOOL
defaults: true
description: 'Preview only: no directory or request-ledger writes.'
- id: tools_image
type: STRING
defaults: debian:bookworm-slim
description: Public Debian-compatible image; beforeCommands installs
python3-ldap at runtime.
- id: docker_network
type: STRING
defaults: bridge
description: Docker network with Debian package access and directory
connectivity; use a routable ldap_host.
variables:
install_ldap: >-
apt-get update -qq && DEBIAN_FRONTEND=noninteractive apt-get install -y
--no-install-recommends python3-ldap
ldap_helpers: |
import hashlib, io, json, os, re
from pathlib import Path
import ldap, ldap.dn, ldap.filter, ldif
def load(name):
return json.loads(Path(name).read_text())
def save(name, value):
Path(name).write_text(json.dumps(value, indent=2, sort_keys=True), encoding='utf-8')
def emit(value):
print('::' + json.dumps({'outputs': value}) + '::')
def require(condition, message):
if not condition:
raise ValueError(message)
def canonical(dn):
return tuple(tuple(sorted((a.lower(), v.casefold()) for a, v, _ in rdn)) for rdn in ldap.dn.str2dn(dn))
def digest(value):
return hashlib.sha256(json.dumps(value, sort_keys=True, separators=(',', ':')).encode()).hexdigest()
def records(name):
parser = ldif.LDIFRecordList(io.BytesIO(Path(name).read_bytes()))
parser.parse()
return [{'dn': dn, 'attrs': {k.lower(): sorted(v.decode('utf-8') for v in values) for k, values in attrs.items()}} for dn, attrs in parser.all_records]
def single(record, name):
values = record['attrs'].get(name.lower(), [])
require(len(values) == 1, 'Expected one ' + name + ' on ' + record['dn'])
return values[0]
def config_snapshot(name, scope):
entries = records(name)
databases = [e for e in entries if any(canonical(v) == canonical(scope['base_dn']) for v in e['attrs'].get('olcsuffix', []))]
require(len(databases) == 1, 'Expected one database for base_dn')
database = databases[0]
require(bool(database['attrs'].get('olcrootdn')), 'refint requires a configured database root DN')
overlays = [e for e in entries if canonical(e['dn'])[1:] == canonical(database['dn']) and 'olcrefintattribute' in e['attrs']]
require(len(overlays) == 1, 'Expected a refint overlay on the selected database')
attributes = {a.lower() for v in overlays[0]['attrs']['olcrefintattribute'] for a in v.split()}
require(attributes == {'member'}, 'This blueprint requires refint to manage only member; expand the plan before tracking other reference attributes')
return {'database': database, 'overlay': overlays[0]}
def snapshot(scope, user_file, groups_file, config_file, destination_file):
users = records(user_file)
require(len(users) == 1, 'Expected exactly one matching uid in the naming context')
user = users[0]
require(single(user, 'uid') == scope['username'], 'The uid does not match the request')
require(single(user, 'hassubordinates').upper() == 'FALSE', 'Only leaf users can be moved')
single(user, 'entryuuid'); single(user, 'modifytimestamp')
require('inetorgperson' in {v.lower() for v in user['attrs'].get('objectclass', [])}, 'Expected inetOrgPerson')
destinations = records(destination_file)
require(len(destinations) == 1 and canonical(destinations[0]['dn']) == canonical(scope['destination_ou']), 'Destination OU is missing or ambiguous')
single(destinations[0], 'entryuuid')
groups = records(groups_file)
require(not any(canonical(v) == canonical(scope['new_dn']) for g in groups for v in g['attrs'].get('member', [])), 'Destination DN already has group references')
affected = [g for g in groups if any(canonical(v) == canonical(scope['old_dn']) for v in g['attrs'].get('member', []))]
for group in affected:
single(group, 'entryuuid')
return {'scope': scope, 'user': user, 'groups': sorted(affected, key=lambda g: g['dn']), 'config': config_snapshot(config_file, scope), 'destination': destinations[0]}
def verify(plan, user_file, groups_file):
scope = plan['scope']; errors = []; users = records(user_file); groups = records(groups_file)
if len(users) != 1 or canonical(users[0]['dn']) != canonical(scope['new_dn']):
errors.append('Expected exactly one user at the new DN and none at the old DN')
else:
expected = {k: v for k, v in plan['user']['attrs'].items() if k not in ('modifytimestamp', 'hassubordinates')}
actual = {k: v for k, v in users[0]['attrs'].items() if k not in ('modifytimestamp', 'hassubordinates')}
if actual != expected:
errors.append('User identity or selected attributes changed')
expected_groups = {canonical(g['dn']): g for g in plan['groups']}
actual_groups = {canonical(g['dn']): g for g in groups if any(canonical(v) == canonical(scope['new_dn']) for v in g['attrs'].get('member', []))}
if set(expected_groups) != set(actual_groups):
errors.append('Group membership set differs from the approved snapshot')
for dn in set(expected_groups) & set(actual_groups):
before = expected_groups[dn]; after = actual_groups[dn]
expected_members = {canonical(scope['new_dn']) if canonical(v) == canonical(scope['old_dn']) else canonical(v) for v in before['attrs']['member']}
if single(before, 'entryuuid') != single(after, 'entryuuid') or expected_members != {canonical(v) for v in after['attrs'].get('member', [])}:
errors.append('Group identity or member values changed: ' + after['dn'])
stale = [g['dn'] for g in groups if any(canonical(v) == canonical(scope['old_dn']) for v in g['attrs'].get('member', []))]
if stale:
errors.append('Stale old-DN references remain')
return {'verified': not errors, 'errors': errors, 'expected_groups': [g['dn'] for g in plan['groups']], 'actual_groups': [g['dn'] for g in actual_groups.values()], 'stale_reference_groups': stale, 'observed_user_dns': [u['dn'] for u in users]}
def connect(scope):
connection = ldap.initialize('ldap://' + scope['ldap_host'] + ':' + str(scope['ldap_port']))
connection.set_option(ldap.OPT_REFERRALS, 0)
connection.set_option(ldap.OPT_NETWORK_TIMEOUT, 10)
connection.set_option(ldap.OPT_TIMEOUT, 15)
connection.simple_bind_s(os.environ['BIND_DN'], os.environ['BIND_PASSWORD'])
return connection
tasks:
- id: normalize_request
type: io.kestra.plugin.scripts.shell.Commands
description: Validate bounded identifiers and parsed DNs. Webhooks always
preview; passwords never enter request files.
containerImage: "{{ inputs.tools_image }}"
beforeCommands: [ "{{ vars.install_ldap }}" ]
taskRunner:
{
type: io.kestra.plugin.scripts.runner.docker.Docker,
networkMode: "{{ inputs.docker_network }}"
}
commands:
- |
python3 - <<'PY'
{{ vars.ldap_helpers }}
request = json.loads(os.environ['REQUEST'])
for key in ('request_id', 'username'):
require(isinstance(request[key], str) and re.fullmatch(r'[A-Za-z0-9._-]{1,64}', request[key]), 'Invalid ' + key)
require(re.fullmatch(r'[A-Za-z0-9][A-Za-z0-9.-]{0,252}', request['ldap_host']) is not None, 'Invalid LDAP host')
require(1 <= int(request['ldap_port']) <= 65535, 'Invalid LDAP port')
base = canonical(request['base_dn'])
for name in ('source_ou', 'destination_ou'):
dn = canonical(request[name])
require(len(dn) > len(base) and dn[-len(base):] == base and len(dn[0]) == 1 and dn[0][0][0] == 'ou', name + ' must be an OU inside base_dn')
require(canonical(request['source_ou']) != canonical(request['destination_ou']), 'Source and destination OUs must differ')
scope = {k: request[k] for k in ('request_id', 'username', 'base_dn', 'source_ou', 'destination_ou', 'ldap_host', 'ldap_port')}
scope['old_dn'] = 'uid=' + ldap.dn.escape_dn_chars(scope['username']) + ',' + scope['source_ou']
scope['new_dn'] = 'uid=' + ldap.dn.escape_dn_chars(scope['username']) + ',' + scope['destination_ou']
save('scope.json', scope)
emit({'scope': scope, 'ledger_key': 'ldap_move_' + scope['request_id'], 'user_filter': '(uid=' + ldap.filter.escape_filter_chars(scope['username']) + ')', 'destination_filter': '(entryDN=' + ldap.filter.escape_filter_chars(scope['destination_ou']) + ')', 'dry_run': request['dry_run']})
PY
env:
REQUEST: "{{ {'request_id': trigger.body.request_id ?? inputs.request_id,
'username': trigger.body.username ?? inputs.username, 'base_dn':
inputs.base_dn, 'source_ou': inputs.source_ou, 'destination_ou':
trigger.body.destination_ou ?? inputs.destination_ou, 'ldap_host':
inputs.ldap_host, 'ldap_port': inputs.ldap_port, 'dry_run':
inputs.dry_run or (trigger is defined)} | toJson }}"
outputFiles:
- scope.json
- id: load_request
type: io.kestra.plugin.core.kv.Get
description: Load any previously approved request; the same request ID cannot be
reused for another target.
key: "{{ outputs.normalize_request.vars.ledger_key }}"
errorOnMissing: false
retry: { type: constant, interval: PT5S, maxAttempts: 3 }
- id: before_config
type: io.kestra.plugin.ldap.Search
description: Read only the database suffix/root DN and refint metadata, never
configuration passwords.
hostname: "{{ inputs.ldap_host }}"
port: "{{ inputs.ldap_port }}"
userDn: "{{ secret('LDAP_CONFIG_BIND_DN') }}"
password: "{{ secret('LDAP_CONFIG_PASSWORD') }}"
baseDn: cn=config
pageSize: 200
retry: { type: constant, interval: PT5S, maxAttempts: 3 }
filter: (|(objectClass=olcMdbConfig)(objectClass=olcRefintConfig))
attributes: [ olcSuffix, olcRootDN, olcRefintAttribute, entryUUID, modifyTimestamp ]
- id: before_users
type: io.kestra.plugin.ldap.Search
description: Find the unique uid and request only non-secret
identity/operational attributes.
hostname: "{{ inputs.ldap_host }}"
port: "{{ inputs.ldap_port }}"
userDn: "{{ secret('LDAP_BIND_DN') }}"
password: "{{ secret('LDAP_BIND_PASSWORD') }}"
baseDn: "{{ inputs.base_dn }}"
pageSize: 200
retry: { type: constant, interval: PT5S, maxAttempts: 3 }
filter: "{{ outputs.normalize_request.vars.user_filter }}"
attributes:
[
uid,
cn,
sn,
mail,
objectClass,
entryUUID,
modifyTimestamp,
hasSubordinates
]
- id: before_destination
type: io.kestra.plugin.ldap.Search
description: Locate the destination OU by its parsed DN.
hostname: "{{ inputs.ldap_host }}"
port: "{{ inputs.ldap_port }}"
userDn: "{{ secret('LDAP_BIND_DN') }}"
password: "{{ secret('LDAP_BIND_PASSWORD') }}"
baseDn: "{{ inputs.base_dn }}"
pageSize: 200
retry: { type: constant, interval: PT5S, maxAttempts: 3 }
filter: "{{ outputs.normalize_request.vars.destination_filter }}"
attributes: [ ou, objectClass, entryUUID, modifyTimestamp ]
- id: before_groups
type: io.kestra.plugin.ldap.Search
description: Read paged groupOfNames/member records for the complete naming context.
hostname: "{{ inputs.ldap_host }}"
port: "{{ inputs.ldap_port }}"
userDn: "{{ secret('LDAP_BIND_DN') }}"
password: "{{ secret('LDAP_BIND_PASSWORD') }}"
baseDn: "{{ inputs.base_dn }}"
pageSize: 200
retry: { type: constant, interval: PT5S, maxAttempts: 3 }
filter: (objectClass=groupOfNames)
attributes: [ member, entryUUID, modifyTimestamp ]
- id: plan_move
type: io.kestra.plugin.scripts.shell.Commands
description: Parse native LDIF snapshots into a reviewed plan; block missing
refint, ambiguous identities or conflicting requests.
containerImage: "{{ inputs.tools_image }}"
beforeCommands: [ "{{ vars.install_ldap }}" ]
taskRunner:
{
type: io.kestra.plugin.scripts.runner.docker.Docker,
networkMode: "{{ inputs.docker_network }}"
}
commands:
- |
python3 - <<'PY'
{{ vars.ldap_helpers }}
scope = load('scope.json'); ledger = load('ledger.json') or {}
try:
if ledger:
plan = ledger['plan']
require(plan['scope'] == scope, 'request_id was previously used for different parameters')
users = records('users.ldif')
require(len(users) == 1 and single(users[0], 'entryuuid') == single(plan['user'], 'entryuuid'), 'Recorded user identity is missing or different')
if canonical(users[0]['dn']) == canonical(scope['new_dn']):
mode = 'VERIFY_ONLY'
else:
require(ledger['status'] == 'PENDING', 'Completed request unexpectedly returned to the source DN; use a new reviewed request')
current = snapshot(scope, 'users.ldif', 'groups.ldif', 'config.ldif', 'destination.ldif')
require(canonical(current['user']['dn']) == canonical(scope['old_dn']) and digest(current) == ledger['fingerprint'], 'Pending request state changed; manual review with a new request_id is required')
mode = 'MOVE'
else:
plan = snapshot(scope, 'users.ldif', 'groups.ldif', 'config.ldif', 'destination.ldif')
require(canonical(plan['user']['dn']) == canonical(scope['old_dn']), 'User must exist at the source DN; an existing destination is not proof this request moved it')
mode = 'MOVE'
fingerprint = digest(plan)
save('plan.json', plan)
summary = {'status': 'READY', 'mode': mode, 'fingerprint': fingerprint, 'old_dn': scope['old_dn'], 'new_dn': scope['new_dn'], 'affected_groups': [g['dn'] for g in plan['groups']], 'entry_uuid': single(plan['user'], 'entryuuid')}
except (ValueError, KeyError) as exc:
summary = {'status': 'BLOCKED', 'mode': 'BLOCKED', 'reason': str(exc)}
save('plan.json', {'scope': scope, 'blocked': str(exc)})
save('plan-summary.json', summary)
emit(summary)
PY
inputFiles:
users.ldif: "{{ outputs.before_users.uri }}"
groups.ldif: "{{ outputs.before_groups.uri }}"
config.ldif: "{{ outputs.before_config.uri }}"
destination.ldif: "{{ outputs.before_destination.uri }}"
scope.json: "{{ outputs.normalize_request.outputFiles['scope.json'] }}"
ledger.json: "{{ (outputs.load_request.value ?? {}) | toJson }}"
outputFiles:
- plan.json
- plan-summary.json
- id: block_unsafe_plan
type: io.kestra.plugin.core.flow.If
description: Retain the blocked-plan report, then fail before any approval or mutation.
condition: "{{ outputs.plan_move.vars.status == 'BLOCKED' }}"
then:
- id: plan_blocked
type: io.kestra.plugin.core.execution.Fail
errorMessage: "Move blocked: {{ outputs.plan_move.vars.reason }}. Plan: {{
outputs.plan_move.outputFiles['plan-summary.json'] }}"
- id: if_live_move
type: io.kestra.plugin.core.flow.If
description: Dry-run only produces the plan. A recovered destination goes
directly to verification, never another rename.
condition: "{{ outputs.normalize_request.vars.dry_run == false and
outputs.plan_move.vars.mode == 'MOVE' }}"
then:
- id: review
type: io.kestra.plugin.core.flow.Pause
description: A live move requires explicit approval, the exact plan fingerprint
and a review note; expires closed after one hour.
pauseDuration: PT1H
behavior: FAIL
onResume:
- id: approved
type: BOOL
defaults: false
- id: plan_fingerprint
type: STRING
defaults: ''
- id: review_note
type: STRING
defaults: ''
- id: if_approved
type: io.kestra.plugin.core.flow.If
description: A rejected review ends without LDAP or ledger writes.
condition: "{{ outputs.review.onResume.approved == true }}"
then:
- id: recheck_config
type: io.kestra.plugin.ldap.Search
description: Re-read the selected database/refint configuration after approval.
hostname: "{{ inputs.ldap_host }}"
port: "{{ inputs.ldap_port }}"
userDn: "{{ secret('LDAP_CONFIG_BIND_DN') }}"
password: "{{ secret('LDAP_CONFIG_PASSWORD') }}"
baseDn: cn=config
pageSize: 200
retry: { type: constant, interval: PT5S, maxAttempts: 3 }
filter: (|(objectClass=olcMdbConfig)(objectClass=olcRefintConfig))
attributes: [ olcSuffix, olcRootDN, olcRefintAttribute, entryUUID, modifyTimestamp ]
- id: recheck_users
type: io.kestra.plugin.ldap.Search
description: Re-read identity and modification timestamp after approval.
hostname: "{{ inputs.ldap_host }}"
port: "{{ inputs.ldap_port }}"
userDn: "{{ secret('LDAP_BIND_DN') }}"
password: "{{ secret('LDAP_BIND_PASSWORD') }}"
baseDn: "{{ inputs.base_dn }}"
pageSize: 200
retry: { type: constant, interval: PT5S, maxAttempts: 3 }
filter: "{{ outputs.normalize_request.vars.user_filter }}"
attributes:
[
uid,
cn,
sn,
mail,
objectClass,
entryUUID,
modifyTimestamp,
hasSubordinates
]
- id: recheck_destination
type: io.kestra.plugin.ldap.Search
description: Recheck that the same destination OU still exists.
hostname: "{{ inputs.ldap_host }}"
port: "{{ inputs.ldap_port }}"
userDn: "{{ secret('LDAP_BIND_DN') }}"
password: "{{ secret('LDAP_BIND_PASSWORD') }}"
baseDn: "{{ inputs.base_dn }}"
pageSize: 200
retry: { type: constant, interval: PT5S, maxAttempts: 3 }
filter: "{{ outputs.normalize_request.vars.destination_filter }}"
attributes: [ ou, objectClass, entryUUID, modifyTimestamp ]
- id: recheck_groups
type: io.kestra.plugin.ldap.Search
description: Re-read complete group member snapshots; never use a truncated
membership baseline.
hostname: "{{ inputs.ldap_host }}"
port: "{{ inputs.ldap_port }}"
userDn: "{{ secret('LDAP_BIND_DN') }}"
password: "{{ secret('LDAP_BIND_PASSWORD') }}"
baseDn: "{{ inputs.base_dn }}"
pageSize: 200
retry: { type: constant, interval: PT5S, maxAttempts: 3 }
filter: (objectClass=groupOfNames)
attributes: [ member, entryUUID, modifyTimestamp ]
- id: validate_review
type: io.kestra.plugin.scripts.shell.Commands
description: Require the approved fingerprint and a note; compare fresh
directory/configuration snapshots before persisting approval.
containerImage: "{{ inputs.tools_image }}"
beforeCommands: [ "{{ vars.install_ldap }}" ]
taskRunner:
{
type: io.kestra.plugin.scripts.runner.docker.Docker,
networkMode: "{{ inputs.docker_network }}"
}
commands:
- |
python3 - <<'PY'
{{ vars.ldap_helpers }}
plan = load('plan.json'); review = json.loads(os.environ['REVIEW'])
require(review['approved'] is True, 'Approval is required')
require(review['fingerprint'] == digest(plan), 'Approval fingerprint does not match')
require(isinstance(review['note'], str) and bool(review['note'].strip()), 'A nonempty review note is required')
current = snapshot(plan['scope'], 'users.ldif', 'groups.ldif', 'config.ldif', 'destination.ldif')
require(digest(current) == digest(plan), 'Directory or refint configuration changed during approval; nothing was moved')
emit({'ledger': {'status': 'PENDING', 'plan': plan, 'fingerprint': digest(plan), 'approved_execution_id': os.environ['EXECUTION_ID'], 'review_note': review['note'].strip()}})
PY
inputFiles:
users.ldif: "{{ outputs.recheck_users.uri }}"
groups.ldif: "{{ outputs.recheck_groups.uri }}"
config.ldif: "{{ outputs.recheck_config.uri }}"
destination.ldif: "{{ outputs.recheck_destination.uri }}"
plan.json: "{{ outputs.plan_move.outputFiles['plan.json'] }}"
env:
REVIEW: "{{ {'approved': outputs.review.onResume.approved, 'fingerprint':
outputs.review.onResume.plan_fingerprint, 'note':
outputs.review.onResume.review_note} | toJson }}"
EXECUTION_ID: "{{ execution.id }}"
- id: record_pending
type: io.kestra.plugin.core.kv.Set
description: Persist the approved preimage before attempting the move, so a lost
reply can be reconciled safely.
key: "{{ outputs.normalize_request.vars.ledger_key }}"
kvType: JSON
value: "{{ outputs.validate_review.vars.ledger | toJson }}"
retry: { type: constant, interval: PT5S, maxAttempts: 3 }
- id: move_user
type: io.kestra.plugin.scripts.shell.Commands
description: Rename exactly the approved UUID with an LDAP assertion; on retry,
accept only that UUID already at the destination.
containerImage: "{{ inputs.tools_image }}"
beforeCommands: [ "{{ vars.install_ldap }}" ]
taskRunner:
{
type: io.kestra.plugin.scripts.runner.docker.Docker,
networkMode: "{{ inputs.docker_network }}"
}
commands:
- |
python3 - <<'PY'
{{ vars.ldap_helpers }}
from ldap.controls.libldap import AssertionControl
plan = load('plan.json'); scope = plan['scope']; connection = connect(scope)
expected_uuid = single(plan['user'], 'entryuuid')
def at(dn):
try:
return connection.search_s(dn, ldap.SCOPE_BASE, '(objectClass=*)', ['entryUUID', 'modifyTimestamp'])
except ldap.NO_SUCH_OBJECT:
return []
try:
old = at(scope['old_dn']); new = at(scope['new_dn'])
if not old and len(new) == 1 and new[0][1].get('entryUUID') == [expected_uuid.encode()]:
emit({'moved': True, 'already_moved': True, 'new_dn': scope['new_dn']})
else:
require(len(old) == 1 and not new, 'Source missing or destination occupied; no rename attempted')
require(old[0][1].get('entryUUID') == [expected_uuid.encode()], 'Source UUID differs from approval')
condition = '(&(entryUUID=' + ldap.filter.escape_filter_chars(expected_uuid) + ')(modifyTimestamp=' + ldap.filter.escape_filter_chars(single(plan['user'], 'modifytimestamp')) + '))'
rdn = ldap.dn.dn2str(ldap.dn.str2dn(scope['old_dn'])[:1])
connection.rename_s(scope['old_dn'], rdn, newsuperior=scope['destination_ou'], delold=1, serverctrls=[AssertionControl(criticality=True, filterstr=condition)])
emit({'moved': True, 'already_moved': False, 'new_dn': scope['new_dn']})
finally:
connection.unbind_s()
PY
inputFiles:
plan.json: "{{ outputs.plan_move.outputFiles['plan.json'] }}"
env:
BIND_DN: "{{ secret('LDAP_BIND_DN') }}"
BIND_PASSWORD: "{{ secret('LDAP_BIND_PASSWORD') }}"
retry: { type: constant, interval: PT5S, maxAttempts: 3 }
else:
- id: review_rejected
type: io.kestra.plugin.core.output.OutputValues
values:
status: REJECTED
directory_changed: false
- id: if_verify
type: io.kestra.plugin.core.flow.If
description: Verify only an approved move or a previously approved request found
at the destination.
condition: "{{ outputs.normalize_request.vars.dry_run == false and
(outputs.plan_move.vars.mode == 'VERIFY_ONLY' or
(outputs.review.onResume.approved ?? false) == true) }}"
then:
- id: after_users
type: io.kestra.plugin.ldap.Search
description: Independently read the user after mutation or recovery.
hostname: "{{ inputs.ldap_host }}"
port: "{{ inputs.ldap_port }}"
userDn: "{{ secret('LDAP_BIND_DN') }}"
password: "{{ secret('LDAP_BIND_PASSWORD') }}"
baseDn: "{{ inputs.base_dn }}"
pageSize: 200
retry: { type: constant, interval: PT5S, maxAttempts: 3 }
filter: "{{ outputs.normalize_request.vars.user_filter }}"
attributes:
[
uid,
cn,
sn,
mail,
objectClass,
entryUUID,
modifyTimestamp,
hasSubordinates
]
- id: after_groups
type: io.kestra.plugin.ldap.Search
description: Independently read all groups to prove preservation and zero stale
old-DN references.
hostname: "{{ inputs.ldap_host }}"
port: "{{ inputs.ldap_port }}"
userDn: "{{ secret('LDAP_BIND_DN') }}"
password: "{{ secret('LDAP_BIND_PASSWORD') }}"
baseDn: "{{ inputs.base_dn }}"
pageSize: 200
retry: { type: constant, interval: PT5S, maxAttempts: 3 }
filter: (objectClass=groupOfNames)
attributes: [ member, entryUUID, modifyTimestamp ]
- id: verify_memberships
type: io.kestra.plugin.scripts.shell.Commands
description: Compare actual LDAP state against the saved identity and full
member sets; emit a downloadable report before any failure gate.
containerImage: "{{ inputs.tools_image }}"
beforeCommands: [ "{{ vars.install_ldap }}" ]
taskRunner:
{
type: io.kestra.plugin.scripts.runner.docker.Docker,
networkMode: "{{ inputs.docker_network }}"
}
commands:
- |
python3 - <<'PY'
{{ vars.ldap_helpers }}
plan = load('plan.json')
result = verify(plan, 'users.ldif', 'groups.ldif')
result.update({'request_id': plan['scope']['request_id'], 'entry_uuid': single(plan['user'], 'entryuuid'), 'old_dn': plan['scope']['old_dn'], 'new_dn': plan['scope']['new_dn'], 'status': 'VERIFIED' if result['verified'] else 'MOVED_VERIFICATION_FAILED'})
save('verification.json', result)
emit({'verified': result['verified'], 'errors': result['errors'], 'ledger': {'status': 'COMPLETE', 'plan': plan, 'fingerprint': digest(plan)}})
PY
inputFiles:
plan.json: "{{ outputs.plan_move.outputFiles['plan.json'] }}"
users.ldif: "{{ outputs.after_users.uri }}"
groups.ldif: "{{ outputs.after_groups.uri }}"
outputFiles:
- verification.json
- id: fail_incomplete_move
type: io.kestra.plugin.core.flow.If
description: A returned rename result alone is not proof of preservation. Keep
the pending ledger and measured report on failure.
condition: "{{ outputs.verify_memberships.vars.verified == false }}"
then:
- id: membership_verification_failed
type: io.kestra.plugin.core.execution.Fail
errorMessage: "Move outcome needs manual recovery: {{
outputs.verify_memberships.vars.errors | join('; ') }}. Report: {{
outputs.verify_memberships.outputFiles['verification.json'] }}"
- id: record_complete
type: io.kestra.plugin.core.kv.Set
description: Keep the original approved snapshot and COMPLETE receipt for repeat
delivery and recovery checks.
key: "{{ outputs.normalize_request.vars.ledger_key }}"
kvType: JSON
value: "{{ outputs.verify_memberships.vars.ledger | toJson }}"
retry: { type: constant, interval: PT5S, maxAttempts: 3 }
- id: result
type: io.kestra.plugin.core.output.OutputValues
values:
status: "{{ outputs.normalize_request.vars.dry_run ? 'DRY_RUN' :
((outputs.verify_memberships.vars.verified ?? false) ? 'VERIFIED' :
'REJECTED') }}"
old_dn: "{{ outputs.normalize_request.vars.scope.old_dn }}"
new_dn: "{{ outputs.normalize_request.vars.scope.new_dn }}"
fingerprint: "{{ outputs.plan_move.vars.fingerprint }}"
plan_uri: "{{ outputs.plan_move.outputFiles['plan-summary.json'] }}"
verification_uri: "{{ outputs.verify_memberships.outputFiles['verification.json'] ?? '' }}"
errors:
- id: first_error
type: io.kestra.plugin.core.output.OutputValues
values:
task: "{{ (errorLogs() | length) > 0 ? (errorLogs()[0].taskId ?? 'execution') :
'execution' }}"
message: "{{ (errorLogs() | length) > 0 ? errorLogs()[0].message : 'No task
error logged' }}"
link: "{{ (kestra.url ?? 'http://localhost:8080/') ~ 'ui/main/executions/' ~
flow.namespace ~ '/' ~ flow.id ~ '/' ~ execution.id }}"
- id: log_failure
type: io.kestra.plugin.core.log.Log
level: ERROR
message: "{{ flow.id }} / {{ execution.id }} failed in {{
outputs.first_error.values.task }}: {{ outputs.first_error.values.message
}}. Rename confirmation={{ outputs.move_user.vars.moved ?? 'UNKNOWN:
inspect both DNs and the pending ledger' }}. {{
outputs.first_error.values.link }}"
- id: alert_failure
type: io.kestra.plugin.core.http.Request
description: Send the actual failed task and recovery pointers; no missing
response is treated as proof the directory was unchanged.
uri: "{{ secret('LDAP_MOVE_ALERT_URL') }}"
method: POST
contentType: application/json
body: "{{ {'flow_id': flow.id, 'execution_id': execution.id, 'failed_task':
outputs.first_error.values.task, 'message':
outputs.first_error.values.message, 'execution_url':
outputs.first_error.values.link, 'plan_uri':
outputs.plan_move.outputFiles['plan-summary.json'] ?? '',
'verification_uri':
outputs.verify_memberships.outputFiles['verification.json'] ?? '',
'move_confirmed': outputs.move_user.vars.moved ?? 'UNKNOWN; inspect the
approved UUID at both DNs'} | toJson }}"
retry: { type: constant, interval: PT5S, maxAttempts: 3 }
triggers:
- id: move_request
type: io.kestra.plugin.core.trigger.Webhook
description: Preview requests only; the payload cannot enable a live move or
override connection credentials.
disabled: true
key: "{{ secret('LDAP_MOVE_WEBHOOK_KEY') }}"
fetchType: FETCH
Move a leaf inetOrgPerson between OUs while preserving its UUID and groupOfNames/member references. OU-based permissions are outside scope.
Download outputs.plan_move.outputFiles['plan-summary.json'] and outputs.verify_memberships.outputFiles['verification.json']. outputs.result.values exposes status and report URIs. Alerts include the failed task and execution link.
Identity engineers can use this flow when reorganizing OpenLDAP users whose groups store member DNs. It checks that moving a user preserves their identity and memberships.
Kestra keeps the reviewed snapshot across approval and checks it again before a move. Durable receipts reconcile interrupted requests, and independent reads verify the result before the change is marked complete.
Use Kestra 2.0.8, LDAP/Shell plugins, Docker and OpenLDAP MDB with rootDN and refint_attributes member. Accounts need context-wide reads, rename rights and cn=config read access. Users, groups and the destination OU must exist.
Each shell container uses public Debian and installs python3-ldap via the shared install_ldap command. Allow package access. Both the worker and containers need LDAP connectivity; bridge cannot resolve sibling container names. Use a trusted network; TLS needs separate configuration.
Extend planning and verification together for other reference attributes. Recover concurrent-edit failures manually using reports and the pending receipt.
In-place container OS package hotpatching with SecOps approval gates and post-patch verification.
Audits HashiCorp Consul Raft consensus cluster leadership and voter quorum to prevent service discovery outages.
Reads /etc/os-release from each image you list, checks the distro on endoflife.date, and alerts Slack when an image runs an OS that is past end of life or about to be.
Deletes ConfigMaps and Secrets no pod references and reports the cleanup on Slack.
Run conftest against rendered Kubernetes manifests from a CI webhook and escalate every failed rule as a GitHub issue and a Slack alert.
Audits Project Contour ingress controller for Envoy xDS configuration NACKs, CDS sync delay, and proxy disconnects.
Automatically open a Jira issue whenever any Kestra workflow fails or hits a warning, so incidents get tracked the moment they happen.
Automatically open a high-priority HubSpot ticket whenever a Kestra workflow fails or finishes with a warning.
Automatically open a PagerDuty incident whenever any Kestra workflow fails or hits a warning state.
Automatically open a Zendesk incident ticket whenever any workflow in your namespace fails or warns.
Gate a release with a Dag. Git tag, container tag and a staging smoke-test subflow run in parallel, dependent steps wait for exactly what they need, one failure cancels the rest, orphaned child executions are killed, and the release id is a label on every execution of the release.
Download a CSV from any public URL and bulk-load it into PostgreSQL using the fast native COPY protocol.
