EnterpriseTetragon

Tetragon automation

Roll DefenseClaw's Tetragon integration out to a Linux fleet with Preview Ansible plays, a readiness script and Puppet, Chef and Salt templates.

Preview

These plays, scripts and templates are Preview examples. Read each one and test it on a few computers before you run it on a fleet.

Each file automates one part of Tetragon on a Linux fleet. They all run the same three DefenseClaw commands: ensure --from-package --config <file> --json, verify --json and tetragon verify --ready-for <mode>.

FileWhat it doesChanges the computer
harden-tetragon.ymlWrites the Tetragon settings DefenseClaw needs and checks BPF LSMYes, Tetragon settings and a restart
defenseclaw-tetragon.yml and config.yaml.j2Installs DefenseClaw, renders the ring's config, applies it and gates the ringYes
fleet-readiness.yml and fleet-readiness.shOne summary of the whole fleet's readiness for a modeNo
emergency-pause.ymlPauses or resumes kernel enforcement on every computer of a groupYes, a pause file
Puppet, Chef and SaltRun ensure and the readiness check when the config file changesYes

Harden Tetragon

harden-tetragon.yml writes the files from Harden Tetragon. It restarts Tetragon only when a file changed, and on rings that will enforce it also checks that BPF LSM is on. A second run changes nothing.

Run it in a maintenance window, a few hosts at a time: a Tetragon restart drops policies added with tetra.

ansible-playbook -i inventory harden-tetragon.yml
ansible-playbook -i inventory harden-tetragon.yml -e tetragon_for_enforce=true
harden-tetragon.yml
# Harden the Tetragon you already run so the DefenseClaw sensor helper can
# read it. This play is yours: DefenseClaw never writes under /etc/tetragon.
#
# Restarting Tetragon drops every policy added over its API with `tetra`
# (DefenseClaw's and yours). Policies in /etc/tetragon/tetragon.tp.d reload.
# Run it in a maintenance window, a few hosts at a time (tetragon_serial).
#
#   ansible-playbook -i inventory harden-tetragon.yml
#   ansible-playbook -i inventory harden-tetragon.yml -e tetragon_for_enforce=true
- name: Harden Tetragon for DefenseClaw
  hosts: tetragon_hosts
  become: true
  serial: "{{ tetragon_serial | default(5) }}"
  vars:
    tetragon_conf_dir: /etc/tetragon/tetragon.conf.d
    # Set to true on the rings that will enforce.
    tetragon_for_enforce: false
    # Required in every mode: the API is a root-owned unix socket, never TCP.
    tetragon_required:
      server-address: "unix:///var/run/tetragon/tetragon.sock"
    # Required to enforce: stopping Tetragon must not leave programs enforcing
    # with nobody updating them.
    tetragon_required_for_enforce:
      keep-sensors-on-exit: "false"
    # Recommended: listeners on loopback only.
    tetragon_recommended:
      metrics-server: "127.0.0.1:2112"
      health-server-address: "127.0.0.1:6789"
    # Not needed: enable-ancestors. DefenseClaw requests no ancestors and
    # they cost CPU on every event.
  tasks:
    - name: Create the Tetragon settings folder
      ansible.builtin.file:
        path: "{{ tetragon_conf_dir }}"
        state: directory
        owner: root
        group: root
        mode: "0755"

    - name: Write the required settings
      ansible.builtin.copy:
        content: "{{ item.value }}\n"
        dest: "{{ tetragon_conf_dir }}/{{ item.key }}"
        owner: root
        group: root
        mode: "0644"
      loop: "{{ tetragon_required | dict2items }}"
      notify: Restart Tetragon

    - name: Write the settings that enforcement needs
      ansible.builtin.copy:
        content: "{{ item.value }}\n"
        dest: "{{ tetragon_conf_dir }}/{{ item.key }}"
        owner: root
        group: root
        mode: "0644"
      loop: "{{ tetragon_required_for_enforce | dict2items }}"
      when: tetragon_for_enforce | bool
      notify: Restart Tetragon

    - name: Write the recommended settings
      ansible.builtin.copy:
        content: "{{ item.value }}\n"
        dest: "{{ tetragon_conf_dir }}/{{ item.key }}"
        owner: root
        group: root
        mode: "0644"
      loop: "{{ tetragon_recommended | dict2items }}"
      notify: Restart Tetragon

    - name: Restart Tetragon now, so the checks below see the new settings
      ansible.builtin.meta: flush_handlers

    - name: Read the kernel's list of security modules
      ansible.builtin.command: cat /sys/kernel/security/lsm
      register: tetragon_lsm
      changed_when: false
      when: tetragon_for_enforce | bool

    - name: Require BPF LSM on hosts that will enforce
      ansible.builtin.assert:
        that: "'bpf' in tetragon_lsm.stdout"
        fail_msg: "bpf is not in the kernel's lsm= list. Add it to the boot parameters and reboot before you enforce."
        quiet: true
      when: tetragon_for_enforce | bool

  handlers:
    - name: Restart Tetragon
      ansible.builtin.systemd:
        name: tetragon
        state: restarted

