/devsecops-skills:complete-devsecops-pipeline-for-vm-based-workloads-from-scratchfrom devsecops-skills
Builds a complete DevSecOps pipeline for VM-based workloads with SAST, SCA, golden-image scanning, CIS hardening, Ansible Vault secrets, and ongoing patch/drift detection independent of deploy cycles.
Ships in devsecops-skills. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
A VM-based DevSecOps pipeline has a gate sequence with a genuinely different time dimension from the Kubernetes and serverless variants of this skill. Those two are almost entirely per-deploy gates: a scan runs, a decision is made, an artifact ships. A VM fleet built on long-lived, immutable golden images additionally needs an ongoing gate that has no equivalent in a pipeline that redeploys constantly — a golden AMI baked and CIS-hardened once can still drift out of compliance or accumulate newly-disclosed CVEs for months while sitting unchanged in an Auto Scaling Group, so patch/drift detection has to run as its own recurring check, independent of whether a new deploy happens at all. Secrets follow yet another distinct model here too: applied by a config-management tool (Ansible Vault) at provision/config-push time, encrypted at rest in the same repo as the playbooks, rather than a cluster-side operator (Kubernetes) or a runtime API call to a managed secrets service (serverless).
kube-bench's non-Kubernetes sibling tooling,
OpenSCAP, or a cloud-native CIS scanner — per
cis-benchmarks-hardening.ansible-vault for secrets encryption, per
ansible-playbook-and-role-design.Per sast-integration: unchanged from any other pipeline.
Per software-composition-analysis-sca: scan the lockfile before baking anything, exactly as in the base VM CI/CD pipeline.
This is the VM-specific gate: after Packer bakes the AMI (per complete-cicd-pipeline-for-vm-based-workloads-from-scratch), scan the resulting machine image — its OS packages, its configuration posture against CIS benchmarks — not just the application artifact that was installed onto it:
build {
sources = ["source.amazon-ebs.payments_api"]
provisioner "shell" { script = "scripts/install-app.sh" }
provisioner "shell" {
# CIS-aligned OS hardening applied at bake time, not left to the
# instance's first boot or a later manual pass
script = "scripts/cis-harden.sh"
}
provisioner "shell" {
inline = ["sudo cis-cat-lite --benchmark rhel9 --profile level1-server --report /tmp/cis-report.html"]
}
post-processor "manifest" {}
}
Fail the pipeline (or require an explicit, expiring waiver) on any Level-1 CIS finding, per cis-benchmarks-hardening's guidance on interpreting PASS/FAIL/WARN against the actual benchmark text rather than treating a scan pass as a compliance certification. This is the machine-image analog of container-image-hardening's non-root/read-only/minimal-base discipline, applied to a whole bootable OS instead of a container layer.
Where Kubernetes fetches secrets cluster-side and serverless fetches them via a runtime API call, the VM-based model applies secrets at config-push/provision time through Ansible, with the secret values encrypted at rest in the same repo as the playbooks — never a plaintext variable file:
ansible-vault encrypt group_vars/prod/vault.yml
# group_vars/prod/vault.yml (encrypted at rest via ansible-vault)
vault_db_password: "S3cr3tValueNeverPlaintextInGit"
# deploy.yml task referencing the vaulted variable
- name: Render application config with DB credentials
ansible.builtin.template:
src: templates/app-config.yml.j2
dest: /etc/payments-api/config.yml
mode: "0600"
no_log: true
The playbook run itself decrypts vault.yml using a vault password
supplied out-of-band (a CI secret referencing the vault password, or
better, --vault-id backed by a secrets manager lookup) — the encrypted
file is safe to commit, but the vault password itself follows the same
never-hardcoded discipline as any other credential, per
secrets-management and
ansible-playbook-and-role-design.
no_log: true on any task handling the decrypted value prevents it from
being printed in Ansible's own execution output.
Blue-green instance refresh or Ansible config push, per complete-cicd-pipeline-for-vm-based-workloads-from-scratch.
This is the gate with no equivalent in the Kubernetes or serverless
variants: a golden image or a fleet of long-lived VMs can silently
accumulate risk (new CVEs disclosed against already-installed package
versions, manual ssh-and-fix drift from the golden config, a security
group edited out-of-band) with zero code changes and zero new deploys.
Schedule this as its own recurring job, not tied to the deploy pipeline
trigger:
name: fleet-patch-and-drift-scan
on:
schedule:
- cron: '0 4 * * *'
jobs:
patch-scan:
runs-on: ubuntu-latest
steps:
- run: |
aws ssm start-automation-execution \
--document-name AWS-RunPatchBaseline \
--parameters "Operation=Scan"
- run: trivy image --severity CRITICAL,HIGH "${LATEST_GOLDEN_AMI_REPO_REF}"
drift-scan:
runs-on: ubuntu-latest
steps:
- run: ansible-playbook -i inventories/prod check-drift.yml --check --diff
check-drift.yml --check --diff runs every task in dry-run mode against
the live fleet and reports any host whose actual state no longer matches
the playbook's declared state — catching a manually-ssh'd config change
on a running instance the same way
gitops-workflow's
selfHeal catches drift in Kubernetes, but as an explicit scheduled
report rather than a continuously-reconciling controller, since Ansible
push has no equivalent of an in-cluster operator watching state
continuously.
aws ssm describe-instance-patch-states-for-patch-group --patch-group payments-api-prod
ansible-playbook -i inventories/prod check-drift.yml --check --diff | grep -c changed
A nonzero changed count from the drift check means at least one host has
diverged from the declared playbook state and needs investigation before
it's treated as routine.
ansible-vault encrypt before the first commit, not after a secret
is discovered in git history; treat a plaintext secret found in a vars
file with the same rotate-first response as any other leaked credential,
per secrets-management.Symptom: A golden AMI passed its CIS scan at bake time six months ago, and a compliance audit today finds several Level-1 findings on instances still running that same AMI. Fix: This is expected without a recurring gate — a CIS scan result is only valid as of the moment it ran; without Phase 6's scheduled patch/drift scan (or a periodic rebake-and-rescan cadence), an unchanged golden image accumulates newly-disclosed findings silently. Add the scheduled scan, and treat "last CIS scan date" as a tracked fleet metric, not a one-time checkbox.
Symptom: An Ansible group_vars/prod/vault.yml was committed
unencrypted "just for local testing," and by the time someone notices
and runs ansible-vault encrypt, the plaintext secret is already in git
history.
Fix: Treat it as a leaked credential exactly like any other secret
— rotate the underlying value at its source system first, then encrypt
and re-commit, and only then consider the finding closed; encrypting the
current version does not retroactively protect the plaintext already in
history, per
secrets-management.
Symptom: The drift-detection playbook (--check --diff) reports a
handful of hosts as "changed" every single run, even right after a clean
deploy, and the team starts ignoring the report entirely.
Fix: This is usually a genuinely non-idempotent task (a command:/
shell: task with no changed_when guard that Ansible can't evaluate
as idempotent) rather than real drift — audit the flagged tasks for
idempotency per
ansible-playbook-and-role-design
before concluding the hosts have actually drifted, since a
false-positive "changed" every run trains the team to stop reading the
report, the same trust-erosion failure mode as a chronically-noisy SAST
gate.
Symptom: A security group attached to the fleet was edited directly in the console "to open a port for debugging" and never reverted, and it's now a standing exposure nobody remembers creating. Fix: Manual cloud-console changes to fleet-supporting infrastructure (security groups, launch templates) are a different drift surface from the instance-level Ansible drift check — pair Phase 6's host-level drift scan with infrastructure-level drift detection per cloud-resource-post-provisioning-validation-and-drift-detection, since neither one alone covers both layers.
Scenario: payments-api's VM fleet gets its full DevSecOps gate
sequence: SAST/SCA at PR time, CIS-hardening baked into the golden AMI,
database credentials applied via Ansible Vault, and a nightly
patch/drift-detection job independent of the deploy pipeline.
# .github/workflows/ci-cd.yml (build/bake/deploy jobs per the base VM CI/CD skill)
jobs:
sast: { /* per sast-integration */ }
sca: { /* per software-composition-analysis-sca */ }
bake-and-scan-image:
needs: [sast, sca]
runs-on: ubuntu-latest
steps:
- run: packer build payments-api.pkr.hcl
- run: |
AMI_ID=$(jq -r '.builds[-1].artifact_id' manifest.json | cut -d: -f2)
# cis-cat-lite runs as a Packer provisioner during the bake (Phase 3);
# its report is a build artifact reviewed here
aws s3 cp cis-report.html "s3://payments-api-compliance-reports/${AMI_ID}.html"
apply-config-and-secrets:
needs: bake-and-scan-image
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: |
ansible-playbook -i inventories/prod deploy.yml \
--vault-password-file <(aws secretsmanager get-secret-value --secret-id ansible-vault-prod --query SecretString --output text)
# .github/workflows/fleet-patch-and-drift-scan.yml — independent schedule
name: fleet-patch-and-drift-scan
on:
schedule: [{ cron: '0 4 * * *' }]
jobs:
scan:
runs-on: ubuntu-latest
steps:
- run: aws ssm start-automation-execution --document-name AWS-RunPatchBaseline --parameters "Operation=Scan"
- uses: actions/checkout@v4
- run: ansible-playbook -i inventories/prod check-drift.yml --check --diff
The nightly job runs whether or not payments-api had a deploy that day —
catching newly-disclosed OS CVEs against the already-running golden image
and any manual configuration drift on the live fleet, entirely independent
of the per-deploy gate sequence above it.
What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
devsecops, vm-security, golden-ami, cis-benchmark, ansible-vault, drift-detection
npx claudepluginhub selvarajmurugesan90/ops-engineering-skills --plugin devsecops-skills17 skills in this plugin
/checkov-and-tfsec-iac-security-scanningConfigures Checkov and tfsec to scan Terraform/CloudFormation/Kubernetes IaC source for misconfigurations — hardcoded secrets, overly permissive IAM policies, unencrypted storage, open security groups — before `terraform apply` or `aws cloudformation deploy` ever runs. Use when a user asks to "scan my Terraform for security issues," "add Checkov/tfsec to CI," "find overly permissive IAM in my IaC," "write a Checkov suppression," "compare Checkov and tfsec," or "catch misconfigured cloud resources before they're provisioned."
/complete-devsecops-pipeline-for-kubernetes-from-scratchBuilds the complete security-gate sequence for a Kubernetes-targeted DevSecOps pipeline from scratch — SAST, SCA, container image scanning, a policy-as-code (OPA/Kyverno) admission gate placed before the GitOps handoff, and a secrets model where plaintext credentials never touch the pipeline because an External Secrets Operator pulls them cluster-side instead. Use when the user asks to "build a DevSecOps pipeline for Kubernetes from scratch," "add a policy gate before our GitOps commit," "make sure secrets never touch CI for our K8s deploys," or "sequence SAST/SCA/image-scan/policy gates for a container pipeline end-to-end."
/complete-devsecops-pipeline-for-serverless-from-scratchBuilds the complete security-gate sequence for a serverless (Lambda- style) DevSecOps pipeline from scratch — SAST, SCA against a much larger bundled transitive-dependency surface, package/artifact signing, and least-privilege execution-role scoping as the primary release gate (rather than a Kubernetes-style admission policy), with runtime secrets fetched from a managed secrets service instead of baked into the deployment package. Use when the user asks to "build a DevSecOps pipeline for a Lambda function from scratch," "gate a serverless release on execution-role scope instead of admission policy," "sign a Lambda deployment package," or "make sure a Lambda function's secrets aren't baked into its zip."
/container-image-hardeningGuides building minimal, non-root, hardened container images — multi-stage builds, distroless/minimal base images, non-root users, read-only root filesystems, dropped Linux capabilities, and pinned/ digest-referenced base images. Use when the user asks to "harden this Dockerfile", "reduce container image attack surface/size", "make our container run as non-root", "switch to a distroless base image", "fix a container security scan finding about running as root or having a shell", or "set Kubernetes securityContext restrictions for a pod".
/critical-vulnerability-emergency-responseGuides the accelerated, out-of-band response when a critical CVE is publicly disclosed in a widely-used dependency, library, or platform component — rapid exposure assessment across the fleet, patch or temporary mitigation, verification, and closeout. Use when the user says "a critical CVE just dropped in X", "we need to check if we're affected by CVE-YYYY-NNNNN", "log4shell-style emergency patching", "zero-day just disclosed in our dependency", or "run an emergency vulnerability response". Distinct from the steady-state finding-queue management in security-finding-backlog-triage — this is the fire-drill process for one urgent, time-critical disclosure.
/dast-integrationGuides adding Dynamic Application Security Testing (DAST) — automated black-box scanning of a running web application or API — using tools such as OWASP ZAP or Nuclei, in CI/CD or on a scheduled cadence against a staging environment. Use when the user asks to "add DAST scanning", "run a ZAP baseline scan against staging", "automate OWASP scanning in the pipeline", "test the running app for injection/auth/config vulnerabilities", or "scan our API for security issues before release". Complements, but does not replace, SAST or SCA static analysis.
Other plugins' skills for the same job