/cicd-tooling-skills:complete-cicd-pipeline-for-vm-based-workloads-from-scratchfrom cicd-tooling-skills
Builds a complete CI/CD pipeline for VM-based workloads from scratch: source checkout, build, Packer-style AMI baking, SCA/SAST security gates, and deploy via blue-green ASG swap or Ansible config push to existing VMs.
Ships in cicd-tooling-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.
VM-based deployment splits into two genuinely different mechanical models, and this skill covers both because a team's choice between them changes almost everything downstream of the build step: immutable image replacement (bake a golden AMI with Packer, swap an Auto Scaling Group/instance group to it, blue-green) versus mutable config push (long-lived VMs stay running, and a config-management tool like Ansible pushes the new application version/config onto them in place). Neither looks like the Kubernetes variant of this skill (no container image, no GitOps handoff) or the serverless variant (no zip/layer, no alias-based traffic shift) — the build artifact here is either a whole bootable machine image or nothing at all (just new config/binaries pushed onto existing hosts), and "deploy" means either swapping which image an instance group boots or running a playbook against a live fleet.
ec2:RunInstances, ec2:CreateImage, and
related — least-privilege, per
cloud-iam-hardening).Standard PR/push trigger setup per ci-cd-pipeline-design.
Compile/package the application binary or bundle exactly as any pipeline
would (npm run build, mvn package, go build, etc.) — this step alone
looks identical to any other pipeline. What differs is what happens to
that artifact next.
Run static analysis and dependency scanning against the source/build output before either downstream path — baking a full machine image (Phase 4) is comparatively expensive and slow, so failing fast here avoids wasting a 10-20 minute image-build cycle on code that wouldn't have passed anyway:
jobs:
sast:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with: { fetch-depth: 0 }
- run: semgrep ci --config p/owasp-top-ten --baseline-commit "${{ github.event.pull_request.base.sha }}"
sca:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: aquasecurity/[email protected]
with: { scan-type: 'fs', severity: 'CRITICAL,HIGH', exit-code: '1', ignore-unfixed: true }
// payments-api.pkr.hcl (HCL2, abbreviated)
source "amazon-ebs" "payments_api" {
ami_name = "payments-api-{{timestamp}}"
instance_type = "t3.medium"
region = "us-east-1"
source_ami_filter {
filters = { name = "al2023-ami-*-x86_64", virtualization-type = "hvm" }
owners = ["amazon"]
most_recent = true
}
ssh_username = "ec2-user"
}
build {
sources = ["source.amazon-ebs.payments_api"]
provisioner "file" {
source = "dist/payments-api.tar.gz"
destination = "/tmp/payments-api.tar.gz"
}
provisioner "shell" {
script = "scripts/install-and-harden.sh"
}
}
packer build -var "build_number=${GITHUB_SHA}" payments-api.pkr.hcl
scripts/install-and-harden.sh installs the built artifact, applies
CIS-aligned OS hardening, and removes build-time tooling — this is the
machine-image analog of a container's multi-stage build
(container-build-and-release)
except the "final stage" is an entire bootable OS image, not a set of
layered filesystem diffs.
If the team's chosen model is config-management push rather than
immutable replacement, Phase 4a is skipped entirely and the built artifact
(Phase 2's output) is instead packaged for
ansible-playbook-and-role-design
to push directly — e.g. uploaded to an artifact store the playbook's
fetch/unarchive tasks will pull from, with no machine image produced at
all.
aws autoscaling create-launch-template-version \
--launch-template-name payments-api-lt \
--source-version 1 \
--launch-template-data "{\"ImageId\":\"${NEW_AMI_ID}\"}"
aws autoscaling start-instance-refresh \
--auto-scaling-group-name payments-api-asg \
--preferences '{"MinHealthyPercentage": 90, "InstanceWarmup": 120}'
An instance refresh replaces instances gradually behind the existing load balancer, honoring health checks — this is the VM-fleet analog of blue-green-canary-deployments's Kubernetes Service-selector flip, but operating on EC2 instances inside one Auto Scaling Group rather than pods behind a Kubernetes Service. For a harder cutover with an explicit separate "green" ASG and load-balancer target-group swap (full blue-green, not a rolling instance refresh), the CodeDeploy EC2 blue/green mechanics in aws-codepipeline-and-codedeploy apply directly, with this pipeline's baked AMI (Phase 4a) as the launch template's image instead of an existing one.
Warning — destructive/irreversible step: an instance refresh or ASG swap terminates old instances as it progresses. Always set
MinHealthyPercentagehigh enough that capacity never drops dangerously, and confirm the new AMI passes health checks on a small batch before letting the refresh proceed to the full fleet — an instance refresh has no automatic rollback the way a GitOpsApplicationrevert does; rolling back means starting a new instance refresh pointed at the previous launch template version.
# deploy.yml
- hosts: payments_api_fleet
serial: "25%"
tasks:
- name: Fetch new build artifact
ansible.builtin.unarchive:
src: "https://artifacts.internal.example.com/payments-api/{{ build_sha }}.tar.gz"
dest: /opt/payments-api
remote_src: true
- name: Restart service
ansible.builtin.systemd:
name: payments-api
state: restarted
register: restart_result
- name: Health check
ansible.builtin.uri:
url: "http://localhost:8080/healthz"
status_code: 200
retries: 5
delay: 3
ansible-playbook -i inventories/prod deploy.yml --extra-vars "build_sha=${GITHUB_SHA}"
serial: "25%" rolls the change out to a quarter of the fleet at a time —
the config-push analog of a canary percentage, but implemented as batched
SSH-driven task execution across existing long-lived hosts rather than
either a Kubernetes traffic split or an ASG instance replacement. See
ansible-playbook-and-role-design
for idempotent task design and dry-run (--check) practice before this
runs against production.
Immutable path: aws autoscaling describe-instance-refreshes shows
Successful, and the target group's healthy-host count matches the ASG's
desired capacity. Mutable path: re-run the playbook's health-check task
against the full inventory, or a separate smoke-test job, to confirm every
batch converged, not just the last one Ansible reported on.
ansible-playbook --check --diff
against a subset of the inventory before the real run, and keep
serial: batching conservative enough that a bad playbook run doesn't
reach the whole fleet before someone notices.Symptom: An instance refresh is started against production with a
bad AMI, and by the time anyone notices, most of the fleet has already
been replaced and is failing health checks.
Fix: This is the destructive-step warning in Phase 5a in practice —
set MinHealthyPercentage conservatively and watch the refresh's
progress on the first batch before it proceeds; if it's already
underway and failing, aws autoscaling cancel-instance-refresh halts
further replacement, and a second instance refresh targeting the prior
launch template version is the rollback path (there is no automatic
revert).
Symptom: An Ansible deploy.yml run against serial: "100%" (the
whole fleet at once) fails partway through, leaving half the fleet on
the new version and half on the old, with no clear record of which
hosts got which.
Fix: Use a conservative serial: batch size (e.g. 25%) so a
failure is caught and can be halted (ansible-playbook stops the play
on a batch's failure by default) before it reaches the rest of the
fleet, and query ansible -i inventories/prod payments_api_fleet -m shell -a "cat /opt/payments-api/VERSION" afterward to get an explicit
per-host version inventory rather than assuming uniformity.
Symptom: The team assumes "we bake an AMI" means secrets can be safely embedded during the Packer build "since it's a private image," and a database password ends up recoverable from a launched instance's root filesystem or an old, still-registered AMI snapshot. Fix: Treat a baked AMI exactly like a container image for secrets purposes — nothing written during the build should be assumed private once the image is registered and shared/copied across accounts/regions; fetch secrets at boot via a secrets manager instead of Packer provisioning them in.
Symptom: SAST/SCA gates (Phase 3) are placed after the Packer bake (Phase 4a) "since the image build takes longer anyway," and a failing gate is only discovered after a 15-minute AMI build already completed. Fix: Order gates before the expensive image-bake step, not after — identical sequencing lesson to the Kubernetes and serverless variants of this skill, just more costly here because rebuilding a machine image is slower than rebuilding a container layer or a zip.
Scenario: payments-api runs on an EC2 Auto Scaling Group behind an
ALB. The team chooses the immutable-image path: PR-time SAST/SCA, a
Packer-baked AMI on merge to main, and a gradual instance refresh with a
conservative health threshold.
name: ci-cd
on:
pull_request: { branches: [main] }
push: { branches: [main] }
jobs:
sast:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with: { fetch-depth: 0 }
- run: semgrep ci --config p/owasp-top-ten --baseline-commit "${{ github.event.pull_request.base.sha }}"
sca:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: aquasecurity/[email protected]
with: { scan-type: 'fs', severity: 'CRITICAL,HIGH', exit-code: '1' }
build:
needs: [sast, sca]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: make build # produces dist/payments-api.tar.gz
bake-and-deploy:
needs: build
if: github.event_name == 'push'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: hashicorp/setup-packer@v3
- run: packer build -var "build_number=${{ github.sha }}" payments-api.pkr.hcl
- run: |
NEW_AMI_ID=$(cat manifest.json | jq -r '.builds[-1].artifact_id' | cut -d: -f2)
aws autoscaling create-launch-template-version \
--launch-template-name payments-api-lt --source-version 1 \
--launch-template-data "{\"ImageId\":\"$NEW_AMI_ID\"}"
aws autoscaling start-instance-refresh \
--auto-scaling-group-name payments-api-asg \
--preferences '{"MinHealthyPercentage": 90, "InstanceWarmup": 120}'
aws autoscaling describe-instance-refreshes --auto-scaling-group-name payments-api-asg is polled (or alerted on) until Status: Successful,
confirming every instance in the ASG is now running the new AMI — with
MinHealthyPercentage: 90 ensuring the ALB always has enough healthy
capacity behind it during the swap.
What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
npx claudepluginhub selvarajmurugesan90/ops-engineering-skills --plugin cicd-tooling-skills13 skills in this plugin
/aws-codepipeline-and-codedeployDesigns AWS CodePipeline stage/action structure and integrates it with CodeDeploy deployment groups and appspec.yml for EC2/on-prem, ECS, or Lambda deploys. Use when the user asks to "set up CodePipeline," "add a CodeDeploy deployment group," "write an appspec.yml," "wire CodePipeline to CodeDeploy," "troubleshoot a stuck/failed CodePipeline action," or "add a manual approval action before an AWS deploy."
/azure-pipelines-yaml-and-multi-stageDesigns Azure Pipelines YAML (azure-pipelines.yml), multi-stage pipelines with environments/approvals, templates for reuse across repos, and self-hosted vs. Microsoft-hosted agent pools. Use when the user asks to "set up Azure Pipelines," "write an azure-pipelines.yml," "add a multi-stage pipeline with approvals," "create a reusable pipeline template," "configure a self-hosted agent pool," or "troubleshoot a stuck/failed Azure DevOps pipeline run."
/bamboo-pipeline-yaml-and-java-specsAuthors Atlassian Bamboo pipeline definitions using either Bamboo Specs (Java DSL, compiled and run to create/update a plan) or Bamboo's YAML specs format, covering plan/job/stage structure and how a Specs definition links to and updates a live Bamboo plan. Use when the user asks to "write a Bamboo Specs plan," "convert our Bamboo plan to code," "add a stage/job to a Bamboo build," "use Bamboo YAML specs," or "troubleshoot a Bamboo Specs plan not updating the linked plan."
/complete-cicd-pipeline-deployment-for-kubernetes-from-scratchBuilds a complete CI/CD pipeline for a Kubernetes-targeted service from an empty repo — source checkout, container image build, SCA/SAST security gates, registry push, and a deploy step that ends at a GitOps handoff (committing a new image tag to a manifests repo) rather than a direct kubectl apply or helm upgrade against the cluster. Use when the user asks to "build a full CI/CD pipeline for Kubernetes from scratch," "set up CI/CD that ends in a GitOps commit, not a cluster deploy," "wire a container build pipeline into Argo CD/Flux," or "go from an empty repo to a Kubernetes service deployed via GitOps end-to-end."
/complete-cicd-pipeline-deployment-for-serverless-from-scratchBuilds a complete CI/CD pipeline for a serverless (AWS Lambda-style) function from an empty repo — source checkout, zip/layer packaging (not a container image), SCA/SAST security gates, package upload, and a SAM/Serverless-Framework/CDK-style deploy step with alias-based canary traffic shifting, distinct from Kubernetes rollout mechanics. Use when the user asks to "build a full CI/CD pipeline for a Lambda function from scratch," "set up serverless CI/CD with canary traffic shifting," "wire SAM/Serverless Framework deploys into a pipeline," or "go from an empty repo to a function deployed with an alias-based canary."
/gitea-actions-and-ciConfigures Gitea Actions — Gitea's GitHub Actions-compatible CI/CD runner — including self-hosted act_runner setup/registration and the specific differences from GitHub Actions (supported contexts, missing features, runner labels). Use when the user asks to "set up CI on Gitea," "configure Gitea Actions," "register an act_runner," "port a GitHub Actions workflow to Gitea," or "troubleshoot a Gitea Actions job that isn't picked up by any runner."
Other plugins' skills for the same job