Roll out by ring

defenseclaw-tetragon.yml installs the package, renders the candidate config from config.yaml.j2 for the ring, runs ensure and verify, and then gates the ring on tetragon verify.

  • One ring at a time. It stops at the first computer that fails (serial and any_errors_fatal).
  • The gate waits. It retries for up to two minutes, because the helper applies a new mode at its first pass after ensure restarts it. Until then verify can fail defenseclaw.policies and defenseclaw.agents.
  • Ring variables go in group_vars, one file per ring group, as the play's header shows. Set defenseclaw_version and the package SHA-256 values from the release's checksums.txt first.
ansible-playbook -i inventory defenseclaw-tetragon.yml -e defenseclaw_ring=defenseclaw_ring_pilot
defenseclaw-tetragon.yml
# Install DefenseClaw standalone enterprise and set its Tetragon mode, ring by
# ring. Ring variables live in group_vars, one file per ring group:
#
#   group_vars/defenseclaw_ring_pilot.yml
#     defenseclaw_tetragon_mode: observe
#     defenseclaw_tetragon_burn_in: 40h
#   group_vars/defenseclaw_ring_broad.yml
#     defenseclaw_tetragon_mode: enforce
#     defenseclaw_tetragon_enforce_ack: sha256:<digest>   # from `tetragon verify --ready-for enforce`
#     defenseclaw_guardrail_mode: action   # the kernel controls deny only for connectors in action mode
#
# Run one ring at a time, and stop at the first host that fails its checks:
#
#   ansible-playbook -i inventory defenseclaw-tetragon.yml -e defenseclaw_ring=defenseclaw_ring_pilot
- name: DefenseClaw standalone enterprise with Tetragon
  hosts: "{{ defenseclaw_ring | default('defenseclaw_linux') }}"
  become: true
  serial: "{{ defenseclaw_serial | default(5) }}"
  any_errors_fatal: true
  vars:
    # The release you deploy. It must include the Tetragon integration: it
    # reads config_version 9 and enterprise.tetragon, which 1.0.0 refuses.
    defenseclaw_version: "<version>"
    # SHA-256 values from the release's cosign-verified checksums.txt
    defenseclaw_pins:
      defenseclaw-enterprise-<version>-linux-amd64.deb: "<sha256>"
      defenseclaw-enterprise-<version>-linux-amd64.rpm: "<sha256>"
      defenseclaw-enterprise-<version>-linux-arm64.deb: "<sha256>"
      defenseclaw-enterprise-<version>-linux-arm64.rpm: "<sha256>"
    defenseclaw_arch: "{{ {'x86_64': 'amd64', 'aarch64': 'arm64'}[ansible_facts['architecture']] }}"
    defenseclaw_format: "{{ 'deb' if ansible_facts['pkg_mgr'] == 'apt' else 'rpm' }}"
    defenseclaw_package: "defenseclaw-enterprise-{{ defenseclaw_version }}-linux-{{ defenseclaw_arch }}.{{ defenseclaw_format }}"
    defenseclaw_gateway: /opt/defenseclaw/bin/defenseclaw-gateway
    # The ring variables are not set here: play vars outrank group_vars, so a
    # ring's mode would never take effect. They default where they are read.
  tasks:
    - name: Create the root-only staging folder
      ansible.builtin.file:
        path: /etc/mdm/defenseclaw
        state: directory
        owner: root
        group: root
        mode: "0700"

    - name: Render the candidate config for this ring
      ansible.builtin.template:
        src: config.yaml.j2
        dest: /etc/mdm/defenseclaw/config.yaml
        owner: root
        group: root
        mode: "0600"

    - name: Create the config folder
      ansible.builtin.file:
        path: /etc/defenseclaw
        state: directory
        owner: root
        group: root
        mode: "0755"

    - name: Put the config in place before the first install
      ansible.builtin.template:
        src: config.yaml.j2
        dest: /etc/defenseclaw/config.yaml
        owner: root
        mode: "0640"
        force: false

    - name: Download the package and check its SHA-256
      ansible.builtin.get_url:
        url: "https://github.com/cisco-ai-defense/defenseclaw/releases/download/{{ defenseclaw_version }}/{{ defenseclaw_package }}"
        dest: "/var/cache/{{ defenseclaw_package }}"
        checksum: "sha256:{{ defenseclaw_pins[defenseclaw_package] }}"
        owner: root
        group: root
        mode: "0644"

    - name: Install or upgrade the package (Debian, Ubuntu)
      ansible.builtin.apt:
        deb: "/var/cache/{{ defenseclaw_package }}"
      when: ansible_facts['pkg_mgr'] == 'apt'

    - name: Install or upgrade the package (RHEL family)
      ansible.builtin.dnf:
        name: "/var/cache/{{ defenseclaw_package }}"
        state: present
        # The rpm has no embedded signature; the SHA-256 check above proves it.
        disable_gpg_check: true
      when: ansible_facts['pkg_mgr'] in ['dnf', 'dnf5']

    - name: Apply the config and converge
      ansible.builtin.command:
        argv:
          - "{{ defenseclaw_gateway }}"
          - enterprise
          - linux
          - ensure
          - --from-package
          - --config
          - /etc/mdm/defenseclaw/config.yaml
          - --json
      register: defenseclaw_ensure
      until: defenseclaw_ensure.rc != 75
      retries: 5
      delay: 30
      changed_when: defenseclaw_ensure.rc == 0 and not (defenseclaw_ensure.stdout | from_json).noop
      failed_when: defenseclaw_ensure.rc != 0

    - name: Verify the deployment
      ansible.builtin.command:
        argv: ["{{ defenseclaw_gateway }}", enterprise, linux, verify, --json]
      changed_when: false

    - name: Gate the ring on Tetragon readiness for its mode
      ansible.builtin.command:
        argv:
          - "{{ defenseclaw_gateway }}"
          - enterprise
          - linux
          - tetragon
          - verify
          - --ready-for
          - "{{ defenseclaw_tetragon_mode | default('consume') }}"
      register: defenseclaw_tetragon_ready
      # ensure restarts the sensor helper into a new mode, and the helper
      # loads that mode's policies at its first pass, within a minute: the
      # gate waits for it rather than failing on the first look.
      until: defenseclaw_tetragon_ready.rc == 0
      retries: 6
      delay: 20
      changed_when: false
      failed_when: defenseclaw_tetragon_ready.rc != 0
      when: (defenseclaw_tetragon_mode | default('consume')) != 'off'

Candidate admin config

config.yaml.j2 is the config the play renders for each ring. Merge its ai_discovery and enterprise.tetragon parts into the config you already push. defenseclaw_guardrail_mode defaults to observe; set it to action on rings that enforce.

config.yaml.j2
# Candidate DefenseClaw admin config, rendered per ring by defenseclaw-tetragon.yml.
# Merge the ai_discovery and enterprise.tetragon parts into the config you already push.
config_version: 9
deployment_mode: managed_enterprise
data_dir: /var/lib/defenseclaw
policy_dir: /etc/defenseclaw/policies
gateway:
  api_bind: 127.0.0.1
  api_port: 18970
guardrail:
  enabled: true
  mode: "{{ defenseclaw_guardrail_mode | default('observe') }}"         # observe | action; a kernel control denies only for a connector in action mode
  connectors:
    claudecode: {}
    codex: {}
ai_discovery:
  runtime:
    enabled: true
    enable_host_plane: true      # Plane C; without it the Tetragon mode is off
enterprise:
  profile: standalone
  tetragon:
    mode: "{{ defenseclaw_tetragon_mode | default('consume') }}"                # consume | observe | enforce | off
    customer_events: "{{ defenseclaw_tetragon_customer_events | default('agent') }}"       # your policies' events from AI agents: agent | off
{% if defenseclaw_tetragon_burn_in | default('') | string != '' %}
    burn_in: {{ defenseclaw_tetragon_burn_in }}                # covered agent-hours per user; 0, or 24h to 2160h
{% endif %}
{% if defenseclaw_tetragon_enforce_ack | default('') | length > 0 %}
    enforce_ack: {{ defenseclaw_tetragon_enforce_ack | tojson }}   # one digest, or a list of up to 4 during a ring upgrade
{% endif %}

Fleet readiness

Both files change nothing. They run tetragon verify --ready-for <mode> --json on every computer and print one summary: computers ready and not ready (with the failing checks), users by phase toward enforce, and whether computers run different builds (more than one digest).

Phase countedMeaning
EnforcingAn agent session of the user is anchored and denied
ArmedEnforce is loaded, no agent session anchored yet
Ready for enforceBurn-in done
In burn-inStill measuring
Reset by a hitA would-block hit restarted the window
Monitor-onlyThe connector is in observe mode
No agent installedNo command-line agent for that user
Held in monitorA deny-anchor limit, a pause or an operator change

With Ansible. Pass the mode you want to move to:

ansible-playbook -i inventory fleet-readiness.yml -e defenseclaw_tetragon_mode=enforce
fleet-readiness.yml
# One-screen readiness of the whole fleet for a Tetragon mode.
#
#   ansible-playbook -i inventory fleet-readiness.yml -e defenseclaw_tetragon_mode=enforce
#
# It changes nothing. Each host runs `tetragon verify --json` (exit 0 ready,
# 1 not ready); one summary follows. The user counts are each user's phase
# toward enforce (verify's phase field, for observe and enforce). The
# plain-shell twin is fleet-readiness.sh.
- name: Fleet readiness for the DefenseClaw Tetragon integration
  hosts: defenseclaw_linux
  become: true
  gather_facts: false
  vars:
    defenseclaw_gateway: /opt/defenseclaw/bin/defenseclaw-gateway
    defenseclaw_tetragon_mode: observe
  tasks:
    - name: Check readiness for the mode
      ansible.builtin.command:
        argv:
          - "{{ defenseclaw_gateway }}"
          - enterprise
          - linux
          - tetragon
          - verify
          - --ready-for
          - "{{ defenseclaw_tetragon_mode }}"
          - --json
      register: fleet_verify
      changed_when: false
      failed_when: fleet_verify.rc not in [0, 1]

    - name: Keep what the summary needs
      ansible.builtin.set_fact:
        fleet_ready: "{{ fleet_verify.rc == 0 }}"
        fleet_failing: "{{ ((fleet_verify.stdout | from_json).checks | default([]) | selectattr('status', 'equalto', 'fail') | map(attribute='id') | list) }}"
        fleet_digest: "{{ (fleet_verify.stdout | from_json).kernel_policy | default('') }}"
        fleet_users: "{{ (fleet_verify.stdout | from_json).users | default([]) }}"

    - name: Summarize the fleet
      ansible.builtin.debug:
        msg:
          - "Mode checked: {{ defenseclaw_tetragon_mode }}"
          - "Hosts ready: {{ fleet_ready_hosts | length }} of {{ fleet_vars | length }}"
          - "Hosts not ready: {{ fleet_not_ready_hosts | join(', ') | default('none', true) }}"
          - "Users enforcing: {{ fleet_users_all | selectattr('phase', 'equalto', 'enforcing') | list | length }}"
          - "Users armed (enforce loaded, no agent session anchored yet): {{ fleet_users_all | selectattr('phase', 'equalto', 'armed') | list | length }}"
          - "Users ready for enforce: {{ fleet_users_all | selectattr('phase', 'equalto', 'ready') | list | length }}"
          - "Users in burn-in: {{ fleet_users_all | selectattr('phase', 'equalto', 'burn_in') | list | length }}"
          - "Users reset by a hit: {{ fleet_users_all | selectattr('phase', 'equalto', 'reset') | list | length }}"
          - "Users monitor-only (connector in observe mode): {{ fleet_users_all | selectattr('phase', 'equalto', 'monitor_only') | list | length }}"
          - "Users with no agent installed: {{ fleet_users_all | selectattr('phase', 'equalto', 'no_agent') | list | length }}"
          - "Users held in monitor (a deny-anchor limit, a pause or an operator change): {{ fleet_users_all | selectattr('phase', 'equalto', 'held') | list | length }}"
          - "Kernel controls digests: {{ fleet_vars | map(attribute='fleet_digest') | unique | list }} (more than one means hosts run different builds)"
      run_once: true
      vars:
        fleet_vars: "{{ ansible_play_hosts | map('extract', hostvars) | list }}"
        fleet_ready_hosts: "{{ fleet_vars | selectattr('fleet_ready') | map(attribute='inventory_hostname') | list }}"
        fleet_not_ready_hosts: "{{ fleet_vars | rejectattr('fleet_ready') | map(attribute='inventory_hostname') | list }}"
        fleet_users_all: "{{ fleet_vars | map(attribute='fleet_users') | flatten }}"

    - name: Name each host that is not ready
      ansible.builtin.debug:
        msg: "{{ inventory_hostname }} is not ready for {{ defenseclaw_tetragon_mode }}: {{ fleet_failing | join(', ') | default('see tetragon verify', true) }}"
      when: not fleet_ready

Without Ansible. fleet-readiness.sh does the same with an ssh loop and jq. It needs key-based ssh to an account that can run sudo without a prompt. Satellite remote execution can run the same command on each host instead.

./fleet-readiness.sh enforce hosts.txt
ExitMeaning
0Every computer is ready
1A computer is not ready
2Bad arguments, or a computer could not be checked
fleet-readiness.sh
#!/bin/sh
# Fleet readiness for the DefenseClaw Tetragon integration, without Ansible.
# It changes nothing on the hosts. Satellite remote execution can run the same
# commands on each host; this script is the ssh version.
#
# Usage: fleet-readiness.sh MODE HOSTFILE
#   MODE      consume, observe or enforce: the mode you want to move to
#   HOSTFILE  one ssh target per line; blank lines and lines starting with # are skipped
#
# Needs key-based ssh to an account that can run sudo without a prompt, and jq here.
# Exit 0 when every host is ready, 1 when a host is not ready, 2 for bad arguments
# or a host that could not be checked.
set -u

GW=/opt/defenseclaw/bin/defenseclaw-gateway
mode=${1:-}
hosts=${2:-}

case "$mode" in
consume | observe | enforce) ;;
*)
	echo "usage: $0 consume|observe|enforce HOSTFILE" >&2
	exit 2
	;;
esac
if [ ! -r "$hosts" ]; then
	echo "$0: cannot read the host file: $hosts" >&2
	exit 2
fi
if ! command -v jq >/dev/null 2>&1; then
	echo "$0: jq is required on this machine" >&2
	exit 2
fi

work=$(mktemp -d) || exit 2
trap 'rm -rf "$work"' EXIT HUP INT TERM

n=0
while IFS= read -r host; do
	case "$host" in
	'' | '#'*) continue ;;
	esac
	n=$((n + 1))
	# -n keeps ssh from reading the host list on standard input.
	ssh -n -o BatchMode=yes -o ConnectTimeout=10 "$host" \
		"sudo $GW enterprise linux tetragon verify --ready-for $mode --json" >"$work/$n.verify" 2>/dev/null
	vrc=$?
	jq -c . "$work/$n.verify" >"$work/$n.verify.json" 2>/dev/null || echo null >"$work/$n.verify.json"
	# The users are each user's phase toward enforce (verify reports them
	# for observe and enforce).
	jq -n -c --arg host "$host" --argjson rc "$vrc" --slurpfile verify "$work/$n.verify.json" '
		{
		  host: $host,
		  rc: $rc,
		  failing: [($verify[0].checks // [])[] | select(.status == "fail") | .id],
		  digest: ($verify[0].kernel_policy // ""),
		  users: [($verify[0].users // [])[] | {phase: (.phase // "held")}]
		}' >>"$work/rows.jsonl"
done <"$hosts"

if [ "$n" -eq 0 ]; then
	echo "$0: no hosts in $hosts" >&2
	exit 2
fi

jq -s -r --arg mode "$mode" '
	def unchecked: (.rc != 0 and .rc != 1);
	def ready: (.rc == 0);
	(map(select(unchecked)) | map(.host)) as $unchecked
	| (map(select(unchecked | not) | select(ready | not))) as $notready
	| (map(.users[]?)) as $users
	| (map(select(unchecked | not) | .digest) | unique) as $digests
	| (
	    (.[] | if unchecked then "\(.host): could not be checked (exit \(.rc))"
	           elif ready then "\(.host): ready for \($mode)"
	           else "\(.host): not ready for \($mode): \(if (.failing | length) > 0 then (.failing | join(", ")) else "see tetragon verify" end)" end),
	    "",
	    "Mode checked: \($mode)",
	    "Hosts ready: \(map(select(ready)) | length) of \(length)",
	    "Hosts not ready: \(if ($notready | length) > 0 then ($notready | map(.host) | join(", ")) else "none" end)",
	    "Hosts not checked: \(if ($unchecked | length) > 0 then ($unchecked | join(", ")) else "none" end)",
	    "Users enforcing: \($users | map(select(.phase == "enforcing")) | length)",
	    "Users armed (enforce loaded, no agent session anchored yet): \($users | map(select(.phase == "armed")) | length)",
	    "Users ready for enforce: \($users | map(select(.phase == "ready")) | length)",
	    "Users in burn-in: \($users | map(select(.phase == "burn_in")) | length)",
	    "Users reset by a hit: \($users | map(select(.phase == "reset")) | length)",
	    "Users monitor-only (connector in observe mode): \($users | map(select(.phase == "monitor_only")) | length)",
	    "Users with no agent installed: \($users | map(select(.phase == "no_agent")) | length)",
	    "Users held in monitor (a deny-anchor limit, a pause or an operator change): \($users | map(select(.phase == "held")) | length)",
	    "Kernel controls digests: \(if ($digests | length) > 0 then ($digests | join(", ")) else "none" end)\(if ($digests | length) > 1 then " (more than one means hosts run different builds)" else "" end)"
	  )
' "$work/rows.jsonl"

if jq -s -e 'any(.[]; .rc != 0 and .rc != 1)' "$work/rows.jsonl" >/dev/null; then
	exit 2
fi
if jq -s -e 'any(.[]; .rc == 1)' "$work/rows.jsonl" >/dev/null; then
	exit 1
fi
exit 0

fleet-readiness.sh enforce hosts.txt: one line per computer, then the summary with computers ready and not ready, users enforcing, ready for enforce, in burn-in, reset by a hit, monitor-only, with no agent installed, held in monitor, and the controls digests

Emergency pause

emergency-pause.yml pauses kernel enforcement on every computer of the group, or resumes it. A pause needs a reason. It is host-wide, keeps visibility, and ends by itself (default 4h). See Pause, roll back and the kill switch.

ansible-playbook -i inventory emergency-pause.yml -e reason=TICKET-123
ansible-playbook -i inventory emergency-pause.yml -e reason=TICKET-123 -e pause_for=8h
ansible-playbook -i inventory emergency-pause.yml -e pause_action=resume

Without the file, an ad-hoc command does the same:

ansible defenseclaw_linux -b -m ansible.builtin.command -a '/opt/defenseclaw/bin/defenseclaw-gateway enterprise linux tetragon pause --for 4h --reason TICKET-123'
emergency-pause.yml
# Pause (or resume) DefenseClaw kernel enforcement on every host in the group.
# A pause is host-wide: every user on the host moves to monitor mode within
# about five seconds, and visibility continues. It ends by itself.
#
#   ansible-playbook -i inventory emergency-pause.yml -e reason=TICKET-123
#   ansible-playbook -i inventory emergency-pause.yml -e reason=TICKET-123 -e pause_for=8h
#   ansible-playbook -i inventory emergency-pause.yml -e pause_action=resume
- name: Pause or resume DefenseClaw kernel enforcement
  hosts: defenseclaw_linux
  become: true
  gather_facts: false
  vars:
    defenseclaw_gateway: /opt/defenseclaw/bin/defenseclaw-gateway
    pause_action: pause
    pause_for: 4h
  tasks:
    - name: Require a reason for a pause
      ansible.builtin.assert:
        that:
          - reason is defined
          - reason | length > 0
        fail_msg: "Pass the ticket or reason with -e reason=TICKET-123"
        quiet: true
      when: pause_action == 'pause'

    - name: Pause kernel enforcement
      ansible.builtin.command:
        argv:
          - "{{ defenseclaw_gateway }}"
          - enterprise
          - linux
          - tetragon
          - pause
          - --for
          - "{{ pause_for }}"
          - --reason
          - "{{ reason }}"
      changed_when: true
      when: pause_action == 'pause'

    - name: Resume kernel enforcement
      ansible.builtin.command:
        argv: ["{{ defenseclaw_gateway }}", enterprise, linux, tetragon, resume]
      changed_when: true
      when: pause_action == 'resume'

Puppet, Chef and Salt

These templates run ensure and then tetragon verify when the staged config file changes. Stage the file the way the recipes do. The readiness check retries for up to two minutes, like the play's gate. Change --ready-for observe to the ring's mode.

$gateway = '/opt/defenseclaw/bin/defenseclaw-gateway'
exec { 'defenseclaw ensure':
  command     => "${gateway} enterprise linux ensure --from-package --config /etc/mdm/defenseclaw/config.yaml --json",
  refreshonly => true,
  subscribe   => File['/etc/mdm/defenseclaw/config.yaml'],
}
exec { 'defenseclaw tetragon verify':
  command     => "${gateway} enterprise linux tetragon verify --ready-for observe",
  refreshonly => true,
  tries       => 6,
  try_sleep   => 20,
  subscribe   => Exec['defenseclaw ensure'],
}
execute 'defenseclaw ensure' do
  command '/opt/defenseclaw/bin/defenseclaw-gateway enterprise linux ensure --from-package --config /etc/mdm/defenseclaw/config.yaml --json'
  action :nothing
  subscribes :run, 'template[/etc/mdm/defenseclaw/config.yaml]', :immediately
end

execute 'defenseclaw tetragon verify' do
  command '/opt/defenseclaw/bin/defenseclaw-gateway enterprise linux tetragon verify --ready-for observe'
  retries 6
  retry_delay 20
  action :nothing
  subscribes :run, 'execute[defenseclaw ensure]', :immediately
end
defenseclaw-ensure:
  cmd.run:
    - name: /opt/defenseclaw/bin/defenseclaw-gateway enterprise linux ensure --from-package --config /etc/mdm/defenseclaw/config.yaml --json
    - onchanges:
      - file: /etc/mdm/defenseclaw/config.yaml

defenseclaw-tetragon-ready:
  cmd.run:
    - name: /opt/defenseclaw/bin/defenseclaw-gateway enterprise linux tetragon verify --ready-for observe
    - retry:
        attempts: 6
        interval: 20
    - onchanges:
      - cmd: defenseclaw-ensure