39 Commits

Author SHA1 Message Date
samahk13 fa52a28a0c Merge pull request 'Feature/issue 24 delivery' (#27) from feature/issue-24-delivery into main
Scrap-Web/pipeline/head This commit looks good
Reviewed-on: #27
Reviewed-by: kholmes <kholmes2@stevens.edu>
2026-11-13 21:14:35 +00:00
samahk13 8979d92c00 Merge remote-tracking branch 'origin/main' into feature/issue-24-delivery
Scrap-Web/pipeline/pr-main Build started...
Scrap-Web/pipeline/head This commit looks good
# Conflicts:
#	Jenkinsfile
2026-11-13 16:14:14 -05:00
samahk13 17750b844b Merge pull request 'Docs/chapter 11' (#26) from docs/chapter-11 into main
Scrap-Web/pipeline/head There was a failure building this commit
Build IT manual / build-manual (push) Successful in 2m41s
Reviewed-on: #26
Reviewed-by: kholmes <kholmes2@stevens.edu>
2026-11-13 20:58:39 +00:00
samahk13 fb2bac752a Add Chapter 11 draft (Secure Delivery and Rollback)
Scrap-Web/pipeline/pr-main This commit looks good
Scrap-Web/pipeline/head This commit looks good
2026-11-13 15:55:41 -05:00
samahk13 99acac3136 Update trusted branch
Scrap-Web/pipeline/head This commit looks good
2026-11-13 15:50:50 -05:00
samahk13 3b79b7e07a Merge pull request 'Update manual to v1.6 and merge SRE chapter into one file' (#25) from fix/manual-v1.6 into main
Scrap-Web/pipeline/head This commit looks good
Build IT manual / build-manual (push) Successful in 2m13s
Reviewed-on: #25
Reviewed-by: kholmes <kholmes2@stevens.edu>
2026-11-13 19:58:27 +00:00
samahk13 5c0ed9fbcd Update manual to v1.6 and merge SRE chapter into one file
Scrap-Web/pipeline/pr-main This commit looks good
Scrap-Web/pipeline/head This commit looks good
2026-11-13 14:09:15 -05:00
samahk13 60019db7da Change TRUSTED_BRANCH line of Jenkinsfile
Scrap-Web/pipeline/head This commit looks good
Scrap-Web/pipeline/pr-main This commit looks good
2026-11-12 19:16:59 -05:00
samahk13 2a35f97071 Add Ansible staging deploy and idempotence check for #24
Scrap-Web/pipeline/head This commit looks good
2026-11-12 18:51:25 -05:00
samahk13 d8a5d2717b Revert "Controlled failing test: wrong expected total (demo for #24)"
Scrap-Web/pipeline/head This commit looks good
This reverts commit 5e17a009dc.
2026-11-12 18:20:28 -05:00
samahk13 5e17a009dc Controlled failing test: wrong expected total (demo for #24)
Scrap-Web/pipeline/head There was a failure building this commit
2026-11-12 18:18:53 -05:00
samahk13 7e76950690 Fix base image FROM line for #24
Scrap-Web/pipeline/head This commit looks good
2026-11-12 18:13:03 -05:00
samahk13 27f8f20275 Add build, scan hooks and registry publish stages for #24
Scrap-Web/pipeline/head There was a failure building this commit
2026-11-12 18:05:14 -05:00
samahk13 98f86092a2 Start delivery agent directly with secret file for #24
Scrap-Web/pipeline/head This commit looks good
2026-11-11 13:37:57 -05:00
samahk13 459838dfcd Add trusted delivery agent for #24
Scrap-Web/pipeline/head This commit looks good
2026-11-11 13:23:25 -05:00
samahk13 6553b4400c Add v1 pricing service, Ansible starter and locked deps for #24
Scrap-Web/pipeline/head This commit looks good
2026-11-11 13:01:00 -05:00
kholmes b4007504b7 Merge pull request 'Merged rules' (#23) from kholmes-patch-5 into main
Scrap-Web/pipeline/head This commit looks good
Reviewed-on: #23
2026-10-30 23:24:36 +00:00
kholmes a482ef9ef9 Merged rules
Scrap-Web/pipeline/pr-main Build queued...
Scrap-Web/pipeline/head This commit looks good
2026-10-30 23:24:14 +00:00
samahk13 1bfa31acc0 Merge pull request 'Feature/issue 18 monitoring' (#22) from feature/issue-18-monitoring into main
Scrap-Web/pipeline/head This commit looks good
Reviewed-on: #22
2026-10-29 22:31:33 +00:00
samahk13 2ab41bdce5 Update ServiceUnavailable alert export and runbook for #18
Scrap-Web/pipeline/pr-main This commit looks good
Scrap-Web/pipeline/head This commit looks good
2026-10-29 17:24:21 -04:00
samahk13 01f842323e Fix ServiceUnavailable threshold for #18
Scrap-Web/pipeline/head This commit looks good
2026-10-28 20:39:33 -04:00
samahk13 d6ea94f20d Add ServiceUnavailable alert export and runbook for #18
Scrap-Web/pipeline/head This commit looks good
2026-10-28 20:32:10 -04:00
samahk13 6d65f29674 Add SRE dashboard definition for #18
Scrap-Web/pipeline/head This commit looks good
2026-10-28 17:42:15 -04:00
samahk13 4c098708f4 Add monitoring stack config for #18
Scrap-Web/pipeline/head This commit looks good
2026-10-28 15:02:43 -04:00
kholmes 3301e2463e Merge pull request 'compose file addition' (#17) from kholmes-patch-3 into main
Scrap-Web/pipeline/head This commit looks good
Reviewed-on: #17
2026-10-24 08:01:55 +00:00
kholmes ae289072ed compose file addition
Scrap-Web/pipeline/pr-main Build queued...
Scrap-Web/pipeline/head This commit looks good
2026-10-24 08:01:30 +00:00
samahk13 696b328a7d Merge pull request 'Add CI with Jenkins chapter, screenshots, glossary, references, version 1.5 (#11)' (#16) from docs/ci-chapter into main
Scrap-Web/pipeline/head This commit looks good
Build IT manual / build-manual (push) Failing after 2m21s
Reviewed-on: #16
Reviewed-by: kholmes <kholmes2@stevens.edu>
2026-10-24 04:32:08 +00:00
samahk13 38d2e1e965 Add CI with Jenkins chapter, screenshots, glossary, references, version 1.5 (#11)
Scrap-Web/pipeline/pr-main This commit looks good
Scrap-Web/pipeline/head This commit looks good
2026-10-24 00:28:24 -04:00
samahk13 1de58d4742 Merge pull request 'Add pricing module, tests and Jenkinsfile for CI (#11)' (#13) from feature/issue-11 into main
Scrap-Web/pipeline/head This commit looks good
Reviewed-on: #13
Reviewed-by: kholmes <kholmes2@stevens.edu>
2026-10-24 03:13:17 +00:00
samahk13 84a44f0477 Fix total_price: restore multiplication (#11)
Scrap-Web/pipeline/pr-main This commit looks good
Scrap-Web/pipeline/head This commit looks good
2026-10-23 23:06:39 -04:00
samahk13 a5180ad781 Demonstrate failing CI check: use addition in total_price (#N)
Scrap-Web/pipeline/pr-main There was a failure building this commit
2026-10-23 23:04:14 -04:00
samahk13 8ba340e32f Remove stray files from CI pull request; manual chapter moves to its own PR (#11)
Scrap-Web/pipeline/pr-main This commit looks good
2026-10-23 23:01:57 -04:00
samahk13 c5538a84d1 Merge main into feature/issue-11, keeping the tested Jenkinsfile (#11)
Scrap-Web/pipeline/pr-main This commit looks good
2026-10-23 22:52:52 -04:00
samahk13 81c343ddb6 Fix total_price: restore multiplication (#11)
Scrap-Web/pipeline/pr-main This commit looks good
2026-10-23 22:41:45 -04:00
samahk13 091a9a9695 Update repository with local changes 2026-10-23 22:36:04 -04:00
samahk13 ab0bcc25f3 Demonstrate failing CI check: use addition in total_price (#11)
Scrap-Web/pipeline/pr-main There was a failure building this commit
2026-10-23 22:32:31 -04:00
kholmes fa22a0d512 Merge pull request 'Added Jenkinsfile for build automation' (#15) from kholmes-patch-2 into main
Scrap-Web/pipeline/head There was a failure building this commit
Reviewed-on: #15
2026-10-24 01:19:22 +00:00
kholmes b779817f2c Added Jenkinsfile for build automation
Scrap-Web/pipeline/pr-main There was a failure building this commit
Scrap-Web/pipeline/head There was a failure building this commit
2026-10-24 01:18:17 +00:00
samahk13 b899233138 Add pricing module, tests and Jenkinsfile for CI (#11)
Scrap-Web/pipeline/pr-main This commit looks good
2026-10-18 15:03:41 -04:00
114 changed files with 5513 additions and 18 deletions
+5 -5
View File
@@ -6,9 +6,9 @@ on:
push:
branches: [main]
paths:
- 'manual/**'
- '.gitea/workflows/manual.yml'
workflow_dispatch: # lets a team member re-run a build by hand from the Actions tab
- "manual/**"
- ".gitea/workflows/manual.yml"
workflow_dispatch: # lets a team member re-run a build by hand from the Actions tab
jobs:
build-manual:
@@ -31,7 +31,7 @@ jobs:
GIT_COMMIT: ${{ github.sha }}
BUILD_NUMBER: ${{ github.run_number }}
run: |
MANUAL_VERSION="v1.4"
MANUAL_VERSION="v1.5"
SHORT_SHA="${GIT_COMMIT:0:7}"
BUILD_ID="${MANUAL_VERSION}+build.${BUILD_NUMBER}.${SHORT_SHA}"
@@ -48,7 +48,7 @@ jobs:
\textbf{Commit hash:} \BuildCommit\\
\textbf{Gitea Actions run:} \BuildRunNumber
EOF
- name: Record build identity and toolchain
run: |
SHORT_SHA="${GITHUB_SHA::7}"
+1
View File
@@ -0,0 +1 @@
__pycache__/
Vendored
+188
View File
@@ -0,0 +1,188 @@
// Scrap-Web pipeline: Chapter 4 CI checks + Chapter 6 secure delivery.
//
// Trust boundary:
// * Every build (branches and pull requests) runs the Chapter 4 checks on the
// controller's built-in node. No credentials, no Docker socket.
// * Delivery stages run only for trusted branches, on the 'delivery' agent,
// which holds the Docker socket and the registry/deploy credentials.
// TODO before submission: remove the feature branch from TRUSTED_BRANCH so
// only reviewed code on main can deliver.
def TRUSTED_BRANCH = 'main'
pipeline {
agent none
options {
skipDefaultCheckout()
disableConcurrentBuilds() // no competing releases
timeout(time: 30, unit: 'MINUTES')
buildDiscarder(logRotator(numToKeepStr: '50'))
}
environment {
REGISTRY = 'git.ssw590-08.me'
IMAGE = 'git.ssw590-08.me/ssw-590-08/pricing'
}
stages {
// ---------------- Chapter 4 CI (all builds, controller) ----------------
stage('CI checks') {
agent { label 'built-in' }
steps {
checkout scm
sh 'git rev-parse HEAD'
sh 'python3 --version'
sh 'python3 -m py_compile pricing.py tests/test_pricing.py'
sh 'python3 -m unittest discover -s tests -v'
}
}
// ---------------- Chapter 6 delivery (trusted branches, agent) ---------
stage('Delivery') {
when { beforeAgent true; branch pattern: TRUSTED_BRANCH, comparator: 'REGEXP' }
agent { label 'delivery' }
stages {
stage('Checkout') {
steps {
checkout scm
script {
env.APP_COMMIT = sh(script: 'git rev-parse HEAD', returnStdout: true).trim()
env.IMAGE_TAG = "${env.IMAGE}:${env.APP_COMMIT}"
}
echo "Source commit: ${env.APP_COMMIT}"
}
}
stage('Unit tests') {
steps {
dir('pricing') {
sh '''
python3 -m venv .venv
.venv/bin/pip install -q --require-hashes -r requirements.txt
.venv/bin/python -m py_compile app.py test_app.py
.venv/bin/python -m unittest -v
'''
}
}
}
// 6.4.5 (kholmes): dependency + secret checks on the source.
stage('Security scan: source') {
steps {
sh '''
if [ -x security/scan.sh ]; then
security/scan.sh source
else
echo "security/scan.sh not added yet (6.4.5)"
fi
'''
}
}
stage('Build image') {
steps {
dir('pricing') {
sh 'docker build --build-arg APP_COMMIT="$APP_COMMIT" -t "$IMAGE_TAG" .'
}
}
}
// 6.4.5 (kholmes): image vulnerability scan before publishing.
stage('Security scan: image') {
steps {
sh '''
if [ -x security/scan.sh ]; then
security/scan.sh image "$IMAGE_TAG"
else
echo "security/scan.sh not added yet (6.4.5)"
fi
'''
}
}
stage('Publish') {
steps {
withCredentials([usernamePassword(credentialsId: 'gitea-registry-push',
usernameVariable: 'REG_USER',
passwordVariable: 'REG_TOKEN')]) {
// Push, then delete the local copy and pull it back from the
// registry, so the recorded digest is the registry's, not a local ID.
sh '''
printf '%s' "$REG_TOKEN" | docker login "$REGISTRY" -u "$REG_USER" --password-stdin
docker push "$IMAGE_TAG"
docker image rm "$IMAGE_TAG"
docker pull "$IMAGE_TAG"
docker logout "$REGISTRY"
docker image inspect "$IMAGE_TAG" --format '{{index .RepoDigests 0}}' > image-digest.txt
echo "Published: $(cat image-digest.txt)"
'''
}
script { env.IMAGE_DIGEST = readFile('image-digest.txt').trim() }
writeFile file: 'build-record.txt', text: """source_commit: ${env.APP_COMMIT}
image_tag: ${env.IMAGE_TAG}
image_digest: ${env.IMAGE_DIGEST}
jenkins_build: ${env.BUILD_URL}
"""
archiveArtifacts artifacts: 'image-digest.txt, build-record.txt', fingerprint: true
}
}
// 6.4.6: deploy the digest just published to staging with Ansible,
// then rerun unchanged and require changed=0 (idempotence).
stage('Deploy staging') {
steps {
script {
// Expected behaviour comes from the source, not from config.
def version = sh(script: "sed -n 's/^VERSION = \"\\(.*\\)\"/\\1/p' pricing/app.py", returnStdout: true).trim()
def unit = sh(script: "sed -n 's/^UNIT_PRICE = //p' pricing/app.py", returnStdout: true).trim()
env.APP_VERSION = version
writeFile file: "release-${version}-staging.yml", text: """target_env: staging
release_image: ${env.IMAGE_DIGEST}
expected_version: ${version}
expected_commit: ${env.APP_COMMIT}
expected_total: ${3 * (unit as Integer)}
public_url: https://staging.ssw590-08.me
proxy_network: gitea-net
"""
}
archiveArtifacts artifacts: "release-${env.APP_VERSION}-staging.yml", fingerprint: true
withCredentials([sshUserPrivateKey(credentialsId: 'deploy-ssh', keyFileVariable: 'DEPLOY_KEY')]) {
sh '''
export PATH=/opt/ansible-venv/bin:$PATH
ansible-playbook -i ansible/inventory.ini ansible/deploy.yml --syntax-check
ansible-playbook -i ansible/inventory.ini ansible/deploy.yml \
--private-key "$DEPLOY_KEY" -e @release-$APP_VERSION-staging.yml
'''
}
}
}
stage('Staging idempotence') {
steps {
withCredentials([sshUserPrivateKey(credentialsId: 'deploy-ssh', keyFileVariable: 'DEPLOY_KEY')]) {
sh '''
export PATH=/opt/ansible-venv/bin:$PATH
ansible-playbook -i ansible/inventory.ini ansible/deploy.yml \
--private-key "$DEPLOY_KEY" -e @release-$APP_VERSION-staging.yml | tee rerun.log
grep -E 'startup +: .*changed=0 +unreachable=0 +failed=0' rerun.log \
|| { echo "Second run changed something: not idempotent"; exit 1; }
'''
}
}
}
// 6.4.7 (kholmes): approval + production deploy.
stage('Approve and deploy production') {
steps { echo 'Not implemented yet (6.4.7).' }
}
}
}
}
post {
success { echo 'All stages passed.' }
failure { echo 'A stage failed: see the stage view for which one.' }
}
}
+4
View File
@@ -0,0 +1,4 @@
# Secrets and host-specific values stay on the Droplet
jenkins-agent.secret
agent.secrets.env
.env
+31
View File
@@ -0,0 +1,31 @@
# Trusted Jenkins delivery agent for Chapter 6.
# Build context is the repository root (see agent/compose.yaml).
FROM jenkins/inbound-agent:latest-jdk21
USER root
# Python 3 + venv for tests, pip-audit and Ansible; curl for checks
RUN apt-get update \
&& apt-get install -y --no-install-recommends python3 python3-venv python3-pip ca-certificates curl \
&& rm -rf /var/lib/apt/lists/*
# Docker CLI + buildx plugin (client only; the daemon is the host's, via the mounted socket)
COPY --from=docker:cli /usr/local/bin/docker /usr/local/bin/docker
COPY --from=docker/buildx-bin /buildx /usr/libexec/docker/cli-plugins/docker-buildx
# Trivy scanner (image vulnerabilities + secret scanning)
COPY --from=aquasec/trivy:latest /usr/local/bin/trivy /usr/local/bin/trivy
# Ansible in its own virtual environment, plus the community.docker collection
ENV ANSIBLE_COLLECTIONS_PATH=/opt/ansible-collections
COPY ansible/requirements.yml /tmp/ansible-requirements.yml
RUN python3 -m venv /opt/ansible-venv \
&& /opt/ansible-venv/bin/pip install --no-cache-dir ansible-core \
&& /opt/ansible-venv/bin/ansible-galaxy collection install -r /tmp/ansible-requirements.yml -p /opt/ansible-collections \
&& rm /tmp/ansible-requirements.yml
# pip-audit in a separate tools venv
RUN python3 -m venv /opt/tools-venv \
&& /opt/tools-venv/bin/pip install --no-cache-dir pip-audit
USER jenkins
+41
View File
@@ -0,0 +1,41 @@
# Trusted delivery agent. Connects to the existing Jenkins controller over the
# internal gitea-net network (WebSocket), so no new port is published.
services:
jenkins-agent:
build:
context: ..
dockerfile: agent/Dockerfile
image: ssw590/jenkins-delivery-agent:1
container_name: jenkins-agent
restart: unless-stopped
# Start agent.jar directly. The secret is read from a file (-secret @file),
# so it never appears in the process list, docker inspect, or Git.
entrypoint:
- java
- -jar
- /usr/share/jenkins/agent.jar
- -url
- http://jenkins:8080/
- -webSocket
- -name
- delivery-agent
- -workDir
- /home/jenkins/agent
- -secret
- "@/run/secrets/jenkins-agent-secret"
# Host Docker socket: needed to build/push images. This is effectively root
# on the Droplet, so only reviewed main-branch delivery jobs may use this agent.
group_add: ["${DOCKER_GID:?set DOCKER_GID in .env}"]
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- ./jenkins-agent.secret:/run/secrets/jenkins-agent-secret:ro
- agent_home:/home/jenkins # workspace, known_hosts, registry login
networks: [gitea-net]
networks:
gitea-net:
external: true
name: gitea-net
volumes:
agent_home:
+12
View File
@@ -0,0 +1,12 @@
#!/bin/sh
# Print tool versions inside the agent. From the repo root on the Droplet:
# docker exec -i jenkins-agent sh -s < agent/versions.sh
echo "== java"; java -version 2>&1 | head -1
echo "== python"; python3 --version
echo "== docker"; docker version --format 'client {{.Client.Version}} / server {{.Server.Version}}'
echo "== buildx"; docker buildx version
echo "== trivy"; trivy --version | head -1
echo "== pip-audit"; /opt/tools-venv/bin/pip-audit --version
echo "== ansible"; /opt/ansible-venv/bin/ansible --version | head -3
echo "== collections"; /opt/ansible-venv/bin/ansible-galaxy collection list community.docker 2>/dev/null | tail -2
echo "== os"; . /etc/os-release; echo "$PRETTY_NAME $(uname -m)"
+62
View File
@@ -0,0 +1,62 @@
- name: Deploy a selected immutable pricing release
hosts: delivery
become: true
vars:
project_dir: "/opt/startup/pricing-{{ target_env }}"
tasks:
- name: Validate release selection
ansible.builtin.assert:
that:
- target_env in ['staging', 'production']
- "'@sha256:' in release_image"
- expected_version in ['v1', 'v2']
- expected_total | int > 0
- public_url.startswith('https://')
- proxy_network | length > 0
- name: Create deployment directory
ansible.builtin.file:
path: "{{ project_dir }}"
state: directory
mode: '0750'
- name: Render selected Compose configuration
ansible.builtin.template:
src: compose.yaml.j2
dest: "{{ project_dir }}/compose.yaml"
mode: '0640'
- name: Converge application without rebuilding
community.docker.docker_compose_v2:
project_src: "{{ project_dir }}"
project_name: "pricing-{{ target_env }}"
state: present
build: never
pull: missing
wait: true
wait_timeout: 90
- name: Verify health through public TLS endpoint
ansible.builtin.uri:
url: "{{ public_url }}/health"
return_content: true
validate_certs: true
register: health
until: health.status == 200 and health.json.status == 'ok'
retries: 12
delay: 5
changed_when: false
- name: Read release identity
ansible.builtin.uri:
url: "{{ public_url }}/"
return_content: true
register: identity
changed_when: false
- name: Exercise business behavior
ansible.builtin.uri:
url: "{{ public_url }}/price?quantity=3"
return_content: true
register: price
changed_when: false
- name: Check release identity and calculation
ansible.builtin.assert:
that:
- identity.json.version == expected_version
- identity.json.commit == expected_commit
- price.json.total | int == expected_total | int
+4
View File
@@ -0,0 +1,4 @@
[delivery]
# Target: the existing Droplet, reached over SSH as the dedicated deploy account.
# Host key must be verified and pinned in the agent's known_hosts before first use.
startup ansible_host=147.182.179.191 ansible_user=deploy
+3
View File
@@ -0,0 +1,3 @@
collections:
- name: community.docker
version: ">=4.8.0,<6.0.0"
+19
View File
@@ -0,0 +1,19 @@
services:
app:
image: "{{ release_image }}"
restart: unless-stopped
read_only: true
tmpfs:
- /tmp
cap_drop:
- ALL
security_opt:
- no-new-privileges:true
networks:
edge:
aliases:
- "pricing-{{ target_env }}"
networks:
edge:
external: true
name: "{{ proxy_network }}"
+21
View File
@@ -0,0 +1,21 @@
services:
jenkins:
build: .
image: custom-jenkins:lts-jdk21-python3
container_name: jenkins
restart: unless-stopped
environment:
JAVA_OPTS: "-Xms256m -Xmx512m"
volumes:
- jenkins-home:/var/jenkins_home
networks:
- gitea-net
volumes:
jenkins-home:
name: jenkins_home
networks:
gitea-net:
external: true
name: gitea-net
Binary file not shown.

After

Width:  |  Height:  |  Size: 146 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 192 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 159 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 194 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 220 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 617 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 169 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 68 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 422 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 157 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 42 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 174 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 80 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 60 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 29 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 42 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 28 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 47 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 72 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 48 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 72 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 53 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 264 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 68 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 52 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 68 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 38 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 52 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 67 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 25 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 38 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 72 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 123 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 84 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 131 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 160 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 65 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 432 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 235 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 151 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 188 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 522 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 84 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 134 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 94 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 472 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 257 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 66 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 47 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 281 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 104 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 172 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 52 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 149 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 105 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 142 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 98 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 85 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 120 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 92 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 31 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 53 KiB

-1
View File
@@ -1,4 +1,3 @@
% This file acts as the entry point for AI
\chapter{AI Agent Usage Guide}
\ChapterLabel{AIAgentGuide}
\index{AI agent}
+54
View File
@@ -60,4 +60,58 @@ directly. Unresolved assumptions: chapter labels for the Digital Ocean
Docker Deployment and class-based JavaScript refactor chapters not
confirmed, as the assistant did not create those two chapters.
\item \textbf{Automated manual build.} Date: October 8--9, 2026. Tool and
model: Claude, model claude-opus-5-5. Task: plan the team work split, create
the reproducible build configuration (\texttt{.latexmkrc}), the Gitea
Actions workflow, the job-image Dockerfile, and draft the Automated Manual
Build chapter. Inputs: assignment instructions; the manual's LaTeX source.
Output used: build configuration, workflow, Dockerfile, chapter text for
sections 1, 3 and 5. Human review and corrections: the build command and
workflow shell steps were tested by compiling the manual in the assistant's
sandbox; the student moved the manual from issue~5 to a dedicated issue~8
branch. Unresolved assumptions: runner label \texttt{latex} and the TL2025
job image are pending the runner registration.
\item \textbf{Continuous integration with Jenkins.} Date: October 18--24,
2026. Tool and model: Claude, model claude-opus-5-5. Task: split the work,
guide the Gitea integration account, branch protection and pull-request
demonstration, write the pricing tests and \texttt{Jenkinsfile}, and draft
and edit the Continuous Integration chapter. Inputs: assignment
instructions; sanitized screenshots, console logs, and commit IDs. Output
used: \texttt{Jenkinsfile}, tests, chapter text, and edits merging both
partners' sections. Human review and corrections: the students ran every
step on the real services and supplied the evidence; the assistant's claims
were checked against the screenshots (for example, the token scopes).
Unresolved assumptions: none.
\item \textbf{SRE monitoring and reliability.} Date: October 25--29, 2026.
Tool and model: Claude, model claude-opus-5-5. Task: split the work, choose
pinned releases, write the monitoring Compose, Prometheus, Blackbox, Grafana
provisioning and dashboard files and the runbook, guide the alert set-up
and incident exercise, and draft sections of the SRE chapter. Inputs:
assignment instructions; baseline and \texttt{docker stats} output;
Prometheus API query output; Grafana and Discord screenshots. Output used:
configuration files, dashboard JSON, runbook, and chapter text. Human review
and corrections: the student deployed and ran everything on the Droplet;
the SMTP failure led to the Discord route; an incorrect alert condition and
summary found during testing were corrected; all timestamps come from the
recorded logs and screenshots. Unresolved assumptions: none.
\item \textbf{SRE chapter completion.} Date: October 30, 2026. Tool and
model: Claude (configured model claude-sonnet-5-5). Task: complete the
\texttt{HostDiskLow} alert subsection and its repeat test; merge the two
exported alert rules into one file; draft the capacity and retention
rationale, the deployment diagram, the SLI, SLO, and SLA definitions and
worked example, the metric inventory, and the access-control text; add the
Hosts and Passwords rows. Inputs: manual Chapter 5; the existing chapter
text and Compose file; Grafana, Discord, and terminal screenshots; the
exported alert-rule YAML. Output used: chapter text, a Graphviz diagram, and
\texttt{alert-rules.yaml}. Human review and corrections: the students ran
every test and supplied all evidence; a Grafana address in an early export
command was wrong and returned an empty file, which was caught from the
output and corrected. Unresolved assumptions: the probe route from Blackbox
Exporter to the public hostnames is inferred from the Compose networks, not
tested.
\end{itemize}
+12 -3
View File
@@ -9,6 +9,7 @@
\usepackage{fancyhdr}
\usepackage{amsmath,amssymb}
\usepackage{array}
\usepackage{seqsplit}
\usepackage{booktabs}
\usepackage{longtable}
\usepackage{tabularx}
@@ -40,10 +41,10 @@
\newcommand{\CourseName}{DevOps}
\newcommand{\Instructor}{Samah Keshiro and Kayla Holmes}
\newcommand{\Organization}{Stevens Institute of Technology}
\newcommand{\DocumentDate}{10/10/26}
\newcommand{\DocumentDate}{November 13, 2026}
\newcommand{\DueDate}{[Due Date and Time]}
\newcommand{\VERSION}{Version 1.4}
\newcommand{\AssignmentNumber}{5}
\newcommand{\VERSION}{Version 1.7 (draft)}
\newcommand{\AssignmentNumber}{7}
\newcolumntype{Y}{>{\raggedright\arraybackslash}X}
\newcolumntype{L}[1]{>{\raggedright\arraybackslash}p{#1}}
@@ -133,6 +134,12 @@
\include{devopsProjectProposal}
\include{devopsJenkinsCI}
\include{devopsPasswordsAndHosts}
\include{devopsAutomatedManualBuild}
\include{devopsCI}
\include{devopsSRE}
\include{devopsSecureDelivery}
\printglossaries
\bibliographystyle{IEEEtran}
\bibliography{devopsReferences}
@@ -140,4 +147,6 @@
\appendix
\include{devopsAIPromptLog}
\printindex
\end{document}
+517
View File
@@ -0,0 +1,517 @@
\chapter{Automated Manual Build}
\ChapterLabel{AutomatedManualBuild}
\index{Gitea Actions}
\index{automated manual build}
% ---------------------------------------------------------------------------
% Bracketed italic text marks evidence that is added once the runner is online
% and a real workflow run exists. Replace each placeholder with the actual
% value or screenshot; do not fill them in before the run has happened.
% ---------------------------------------------------------------------------
\section{Source and Trigger}
\textbf{Repository and files:}
\begin{description}
\item[Repository:] \url{https://git.ssw590-08.me/SSW-590-08/Scrap-Web}
\item[Manual source folder:]
\url{https://git.ssw590-08.me/SSW-590-08/Scrap-Web/src/branch/main/manual}
\item[Main file:]
\url{https://git.ssw590-08.me/SSW-590-08/Scrap-Web/src/branch/main/manual/devopsAssignment.tex}
\item[Workflow:]
\url{https://git.ssw590-08.me/SSW-590-08/Scrap-Web/src/branch/main/.gitea/workflows/manual.yml}
\item[Tracking issue:]
\url{https://git.ssw590-08.me/SSW-590-08/Scrap-Web/issues/8}
\item[Pull request:] \url{https://git.ssw590-08.me/SSW-590-08/Scrap-Web/pulls/9}
\end{description}
The manual is stored in the \texttt{manual/} folder of the team's existing
product repository, Scrap-Web, rather than in a separate repository. The
complete buildable project is version-controlled there: every chapter file,
the \texttt{cornell.cls} document class, the \texttt{IEEEtran.bst}
bibliography style, \texttt{devopsReferences.bib}, the glossary, and all
figures under \texttt{HW2 images/} and \texttt{HW4 images/}. Generated files
(PDF, \texttt{.aux}, \texttt{.log}, minted cache, and so on) are excluded by
\texttt{manual/.gitignore}, so the repository holds source only. The
repository is the source of truth; the PDF is never edited directly.
\textbf{How the source was added:} the manual was committed on the branch
\texttt{issue-8} (tracked by issue \#8), pushed to Gitea, and merged into
\texttt{main} through a pull request. Work on the website itself happens on
other branches and is unaffected.
\textbf{Selected branch and event:} the workflow runs on a \texttt{push} to
\texttt{main}. A path filter limits it to pushes that change
\texttt{manual/**} or the workflow file itself, so website-only commits do
not rebuild the manual. Merging a pull request into \texttt{main} counts as
such a push. The workflow can also be started by hand from the Actions tab
(\texttt{workflow\_dispatch}).
\begin{figure}
\centering
\includegraphics[width=1\linewidth]{HW5 images/actions.png}
\caption{10/09/26 Screenshot of Actions tab}
\label{fig:actions}
\end{figure}
\textbf{Git remote and network path:} team members push over HTTPS. The
remote is configured as:
\begin{verbatim}
$ git remote -v
origin https://git.ssw590-08.me/SSW-590-08/Scrap-Web.git (fetch)
origin https://git.ssw590-08.me/SSW-590-08/Scrap-Web.git (push)
\end{verbatim}
\begin{center}
\begin{tabular}{lll}
\toprule
Hop & Port & Exposure \\
\midrule
Laptop $\rightarrow$ Caddy (TLS proxy) & 443/TCP (HTTPS) & Public \\
Caddy $\rightarrow$ Gitea web service & 3000/TCP (HTTP) & Private Docker network only \\
\bottomrule
\end{tabular}
\end{center}
A \texttt{git push} connects to \texttt{git.ssw590-08.me} on port 443,
exactly as a browser does. Caddy terminates TLS and forwards the request over
the internal Docker network to Gitea on port 3000, which is not published to
the internet. Gitea's public root URL is set to
\url{https://git.ssw590-08.me/}, so clone URLs and links point at the HTTPS
hostname. SSH pushes are not needed for this assignment.
\textbf{Why the runner needs no public port:} the runner never receives
connections. It contacts Gitea outbound over HTTPS to register and to poll
for jobs; the job then checks out the source and uploads the PDF over the
same HTTPS URL. Because all traffic is initiated by the runner, no submission
or management port has to be opened for it.
\section{Runner Setup}
Gitea Actions was enabled for the Scrap-Web repository to support automated builds of the DevOps IT manual. A Gitea Actions runner was registered to execute workflow jobs. The runner was configured with the label \texttt{latex}, allowing the workflow to select the appropriate execution environment through the \texttt{runs-on: latex} setting in \texttt{.gitea/workflows/manual.yml}. The runner uses \texttt{act\_runner} and executes the build job in a Docker container based on the custom image \texttt{latex-job:local}. This image provides the TeX Live environment and the additional tools required to compile the LaTeX document, including \texttt{latexmk}, \texttt{latexminted}, and Pygments. \subsection{Runner Details} The runner configuration is summarized below. \begin{itemize} \item \textbf{Location:} The runner was hosted on a local macOS computer using Docker Desktop, separate from the DigitalOcean Droplet hosting Gitea. \item \textbf{Version:} Gitea Actions runner \texttt{act\_runner} version 0.6.1. \item \textbf{Execution mode:} Docker-based job execution using the custom image \texttt{latex-job:local}. Each job runs in a temporary container. \item \textbf{Capacity:} One concurrent job, configured with \texttt{capacity: 1} in the runner configuration. \item \textbf{Registration scope:} The runner was registered for the repository's Actions workflow. The registration scope was configured through the Gitea repository's runner settings. \end{itemize}
\subsection{Connectivity and Security} The runner connects to the Gitea instance at \texttt{https://git.ssw590-08.me}. The runner container uses the configured Gitea instance URL and Docker socket to retrieve workflow jobs and launch their job containers. Docker-based execution isolates the build environment from the Gitea application container. The Docker daemon socket is mounted inside the runner container so that it can create job containers; therefore, access to the socket is restricted to the trusted runner environment. No separate runner-management or Docker daemon port was intentionally exposed to the public internet. The runner communicates with Gitea over HTTPS, while the job environment must have network access to the resources required for the build.
\subsection{Resource Considerations} The DigitalOcean Droplet hosting Gitea had approximately 458 MiB of total memory, with approximately 114 MiB available during the earlier resource check. Because this was limited memory, the LaTeX runner was placed on the local macOS computer rather than adding another resource-intensive service to the Droplet. This arrangement reduces the additional memory and disk load on the Gitea server while allowing the runner to use the custom Docker image required for the manual build.
\subsection{Network Path and Runner Verification}
The Gitea Actions runner operates on the local macOS computer
using Docker Desktop. It connects to the Gitea instance at
\texttt{https://git.ssw590-08.me} over HTTPS. The runner retrieves
workflow jobs from Gitea and launches the assigned job in a
Docker container using the custom image
\texttt{latex-job:local}.
The workflow targets the runner through the label
\texttt{latex}, configured with \texttt{runs-on: latex}.
The runner has a capacity of one concurrent job, allowing
one workflow job to execute at a time.
The runner uses the Docker socket to create job containers.
The Docker daemon is not intentionally exposed through a
public network port. Because access to the Docker socket
provides substantial control over the Docker host, access is
restricted to the trusted runner environment.
Figure~\ref{fig:runner-job-assigned} provides evidence of the
runner's status and its assignment to a workflow job.
\begin{figure}[htbp]
\centering
\includegraphics[width=\linewidth]
{HW5 images/runner-verification.png}
\caption{Gitea Actions runner online with a workflow job assigned.}
\label{fig:runner-job-assigned}
\end{figure}
\section{Reproducible Compilation}
\begin{description}
\item[Main file:] \texttt{manual/devopsAssignment.tex}
\item[Build command:] \texttt{latexmk devopsAssignment.tex}, run in the
\texttt{manual/} folder
\item[Build configuration:] \texttt{manual/.latexmkrc}
\item[Expected PDF path:] \texttt{manual/devopsAssignment.pdf}
\item[Job image definition:] \texttt{manual/ci/Dockerfile}
\item[Base image:] \texttt{texlive/texlive:TL2025-historic}
\item[Resolved image ID/digest:] \textit{b5c35d6bdbb9}
\end{description}
\textbf{Where TeX runs:} the compiler is not installed in the Gitea
container. The workflow targets the runner label \texttt{latex}
(\texttt{runs-on: latex}), which maps to a job image built from
\texttt{manual/ci/Dockerfile}. That image is the official TeX Live image,
which already contains \texttt{pdflatex}, \texttt{latexmk}, \texttt{bibtex},
\texttt{makeindex}, \texttt{makeglossaries}, and Python with Pygments (needed
by the \texttt{minted} package). The Dockerfile adds only Node.js and Git from
the image's own Debian package repositories, which the checkout and upload
actions require; no external script is downloaded and executed. The base
image uses a fixed TeX Live release tag rather than \texttt{latest}, so every
build uses the same toolchain.
\textbf{Build command and dependencies:} all compiler options are stored in
\texttt{manual/.latexmkrc}, so the same command works on a laptop and in the
workflow:
\begin{minted}[breaklines]{perl}
$pdf_mode = 1;
$pdflatex = 'pdflatex -shell-escape -interaction=nonstopmode -halt-on-error -file-line-error %O %S';
add_cus_dep('glo', 'gls', 0, 'run_makeglossaries');
add_cus_dep('acn', 'acr', 0, 'run_makeglossaries');
sub run_makeglossaries { return system("makeglossaries \"$_[0]\""); }
\end{minted}
\texttt{latexmk} runs \texttt{pdflatex} as many times as needed and calls
\texttt{bibtex}, \texttt{makeindex}, and \texttt{makeglossaries} when their
inputs change. \texttt{-shell-escape} is required by \texttt{minted}.
\textbf{Workflow:} the complete workflow file,
\texttt{.gitea/workflows/manual.yml}, is shown below.
\begin{minted}[breaklines]{yaml}
name: Build IT manual
on:
push:
branches: [main]
paths:
- 'manual/**'
- '.gitea/workflows/manual.yml'
workflow_dispatch:
jobs:
build-manual:
runs-on: latex
defaults:
run:
shell: bash
steps:
- name: Check out the triggering commit
uses: actions/checkout@v4
- name: Generate build metadata
working-directory: manual
env:
GIT_COMMIT: ${{ github.sha }}
BUILD_NUMBER: ${{ github.run_number }}
run: |
MANUAL_VERSION="v1.4"
SHORT_SHA="${GIT_COMMIT:0:7}"
BUILD_ID="${MANUAL_VERSION}+build.${BUILD_NUMBER}.${SHORT_SHA}"
cat > build-metadata.tex <<EOF
\newcommand{\ManualVersion}{${MANUAL_VERSION}}
\newcommand{\BuildIdentifier}{${BUILD_ID}}
\newcommand{\BuildCommit}{${GIT_COMMIT}}
\newcommand{\BuildRunNumber}{${BUILD_NUMBER}}
EOF
cat >> build-metadata.tex <<'EOF'
\noindent\textbf{Manual version:} \ManualVersion\\
\textbf{Build identifier:} \BuildIdentifier\\
\textbf{Commit hash:} \BuildCommit\\
\textbf{Gitea Actions run:} \BuildRunNumber
EOF
- name: Record build identity and toolchain
run: |
SHORT_SHA="${GITHUB_SHA::7}"
echo "SHORT_SHA=${SHORT_SHA}" >> "$GITHUB_ENV"
echo "Commit: ${GITHUB_SHA} (${SHORT_SHA})"
echo "Run number: ${GITHUB_RUN_NUMBER}"
pdflatex --version | head -n 1
latexmk -v | head -n 2 | tail -n 1
python3 -c "import pygments; print('Pygments', pygments.__version__)"
- name: Compile the manual
working-directory: manual
run: latexmk devopsAssignment.tex
- name: Verify the PDF exists
working-directory: manual
run: |
if [ ! -s devopsAssignment.pdf ]; then
echo "ERROR: manual/devopsAssignment.pdf is missing or empty"
exit 1
fi
ls -l devopsAssignment.pdf
- name: Upload the PDF as an artifact
uses: actions/upload-artifact@v3
with:
name: it-manual-build-${{ github.run_number }}-${{ env.SHORT_SHA }}
path: manual/devopsAssignment.pdf
if-no-files-found: error
retention-days: 30
\end{minted}
\textbf{Failure detection:} the build fails in three independent ways.
\begin{enumerate}
\item A LaTeX error stops \texttt{pdflatex} immediately
(\texttt{-halt-on-error}); \texttt{latexmk} then exits with a non-zero
code, which fails the \emph{Compile the manual} step. The log shows the
failing file and line (\texttt{-file-line-error}).
\item If compilation reports success but the PDF is missing or empty, the
\emph{Verify the PDF exists} step exits with code 1 and prints an error.
\item The upload step uses \texttt{if-no-files-found: error}, so it cannot
silently upload nothing.
\end{enumerate}
A failed step stops the job, so no artifact is produced from a broken build.
\textbf{Checkout and upload without a shared filesystem:} the job container
shares no files with Gitea. The \texttt{actions/checkout} step clones the
exact triggering commit from Gitea over HTTPS, the compile happens inside the
temporary job container, and \texttt{actions/upload-artifact} sends the PDF
back to Gitea over HTTPS, where it is attached to the matching run. The
container is discarded when the job ends.
\begin{figure}[H]
\centering
\includegraphics[width=1\linewidth]{HW5 images/run-build-log.png}
\caption{Successful build log}
\label{fig:run-log}
\end{figure}
\section{PDF Version Traceability}
Every PDF produced by the workflow carries two kinds of version information:
a \emph{human-maintained} manual version, which the team changes deliberately
when the manual's content is revised, and a \emph{generated} build
identifier, which the workflow creates automatically for every run. The
build identifier appends the run number and the triggering commit to the
manual version:
\begin{center}
\texttt{<manual version>+build.<run number>.<short commit hash>}
\end{center}
\subsection{Build Identifier for Run \#10}
The table below traces one build from its source commit to the finished PDF.
\begin{tabularx}{\linewidth}{L{3.4cm}L{4.4cm}Y}
\toprule
\textbf{Field} & \textbf{Where it comes from} & \textbf{Value for run \#10}\\ \midrule
Manual version & \texttt{MANUAL\_VERSION} in the \emph{Generate build metadata} step of \texttt{manual.yml}, edited by the team & \texttt{v1.4}\\
Workflow run number & \texttt{GITHUB\_RUN\_NUMBER}, set by Gitea Actions & \texttt{10}\\
Source commit & \texttt{GITHUB\_SHA}, the triggering commit, shortened to 7 characters & \texttt{67e9e17}\\
Build identifier & Combined by the workflow & \texttt{v1.4+build.10.67e9e17}\\
Gitea run & Actions tab & \url{https://git.ssw590-08.me/SSW-590-08/Scrap-Web/actions/runs/10}\\
Artifact & Uploaded by the same run & \texttt{it-manual-build-10-67e9e17}\\ \bottomrule
\end{tabularx}
The same three values appear in three places: the run's log
(Figure~\ref{fig:gitea-buildhash}), the artifact name, and the generated
PDF itself (Figure~\ref{fig:pdf-buildhash}). In the PDF, the build
identifier, full commit hash, and run number are printed on
\textit{[the title page / in the page footer: state where]}. Because the
commit hash in the PDF matches the commit listed on run \#10, a reader
holding only the PDF can find the exact source revision that produced it.
\subsection{How the Metadata Is Injected}
The human-maintained version is set once, in the \emph{Generate build
metadata} step of the workflow, and is kept equal to \texttt{\string\VERSION}
on the title page. The team changes it only when the manual's content is
revised, together with a new Document History entry. The run number and
commit hash are never typed by hand: Gitea Actions supplies them to every
job as \texttt{github.run\_number} and \texttt{github.sha}.
Before compiling, the workflow combines these values and writes a small
LaTeX file, \texttt{manual/build-metadata.tex}, inside the job container.
The file defines four macros and a short block that prints them:
\begin{minted}[breaklines]{yaml}
- name: Generate build metadata
working-directory: manual
env:
GIT_COMMIT: ${{ github.sha }}
BUILD_NUMBER: ${{ github.run_number }}
run: |
MANUAL_VERSION="v1.4"
SHORT_SHA="${GIT_COMMIT:0:7}"
BUILD_ID="${MANUAL_VERSION}+build.${BUILD_NUMBER}.${SHORT_SHA}"
cat > build-metadata.tex <<EOF
\newcommand{\ManualVersion}{${MANUAL_VERSION}}
\newcommand{\BuildIdentifier}{${BUILD_ID}}
\newcommand{\BuildCommit}{${GIT_COMMIT}}
\newcommand{\BuildRunNumber}{${BUILD_NUMBER}}
EOF
cat >> build-metadata.tex <<'EOF'
\noindent\textbf{Manual version:} \ManualVersion\\
\textbf{Build identifier:} \BuildIdentifier\\
\textbf{Commit hash:} \BuildCommit\\
\textbf{Gitea Actions run:} \BuildRunNumber
EOF
\end{minted}
For run \#10 the generated file therefore defined
\texttt{\string\BuildIdentifier} as \texttt{v1.4+build.10.67e9e17}. The manual
reads the file during compilation:
\begin{minted}[breaklines]{latex}
run: |
MANUAL_VERSION="v1.4"
SHORT_SHA="${GIT_COMMIT:0:7}"
BUILD_ID="${MANUAL_VERSION}+build.${BUILD_NUMBER}.${SHORT_SHA}"
cat > build-metadata.tex <<EOF
\newcommand{\ManualVersion}{${MANUAL_VERSION}}
\newcommand{\BuildIdentifier}{${BUILD_ID}}
\newcommand{\BuildCommit}{${GIT_COMMIT}}
\newcommand{\BuildRunNumber}{${BUILD_NUMBER}}
EOF
cat >> build-metadata.tex <<'EOF'
\noindent\textbf{Manual version:} \ManualVersion\\
\textbf{Build identifier:} \BuildIdentifier\\
\textbf{Commit hash:} \BuildCommit\\
\textbf{Gitea Actions run:} \BuildRunNumber
EOF
\end{minted}
The first \texttt{cat} uses an unquoted heredoc so that the shell
substitutes the version, run number and commit into the macro definitions;
the second uses a quoted heredoc (\texttt{<<'EOF'}) so that the LaTeX
commands are written literally.
\subsection{No Commit or Push Loop}
The metadata file exists only inside the temporary job container, and
\texttt{build-metadata.tex} is listed in \texttt{manual/.gitignore} so that a
local test build cannot commit it by accident. The workflow contains no \texttt{git commit} or \texttt{git push} step, so the
generated version is never written back to \texttt{main}; the container and
the file are discarded when the job ends. This matters because the workflow
is triggered by pushes to \texttt{main}: a workflow that committed its own
version file would trigger itself again on every build. The human-maintained
version and the Document History table therefore stay entirely under the
team's control, and change only when a team member edits them.
\subsection{Re-runs}
Re-running a workflow in Gitea keeps the same run number and checks out the
same commit, so a re-run produces a PDF with the same build identifier.
Because the source is identical, the team treats such a re-run as the same
build, and the run-attempt number is not included in the identifier.
\begin{figure}[H]
\centering
\includegraphics[width=1\linewidth]{HW5 images/gitea-buildhash.png}
\caption{Gitea build report}
\label{fig:gitea-buildhash}
\end{figure}
\begin{figure}[H]
\centering
\includegraphics[width=1\linewidth]{HW5 images/pdf-buildhas.png}
\caption{PDF compiled build report}
\label{fig:pdf-buildhash}
\end{figure}
\section{Downloadable Artifact}
\begin{description}
\item[Artifact name:] \texttt{it-manual-build-\textit{N}-\textit{H}},
where \textit{N} is the workflow run number and \textit{H} is the short
commit hash; for example, \texttt{it-manual-build-12-a1b2c3d}
\item[Contents:] \texttt{devopsAssignment.pdf}
\item[Retention:] 30 days, set in the workflow
(\texttt{retention-days: 30}).
\item[Example artifact link:] \url{https://git.ssw590-08.me/SSW-590-08/Scrap-Web/actions/runs/10/artifacts/it-manual-build-10-67e9e17}
\end{description}
Because the run number and commit hash are part of the artifact name, each
downloaded file can be matched to the run and commit that produced it.
\textbf{How a team member downloads the PDF:}
\begin{enumerate}
\item Open \url{https://git.ssw590-08.me/SSW-590-08/Scrap-Web/actions}.
\item Select the \emph{Build IT manual} workflow and open the run for the
commit of interest (the run lists its commit hash and branch).
\item Confirm the run finished successfully.
\item In the run's \emph{Artifacts} section, click
\texttt{it-manual-build-\ldots} to download it, then extract and open
\texttt{devopsAssignment.pdf}.
\end{enumerate}
Artifacts expire after the retention period and are not a backup. The
permanent record is the LaTeX source in Git, from which any version of the
manual can be rebuilt.
\begin{figure}[H]
\centering
\includegraphics[width=1\linewidth]{HW5 images/gitea-running-artifact.png}
\caption{Run page with the artifact listed, and the downloaded PDF open, dated}
\label{fig:fig:gitea-artifact-running}
\end{figure}
\section{Change, Failure, and Repair Evidence}
To verify the automated manual-build pipeline, two successive changes were committed to the main branch of the Scrap-Web repository. Each commit triggered a separate Gitea Actions run. Both builds completed successfully, and the generated PDF artifacts were checked to confirm that their build identifiers corresponded to the appropriate commits and run numbers.
A deliberate LaTeX error was then introduced into the manual source. The workflow detected the compilation error and terminated with a failed status because the build uses the -halt-on-error option. The failed run and its error log were recorded as evidence that the pipeline prevents an invalid manual from being treated as a successful build.
The invalid command was subsequently removed in a repair commit. A new Actions run compiled the corrected source successfully and produced a new PDF artifact. The repaired artifact's commit hash and run number were compared with the corresponding Gitea Actions run to verify that the output was generated from the repaired revision.
The generated metadata was produced during the workflow rather than committed back to the source branch. This kept the build identifier associated with the specific build while preserving the distinction between source commits and generated artifacts.
\begin{figure}[H]
\centering
\includegraphics[width=1\linewidth]{HW5 images/run-build-log.png}
\caption{Run log showing 2 successive builds, followed by an error, and another successful build}
\label{fig:buildlogs}
\end{figure}
\begin{figure}[H]
\centering
\includegraphics[width=1\linewidth]{HW5 images/errormessage.png}
\caption{Failed build error message}
\label{fig:error-message}
\end{figure}
\section{Runner and Secret Boundary}
\subsection{Workflow edit permissions} The automated build workflow is stored in .gitea/workflows/manual.yml. Users who can modify the workflow may change the commands executed by the runner. Repository write permissions and any branch-protection rules were reviewed to identify who can modify the workflow and its associated source files. The repository's actual permissions and branch-protection configuration are recorded in the accompanying evidence.
\subsection{Runner registration credentials} The Gitea Actions runner is hosted on the local macOS development machine. Its configuration is stored in ~/gitea-runner/runner-data/config.yaml, and its local runner credentials are stored in the runner-data directory, including the .runner file when present. These files are not included in the report or committed to the repository because they may contain sensitive authentication information. The registration token is used to register the runner; it is distinct from the credentials subsequently stored by the registered runner.
\subsection{Runner isolation} The runner uses the latex label, which matches the workflow's runs-on: latex setting. The runner executes the manual-build job in a Docker container based on the custom latex-job:local image. Its configured capacity is one job at a time. Hosting the runner on the development machine rather than the DigitalOcean Gitea server avoids placing the additional build workload on the server's limited memory and disk resources. Containerization provides isolation for the build environment, but it is not treated as a complete security boundary.
\subsection{Docker socket risk} The runner container has access to the Docker Desktop socket so that it can create job containers. Access to this socket is security-sensitive because it may allow control over Docker resources and potentially affect the host system. The socket is mounted locally for runner operation rather than deliberately exposed as a public network endpoint. The runner is therefore restricted to trusted coursework workflows, and its credentials and configuration files are kept out of source control.
Evidence includes the repository permission settings, runner configuration with secrets omitted, and the runner's Docker configuration. No authentication tokens or credential values are reproduced in this report.
\begin{figure}[H]
\centering
\includegraphics[width=1\linewidth]{HW5 images/adminpage.png}
\caption{Listed repo admins}
\label{fig:admin-perms}
\end{figure}
\begin{figure}[H]
\centering
\includegraphics[width=1\linewidth]{HW5 images/ownerpage.png}
\caption{Listed repo owners}
\label{fig:owner-perms}
\end{figure}
\begin{figure}[H]
\centering
\includegraphics[width=1\linewidth]{HW5 images/tokenlocations.png}
\caption{Verification of token existence}
\label{fig:tokenlocations}
\end{figure}
\begin{figure}[H]
\centering
\includegraphics[width=1\linewidth]{HW5 images/twosuccessruns.png}
\caption{Two Successive Runs}
\label{fig:successfulruns}
\end{figure}
\begin{figure}[H]
\centering
\includegraphics[width=1\linewidth]{HW5 images/pdfidentifiers.png}
\caption{Associated PDF identifiers}
\label{fig:pdfidentify}
\end{figure}
\section{Manual Quality and Controls}
\subsection{Common Troubleshooting Methods}
Throughout this exercise, there came many times where the builds failed (around 8 times). The main method of troubleshooting involved checking version statuses, updating and restarting file instances, and parsing of error messages to pinpoint.
+1111
View File
File diff suppressed because it is too large Load Diff
+18 -6
View File
@@ -2,13 +2,25 @@
\addcontentsline{toc}{chapter}{Document History}
\index{document history}
\begin{table}[H]
\caption{Document Update History\label{Table:DocumentHistory}}
\begin{tabularx}{\linewidth}{L{3.1cm}L{2.2cm}YL{2.0cm}}
\toprule \textbf{Date / Version} & \textbf{Author Initials} & \textbf{Change} & \textbf{Changed At}\\ \midrule
{\small
\begin{longtable}{L{2.4cm}L{1.3cm}p{\dimexpr\linewidth-2.4cm-1.3cm-1.9cm-8\tabcolsep\relax}L{1.9cm}}
\caption{Document Update History\label{Table:DocumentHistory}}\\
\toprule \textbf{Date / Version} & \textbf{Authors} & \textbf{Change} & \textbf{Changed At}\\ \midrule
\endfirsthead
\toprule \textbf{Date / Version} & \textbf{Authors} & \textbf{Change} & \textbf{Changed At}\\ \midrule
\endhead
November 13, 2026 / 1.7 (draft) & SK, KH & In progress: Secure Delivery and Rollback assignment. Added the trusted Jenkins delivery agent, locked dependencies and pinned base image, the Gitea container registry, staging and production proxy routes, image build and publish by digest, and Ansible deployment to staging with an idempotence check. Security gates, approval and promotion, v2 and recovery, and monitoring sections still to be completed. Updated the Hosts and Passwords tables and the Glossary. & \ChapterRef{SecureDelivery}, \ChapterRef{PWDHST} \\
October 29, 2026 / 1.6 & SK, KH & Completed the Introduction to SRE assignment: deployed Prometheus, Grafana OSS, Node Exporter, and Blackbox Exporter as four pinned, persistent containers on the existing Droplet; published authenticated Grafana at \texttt{metrics.ssw590-08.me}; built a six-panel dashboard; defined an availability SLI and SLO; configured and tested Grafana-managed alerts with a Discord contact point; and ran a controlled Jenkins outage with a blameless review. Updated the Hosts and Passwords tables and the Glossary. & \ChapterRef{SRE}, \ChapterRef{PWDHST} \\
October 23, 2026 / 1.5 & SK, KH & Completed the Continuous Integration with Jenkins assignment: deployed a persistent Jenkins LTS container behind HTTPS at \texttt{ci.ssw590-08.me} with firewall-restricted access; integrated Jenkins with the Scrap-Web Gitea repository through a dedicated integration account; added a pricing module, unit tests, and a versioned \texttt{Jenkinsfile}; protected \texttt{main} with a required Jenkins status check and one required approval; and demonstrated a failed, repaired, reviewed, and merged pull request. Updated the Hosts table (Jenkins host and ports) and the Passwords table (Jenkins administrator accounts and the Gitea integration token, hints only). & \ChapterRef{ContinuousIntegration}, \ChapterRef{PWDHST} \\
October 10, 2026 / 1.4 & SK, KH & Completed the related Gitea automation in LaTeX exercise and documented it in new chapter & \ChapterRef{AutomatedManualBuild} \\
October 2, 2026 / 1.3 & SK, KH & Completed the Gitea startup exercise and documented the process. Also, created the hosts and passwords tables to be used throughout the group assignments & \ChapterRef{JenkinsCI}, \ChapterRef{PWDHST} \\
September 24, 2026 / 1.2 & SK, KH& Completed the Digital Ocean Docker Deployment chapter; the class-based JavaScript refactor of the two-button website with its accompanying UML class diagram; the LaTeX Docker chapter ; and the Project Proposal chapter, addressing the two-tool comparison, dashboard, SWOT, and unique-contribution rubric criteria. & \ChapterRef{Digital Ocean}, \ChapterRef{ClassBasedJSRefactor}, \ChapterRef{Latex Docker}, \ChapterRef{ProjectProposal}\\
September 16, 2026 / 1.1 & SK, KH & Completed the Linux Commands assignment: environment setup with terminal printout figure and full solutions to Problem Set sections A--E & \ChapterRef{LinuxCommands} \\
\bottomrule
\end{tabularx}
\end{table}
\end{longtable}
}
+15
View File
@@ -3,6 +3,9 @@
\newacronym{cd}{CD}{continuous delivery or continuous deployment}
\newacronym{iac}{IaC}{infrastructure as code}
\newacronym{slo}{SLO}{service-level objective}
\newacronym{sli}{SLI}{service-level indicator}
\newacronym{sla}{SLA}{service-level agreement}
\newacronym{sre}{SRE}{site reliability engineering}
\newglossaryentry{automation}{name={automation},description={A repeatable, version-controlled procedure executed by software rather than undocumented manual steps}}
\newglossaryentry{deployment}{name={deployment},description={The controlled delivery of a versioned change to an environment}}
\newglossaryentry{evidence}{name={evidence},description={A retained record of an actual execution, observation, or review}}
@@ -11,3 +14,15 @@
\newglossaryentry{rollback}{name={rollback},description={A controlled return to a known acceptable version or state after a failed or harmful change}}
\newglossaryentry{runbook}{name={runbook},description={A documented operational procedure for a repeatable task or incident response}}
\newglossaryentry{synonyms}{name={synonyms},description={Equivalent terms used in this assignment; record preferred terms to avoid ambiguity in instructions and evidence}}
\newglossaryentry{pullrequest}{name={pull request},description={A proposed change from one branch into another, reviewed and checked before it is merged}}
\newglossaryentry{webhook}{name={webhook},description={An HTTP request that Gitea sends to another service, such as Jenkins, when a repository event occurs}}
\newglossaryentry{statuscheck}{name={status check},description={A named pass, fail, or pending result that a CI system attaches to a specific commit}}
\newglossaryentry{mergegate}{name={merge gate},description={A branch-protection rule that blocks a merge until required status checks pass and reviews are approved}}
\newglossaryentry{jenkinsfile}{name={\texttt{Jenkinsfile}},sort={Jenkinsfile},description={The version-controlled file that defines a Jenkins pipeline's stages and steps}}
\newglossaryentry{errorbudget}{name={error budget},description={The amount of failure an SLO allows over its window; for a 99\% target, 1\% of scheduled measurements}}
\newglossaryentry{probe}{name={probe},description={A synthetic request, here an HTTPS GET from Blackbox Exporter, that tests whether a service responds as expected}}
\newglossaryentry{contactpoint}{name={contact point},description={The Grafana destination, such as a Discord webhook or email address, that receives alert notifications}}
\newglossaryentry{idempotence}{name={idempotence},description={The property that running the same deployment again on an already-correct system changes nothing}}
\newglossaryentry{imagedigest}{name={image digest},description={The SHA-256 content hash that identifies one exact container image in a registry; unlike a tag, it cannot be moved to another image}}
\newglossaryentry{releaserecord}{name={release record},description={A file that ties one deployment to its image digest, source commit, expected behavior, environment, and build}}
\newglossaryentry{trustedagent}{name={trusted agent},description={A Jenkins build node that holds deployment credentials and therefore runs only reviewed code}}
+58 -3
View File
@@ -2,7 +2,7 @@
\ChapterLabel{PWDHST}
\section{Passwords}
\begin{longtable}{|p{3cm}|p{2.5cm}|p{4cm}|p{4cm}|}
\begin{longtable}{|>{\raggedright\arraybackslash}p{3.2cm}|>{\raggedright\arraybackslash}p{3.8cm}|>{\raggedright\arraybackslash}p{6.6cm}|}
\caption{Passwords and Credential Hints}
\label{tab:devops-passwords}\\
\hline
@@ -46,12 +46,43 @@ Caddy
& No login password configured\\
\hline
Jenkins
& samahk, kaylah7
& Administrator passwords set at Jenkins setup; stored hashed by Jenkins\\
\hline
Gitea (Jenkins integration)
& jenkins-ci
& Password set by the Gitea administrator; Jenkins uses a token stored only in credential \texttt{gitea-jenkins-ci}\\
\hline
Grafana
& admin
& Administrator password kept in \texttt{grafana.secrets.env} on the Droplet; the file is in \texttt{.gitignore} and not in Git\\
\hline
Discord webhook (Grafana contact point \texttt{team-alerts})
& N/A
& Webhook URL stored only in Grafana's database; re-created from the Discord channel's Integrations $\rightarrow$ Webhooks settings\\
\hline
Deployment account (Ansible)
& deploy
& No password; SSH key stored only in Jenkins credential \texttt{deploy-ssh}\\
\hline
Gitea container registry
& Push: Jenkins credential \texttt{gitea-registry-push}; pull: root on the Droplet
& Package-write and package-read tokens; never stored in Git, logs, or screenshots\\
\hline
Jenkins delivery agent
& delivery-agent
& Agent secret in a file on the Droplet beside \texttt{agent/compose.yaml}; not in Git\\
\end{longtable}
\section{Hosts}
\begin{longtable}{|p{3.2cm}|p{4.2cm}|p{3.2cm}|p{3.5cm}|}
\begin{longtable}{|>{\raggedright\arraybackslash}p{3.2cm}|>{\raggedright\arraybackslash}p{3.9cm}|>{\raggedright\arraybackslash}p{1.9cm}|>{\raggedright\arraybackslash}p{5.1cm}|}
\caption{Hosts and Services}
\label{tab:devops-hosts}\\
\hline
@@ -74,6 +105,30 @@ Gitea Git SSH & git.ssw590-08.me & 222 & Git repository SSH access \\
\hline
Gitea Container & gitea & 3000 & Internal Docker network web service \\
\hline
Caddy Container & caddy & 80, 443 & Reverse proxy and TLS certificate management \\
Caddy Container & caddy & 80, 443 & Reverse proxy and TLS certificate management for Gitea and Jenkins \\
\hline
Jenkins Web Interface & ci.ssw590-08.me & 443 & HTTPS access to Jenkins through Caddy \\
\hline
Jenkins Container & jenkins & 8080 & Internal Docker network web service; not published on the host \\
\hline
Jenkins Agent Port & jenkins & 50000 & Not published on the host and not used; the delivery agent connects over WebSocket through port 8080 on \texttt{gitea-net} \\
\hline
Grafana Web Interface & metrics.ssw590-08.me & 443 & HTTPS access to Grafana through Caddy \\
\hline
Grafana Container & grafana & 3000 & Internal Docker network web service (\texttt{gitea-net} and \texttt{monitoring}); not published on the host; state in volume \texttt{monitoring\_grafana\_data} \\
\hline
Prometheus Container & prometheus & 9090 & Private, \texttt{monitoring} network only; metrics storage and query API; state in volume \texttt{monitoring\_prometheus\_data} \\
\hline
Node Exporter Container & node-exporter & 9100 & Private, \texttt{monitoring} network only; whole-Droplet CPU, memory, and root-disk metrics \\
\hline
Blackbox Exporter Container & blackbox-exporter & 9115 & Private, \texttt{monitoring} network only; HTTPS probes of Gitea and Jenkins \\
\hline
Staging Application & staging.ssw590-08.me & 443 & HTTPS access to the staging pricing service through Caddy \\
\hline
Production Application & app.ssw590-08.me & 443 & HTTPS access to the production-like pricing service through Caddy \\
\hline
Pricing Containers & pricing-staging, pricing-production & 8000 & Private, \texttt{gitea-net} only; Gunicorn; not published on the host; Compose projects under \texttt{/opt/startup/pricing-\{staging,production\}}; no data volume \\
\hline
Jenkins Delivery Agent & jenkins-agent & None & Container on \texttt{gitea-net}; runs Docker builds and Ansible; mounts the host Docker socket; state in volume \texttt{agent\_home} \\
\hline
\end{longtable}
+136
View File
@@ -4,3 +4,139 @@
publisher = {IT Revolution Press},
year = {2018}
}
@misc{JenkinsPipeline,
author = {{Jenkins Project}},
title = {{Pipeline}},
howpublished = {Jenkins User Documentation},
year = {2026},
url = {https://www.jenkins.io/doc/book/pipeline/},
note = {Accessed: Oct. 24, 2026}
}
@misc{JenkinsGiteaPlugin,
author = {{Jenkins Project}},
title = {{Gitea Plugin}},
howpublished = {Jenkins Plugins Index},
year = {2026},
url = {https://plugins.jenkins.io/gitea/},
note = {Accessed: Oct. 24, 2026}
}
@misc{JenkinsSecurity,
author = {{Jenkins Project}},
title = {{Securing Jenkins}},
howpublished = {Jenkins User Documentation},
year = {2026},
url = {https://www.jenkins.io/doc/book/security/},
note = {Accessed: Oct. 24, 2026}
}
@misc{GiteaProtectedBranches,
author = {{Gitea Authors}},
title = {{Protected Branches}},
howpublished = {Gitea Documentation},
year = {2026},
url = {https://docs.gitea.com/usage/access-control/protected-branches},
note = {Accessed: Oct. 24, 2026}
}
@book{SREWorkbook,
author = {Beyer, Betsy and Murphy, Niall Richard and Rensin, David K. and Kawahara, Kent and Thorne, Stephen},
title = {{The Site Reliability Workbook: Practical Ways to Implement SRE}},
publisher = {O'Reilly Media},
year = {2018},
note = {Chapter 2, ``Implementing SLOs.'' Available: https://sre.google/workbook/implementing-slos/}
}
@misc{PrometheusDocs,
author = {{Prometheus Authors}},
title = {{Prometheus Documentation}},
year = {2026},
url = {https://prometheus.io/docs/},
note = {Accessed: Oct. 28, 2026}
}
@misc{GrafanaDocs,
author = {{Grafana Labs}},
title = {{Run Grafana Docker Image}},
year = {2026},
url = {https://grafana.com/docs/grafana/latest/setup-grafana/installation/docker/},
note = {Accessed: Oct. 28, 2026}
}
@misc{GrafanaAlerting,
author = {{Grafana Labs}},
title = {{Grafana Alerting}},
year = {2026},
url = {https://grafana.com/docs/grafana/latest/alerting/},
note = {Accessed: Oct. 28, 2026}
}
@misc{NodeExporter,
author = {{Prometheus Authors}},
title = {{Node Exporter}},
year = {2026},
url = {https://github.com/prometheus/node_exporter},
note = {Accessed: Oct. 28, 2026}
}
@misc{BlackboxExporter,
author = {{Prometheus Authors}},
title = {{Blackbox Exporter}},
year = {2026},
url = {https://github.com/prometheus/blackbox_exporter},
note = {Accessed: Oct. 28, 2026}
}
@misc{DOSMTP,
author = {{DigitalOcean}},
title = {{Why Is SMTP Blocked?}},
year = {2026},
url = {https://docs.digitalocean.com/support/why-is-smtp-blocked/},
note = {Accessed: Oct. 28, 2026}
}
@misc{AnsibleCompose,
author = {{Ansible Project}},
title = {{community.docker.docker\_compose\_v2 module}},
howpublished = {Ansible Documentation},
year = {2026},
url = {https://docs.ansible.com/ansible/latest/collections/community/docker/docker_compose_v2_module.html},
note = {Accessed: Nov. 13, 2026}
}
@misc{AnsibleInstall,
author = {{Ansible Project}},
title = {{Installing Ansible}},
howpublished = {Ansible Documentation},
year = {2026},
url = {https://docs.ansible.com/ansible/latest/installation_guide/intro_installation.html},
note = {Accessed: Nov. 13, 2026}
}
@misc{GiteaContainerRegistry,
author = {{Gitea}},
title = {{Container Registry}},
howpublished = {Gitea Documentation},
year = {2026},
url = {https://docs.gitea.com/usage/packages/container},
note = {Accessed: Nov. 13, 2026}
}
@misc{DockerPullDigest,
author = {{Docker Inc.}},
title = {{docker image pull: Pull an image by digest}},
howpublished = {Docker Documentation},
year = {2026},
url = {https://docs.docker.com/reference/cli/docker/image/pull/},
note = {Accessed: Nov. 13, 2026}
}
@misc{JenkinsAgents,
author = {{Jenkins Project}},
title = {{Using Jenkins agents}},
howpublished = {Jenkins User Documentation},
year = {2026},
url = {https://www.jenkins.io/doc/book/using/using-agents/},
note = {Accessed: Nov. 13, 2026}
}
+1500
View File
File diff suppressed because it is too large Load Diff
+445
View File
@@ -0,0 +1,445 @@
\chapter{Secure Delivery and Rollback}
\ChapterLabel{SecureDelivery}
\index{continuous delivery}
\index{Ansible}
\index{rollback}
\sloppy
% Red marker for values still to be filled in from the team's own outputs.
% Search this file for \FillIn before submitting; none should remain.
\providecommand{\FillIn}[1]{\textcolor{devopsRed}{\textbf{[TO FILL: #1]}}}
% Figure helper: shows a labelled box until the screenshot file exists.
\providecommand{\delfig}[4]{%
\begin{figure}[H]\centering
\IfFileExists{HW8 images/#1}{\includegraphics[width=#2\linewidth]{HW8 images/#1}}%
{\fbox{\parbox{0.8\linewidth}{\centering\vspace{1em}\textit{[Screenshot needed: HW8 images/#1]}\vspace{1em}}}}
\caption{#3}\label{#4}\end{figure}}
This chapter closes the delivery loop for the team's startup. The Startup
Pricing Service, a small stateless Flask application served by Gunicorn, is
built once into a container image, published to the Gitea container registry,
and deployed by Ansible to a staging environment on the existing Droplet behind
the existing Caddy proxy. The same image digest is then approved and promoted
to a production-like environment, a second release (v2) is delivered, and two
recovery cases are exercised.
The existing Gitea, Jenkins, Caddy, and monitoring containers from earlier
chapters are reused unchanged. Nothing was reinstalled, and no Kubernetes,
Argo CD, cAdvisor, or database was added. Staging and production share one
Droplet, so they share a failure domain and its CPU, memory, and disk: separate
Compose projects give configuration separation, not high availability.
\textbf{Division of work.} Sections~\ref{sec:del-baseline}--\ref{sec:del-build}
and Section~\ref{sec:del-ansible} were carried out by \texttt{samahk13}, who
holds the Gitea administrator, Jenkins, DNS, and Droplet SSH access.
Sections~\ref{sec:del-security} and~\ref{sec:del-promote}--\ref{sec:del-ops}
were carried out by \texttt{kholmes}.
\section{Deployment Architecture}
\label{sec:del-architecture}
\begin{itemize}
\item \textbf{Source and images:} the existing Gitea server
(\texttt{git.ssw590-08.me}) holds the repository and, with its package
registry enabled~\cite{GiteaContainerRegistry}, the application images under
\texttt{git.ssw590-08.me/ssw-590-08/pricing}.
\item \textbf{Orchestration:} the existing Jenkins controller schedules the
pipeline. Delivery stages run on a new \gls{trustedagent} container~\cite{JenkinsAgents},
\texttt{jenkins-agent} (node \texttt{delivery-agent}, label
\texttt{delivery}), on the same Droplet. Ansible runs inside this agent, not
on the controller and not in the application container.
\item \textbf{Target:} Ansible connects over SSH to the Droplet host as the
dedicated \texttt{deploy} account and applies a separate Compose project
for each environment under \texttt{/opt/startup/pricing-staging} and
\texttt{/opt/startup/pricing-production}.
\item \textbf{Traffic:} browser $\rightarrow$ Caddy (HTTPS 443)
$\rightarrow$ \texttt{pricing-staging:8000} or
\texttt{pricing-production:8000} over the private \texttt{gitea-net}
network. No application port is published on the host.
\item \textbf{Monitoring:} the Chapter~\ref{Chapter:SRE} stack (Prometheus,
Grafana, Blackbox Exporter, Node Exporter) is reused; see
Section~\ref{sec:del-ops}.
\end{itemize}
\FillIn{team deployment diagram (HW8 images/delivery-architecture.png) showing
actual hosts, container boundaries, volumes and bind mounts, Ansible SSH, both
environments, proxy, and monitoring}
\section{Prepare the Repository and Establish a Baseline}
\label{sec:del-baseline}
\textbf{Issue and branch.} The work is tracked in Gitea issue~\#24 and developed
on branch \texttt{feature/issue-24-delivery} of the existing
\texttt{SSW-590-08/Scrap-Web} repository. The supplied v1 starter was copied into
\texttt{pricing/}, the Ansible files into \texttt{ansible/}, and release-record
documentation into \texttt{releases/}.
\textbf{Locked dependencies.} The starter's \texttt{requirements.txt} gives
version ranges (\texttt{Flask>=3.1,<3.2}, \texttt{gunicorn>=23,<24}). These
ranges were moved to \texttt{pricing/requirements.in}, and a lockfile with exact
versions and SHA-256 hashes for every direct and transitive dependency was
generated with:
\begin{minted}[breaklines,breakanywhere]{text}
uv pip compile requirements.in --universal --python-version 3.13 --generate-hashes -o requirements.txt
\end{minted}
\begin{tabularx}{\linewidth}{L{3.2cm}L{2.4cm}Y}
\toprule
\textbf{Package} & \textbf{Version} & \textbf{Role}\\ \midrule
flask & 3.1.3 & Direct: web framework\\
gunicorn & 23.0.0 & Direct: application server\\
werkzeug & 3.1.9 & Transitive (Flask)\\
jinja2 & 3.1.6 & Transitive (Flask)\\
markupsafe & 3.0.4 & Transitive (Jinja2, Werkzeug)\\
itsdangerous & 2.2.0 & Transitive (Flask)\\
click & 8.5.1 & Transitive (Flask)\\
blinker & 1.9.0 & Transitive (Flask)\\
packaging & 26.3 & Transitive (Gunicorn)\\
\bottomrule
\end{tabularx}
\medskip
Both the pipeline's test environment and the image build install with
\texttt{pip install --require-hashes -r requirements.txt}, so a changed or
unlisted package fails the install instead of being used silently. When
dependencies are updated, the lockfile is regenerated and the image is rebuilt
and rescanned. No claim is made that these versions are free of
vulnerabilities; that is the job of the security gates in
Section~\ref{sec:del-security}.
\textbf{Base image.} The Dockerfile pins \texttt{python:3.13-slim} by digest for
\texttt{linux/amd64}, the Droplet's architecture:
\texttt{python:3.13-slim@sha256:e48f59cdba69a3cbd9ed2cf0f348d90d\allowbreak 45a8d350d98134cf1070bc106ee9ed90}. Python 3.13 is
supported by the selected \texttt{ansible-core} release.
\textbf{Baseline and controlled failure.} The v1 unit tests
(\texttt{test\_price}, \texttt{test\_invalid\_quantity},
\texttt{test\_release\_identity}) run in the pipeline's \emph{Unit tests} stage
inside a fresh virtual environment:
\begin{minted}[breaklines,breakanywhere]{text}
python3 -m venv .venv
.venv/bin/pip install -q --require-hashes -r requirements.txt
.venv/bin/python -m py_compile app.py test_app.py
.venv/bin/python -m unittest -v
\end{minted}
\begin{itemize}
\item \textbf{Controlled failure:} Jenkins run
\texttt{feature/issue-24-delivery} \href{https://ci.ssw590-08.me/job/Scrap-Web/job/feature\%252Fissue-24-delivery/6/}{\#6}, started by a push at 11:19 PM EST on
November 12, 2026, ran on \texttt{delivery-agent}. The deliberately
broken test \texttt{test\_price} failed, so the \emph{Unit tests} stage
failed after 6 seconds and every later delivery stage (security scans,
build, publish, deploy) was skipped
(Figure~\ref{fig:del-test-fail}). A failing test therefore prevents
delivery. The test's expected total was changed from 30 to 31, so it
failed with \texttt{AssertionError: 30 != 31} while the application itself
was unchanged.
\item \textbf{Passing baseline and restore:} run \href{https://ci.ssw590-08.me/job/Scrap-Web/job/feature\%252Fissue-24-delivery/5/}{\#5} (11:13 PM EST), before the
controlled failure, passed all three tests. The test was then restored to
expect 30, and run \href{https://ci.ssw590-08.me/job/Scrap-Web/job/feature\%252Fissue-24-delivery/7/}{\#7} (11:20 PM EST) passed all three tests again. The same tests also
pass locally in a fresh virtual environment (\texttt{Ran 3 tests in
0.085s, OK}).
\end{itemize}
All times in this chapter are Eastern Standard Time (EST), as displayed by Jenkins.
\delfig{build6-unit-test-fail.png}{1.0}{November 12, 2026, 11:19 PM EST ---
Jenkins \texttt{feature/issue-24-delivery} run \#6 on \texttt{delivery-agent}:
\texttt{test\_price} fails, the Unit tests stage stops the run, and the build,
publish, and deploy stages are skipped.}{fig:del-test-fail}
\section{Prepare the Trusted Agent and Target}
\label{sec:del-agent}
\subsection{Trusted Delivery Agent}
The Chapter~\ref{Chapter:ContinuousIntegration} pipeline ran only on the
controller's built-in node, which has no Docker or Ansible. A dedicated agent
was added rather than enabling deployment jobs on the controller. It is built
from \texttt{agent/Dockerfile} and started by \texttt{agent/compose.yaml}, both
in Gitea, so recreating the container keeps every tool:
\begin{itemize}
\item \textbf{Base:} \texttt{jenkins/inbound-agent:latest-jdk21}.
\item \textbf{Tools:} Python 3 with \texttt{venv}; Docker CLI and the
\texttt{buildx} plugin (client only; the daemon is the host's); Trivy;
\texttt{pip-audit} in \texttt{/opt/tools-venv}; and \texttt{ansible-core}
with the \texttt{community.docker} collection~\cite{AnsibleInstall} in
\texttt{/opt/ansible-venv}. Every Jenkins deployment step puts
\texttt{/opt/ansible-venv/bin} first on its \texttt{PATH}.
\item \textbf{Connection:} the agent connects to the controller at
\texttt{http://jenkins:8080/} over WebSocket on the internal
\texttt{gitea-net} network, so no new port is published. Its secret is
read from a file (\texttt{-secret @/run/secrets/jenkins-agent-secret}) that
is not in Git, so it does not appear in the process list or
\texttt{docker inspect}.
\item \textbf{Docker access:} the host Docker socket is mounted so the agent
can build and push images. This is effectively root on the Droplet, so only
trusted-branch delivery stages may run on this agent
(Section~\ref{sec:del-trust}).
\end{itemize}
Installed versions, printed by \texttt{agent/versions.sh} inside the agent:
\begin{tabularx}{\linewidth}{L{3.6cm}Y}
\toprule
\textbf{Tool} & \textbf{Version}\\ \midrule
Java & OpenJDK 21.0.13 LTS\\
Python & 3.13.5\\
Docker client / server & 29.9.3 / 29.8.2\\
Docker buildx & v0.38.2\\
Trivy & 0.76.2\\
pip-audit & 2.10.1\\
ansible-core & 2.22.0\\
community.docker & 5.4.0\\
Agent OS & Debian GNU/Linux 13 (trixie), x86\_64\\
\bottomrule
\end{tabularx}
\medskip
The agent image \texttt{ssw590/jenkins-delivery-agent:1} has image ID
\texttt{sha256:e8e72e1c89d3\allowbreak 72fff4a920b581b1a0daa7c885164ff6668dfcc2e22f85e6aa83}.
\subsection{Target Prerequisites}
The target is the same Droplet (\texttt{147.182.179.191}). Before the first
playbook run its prerequisites were verified:
\begin{tabularx}{\linewidth}{L{4.2cm}Y}
\toprule
\textbf{Requirement} & \textbf{Observed}\\ \midrule
Python 3 & 3.12.3\\
Docker Engine & 29.8.2\\
Compose plugin ($\geq$ 2.18) & v5.5.1 (meets the minimum)\\
\bottomrule
\end{tabularx}
\subsection{Deployment Account and Credentials}
\label{sec:del-trust}
\begin{itemize}
\item \textbf{Deployment account:} a dedicated \texttt{deploy} user on the
Droplet, used only by Ansible. Its private key is stored only in the Jenkins
credential \texttt{deploy-ssh}. It is an Ed25519 key with comment
\texttt{jenkins-deploy} and fingerprint
\texttt{SHA256:jy/MveXnRjD+HOLWi6fuR+WNGA3gpkS0kudqPi/prJY}. The Droplet's
Ed25519 host key was read on the Droplet itself over the existing
administrator SSH session
(\texttt{SHA256:zL7qulFmdVDZQ3oBGvXWyWnKjNWUpPh1BDbfAOC+nbk}). The key
scanned from \texttt{147.182.179.191} had the same fingerprint, and it was
then pinned in the agent's \texttt{known\_hosts}. Its non-interactive
\texttt{sudo} rule, in \texttt{/etc/sudoers.d/}, is
\texttt{deploy ALL=(root) NOPASSWD: ALL}. This scope is deliberately broad:
the playbook uses \texttt{become: true} to create directories under
\texttt{/opt/startup} and to drive Docker Compose as \texttt{root}, and
Docker access is already equivalent to root on the host. The account
therefore effectively administers the Droplet. A separate account limits
who holds the key and makes its use auditable, but it does not remove that
risk, so the key is held only by Jenkins and used only by trusted-branch
delivery stages.
\item \textbf{Registry access:} the Gitea package registry was enabled
(\texttt{[packages] ENABLED = true}). A package-\emph{write} token is held
only in the Jenkins credential \texttt{gitea-registry-push} and used by the
\emph{Publish} stage through \texttt{docker login --password-stdin}. A
package-\emph{read} token is logged in for \texttt{root} on the Droplet,
the account that runs Docker under Ansible escalation. Tokens are never in
Git, command arguments, screenshots, or pipeline logs.
\item \textbf{Trust boundary:} every branch and pull request runs only the
Chapter~\ref{Chapter:ContinuousIntegration} checks on the controller, with
no credentials and no Docker socket. The \emph{Delivery} stages run only for
the trusted branch pattern \texttt{TRUSTED\_BRANCH}. During development it
also allowed \texttt{feature/issue-24-delivery}; for the assessed runs it is
\texttt{main} only, so only reviewed code can build, publish, or deploy.
\FillIn{confirm the change to main only and its commit} No Docker daemon API is published to the Internet.
\end{itemize}
\section{Connect the Application to the Existing Proxy}
\label{sec:del-proxy}
\begin{itemize}
\item \textbf{DNS:} \texttt{staging.ssw590-08.me} and
\texttt{app.ssw590-08.me} point to the Droplet (\texttt{147.182.179.191}).
\item \textbf{Proxy network:} Caddy runs in a container on the existing
\texttt{gitea-net} network. The Compose template joins each pricing
container to that external network with a distinct alias
(\texttt{pricing-staging}, \texttt{pricing-production}) and publishes no
host port, so port 8000 is reachable only from containers on
\texttt{gitea-net}.
\item \textbf{Routes:} added to the existing \texttt{/root/gitea/Caddyfile},
keeping the Gitea, Jenkins, and Grafana routes. The file was validated and
Caddy reloaded, and Caddy obtained valid TLS certificates for both
hostnames automatically.
\end{itemize}
\begin{minted}[breaklines,breakanywhere]{text}
staging.ssw590-08.me {
reverse_proxy pricing-staging:8000
}
app.ssw590-08.me {
reverse_proxy pricing-production:8000
}
\end{minted}
The firewall policy is unchanged: public HTTPS (443, and 80 for redirects),
restricted SSH, and no public infrastructure or metrics ports.
\textbf{Accepted simplification.} Sharing \texttt{gitea-net} means a
compromised pricing container could reach Gitea, Jenkins, Grafana, and the
agent on that network directly, not only through Caddy. A separate proxy-only
network per application would give stronger lateral isolation.
\section{Build Once and Record an Immutable Release}
\label{sec:del-build}
The \texttt{Jenkinsfile} keeps the Chapter~\ref{Chapter:ContinuousIntegration}
checks and adds a \emph{Delivery} block on the \texttt{delivery} agent with
these stages: Checkout, Unit tests, Security scan: source, Build image, Security
scan: image, Publish, Deploy staging, Staging idempotence, and Approve and deploy
production. The pipeline sets \texttt{disableConcurrentBuilds()}, so two runs
cannot change staging or production at the same time.
The image is built once per source commit, with the commit baked in at build
time. The \emph{Publish} stage pushes it, deletes the local copy, and pulls it
back, so the recorded \gls{imagedigest} is the registry's and not a local image ID~\cite{DockerPullDigest}:
\begin{minted}[breaklines,breakanywhere]{bash}
docker build --build-arg APP_COMMIT="$APP_COMMIT" -t "$IMAGE:$APP_COMMIT" .
printf '%s' "$REG_TOKEN" | docker login "$REGISTRY" -u "$REG_USER" --password-stdin
docker push "$IMAGE:$APP_COMMIT"
docker image rm "$IMAGE:$APP_COMMIT"
docker pull "$IMAGE:$APP_COMMIT"
docker logout "$REGISTRY"
docker image inspect "$IMAGE:$APP_COMMIT" --format '{{index .RepoDigests 0}}'
\end{minted}
The stage archives \texttt{image-digest.txt} and \texttt{build-record.txt}
(source commit, tag, digest, and Jenkins build URL) as fingerprinted build
artifacts. The image runs Gunicorn as the non-root user \texttt{10001}, and the
Compose template drops all capabilities and makes the root filesystem read-only
with a \texttt{tmpfs} for \texttt{/tmp}.
\begin{tabularx}{\linewidth}{L{3.2cm}Y}
\toprule
\textbf{Release} & \textbf{v1}\\ \midrule
Source commit & \texttt{2a35f97071c95b23bccb8c973099f2991c998599}\\
Jenkins build & \texttt{feature/issue-24-delivery} \href{https://ci.ssw590-08.me/job/Scrap-Web/job/feature\%252Fissue-24-delivery/8/}{\#8}\\
Image digest & \texttt{git.ssw590-08.me/ssw-590-08/\allowbreak pricing@sha256:\allowbreak ce91d0552da2a4580557ec65aedec04b\allowbreak 278fe918df1f02b23c971ca45cc3d97c}\\
Published & November 12, 2026, 11:51 PM EST\\
\bottomrule
\end{tabularx}
\delfig{publish-digest.png}{1.0}{November 12, 2026, run \#8 --- Jenkins Publish
stage: the v1 image is pushed, the local copy deleted and pulled back from the
registry, and its registry digest recorded. The registry token is masked and
never printed.}{fig:del-publish}
\section{Apply Proportionate Security Gates}
\label{sec:del-security}
\FillIn{kholmes: scan policy, tools and database versions, source and image
scan results, blocked synthetic fixture run, fix and rerun
(\texttt{security/scan.sh})}
\section{Deploy v1 with Ansible and Prove Idempotence}
\label{sec:del-ansible}
\textbf{Inputs.} \texttt{ansible/inventory.ini} names one host,
\texttt{startup}, at \texttt{147.182.179.191} with user \texttt{deploy}; it
contains no secrets. \texttt{ansible/deploy.yml} and
\texttt{ansible/templates/compose.yaml.j2} are the supplied playbook and
template with every placeholder replaced.
\textbf{Release record.} The \emph{Deploy staging} stage writes the
\gls{releaserecord} from the build it belongs to, so the digest and commit cannot be
mistyped. The expected version and total are read from the application source
(\texttt{VERSION} and \texttt{3 $\times$ UNIT\_PRICE}), not from configuration.
The record is archived with the build. For v1 it contains:
\begin{minted}[breaklines,breakanywhere]{yaml}
target_env: staging
release_image: git.ssw590-08.me/ssw-590-08/pricing@sha256:ce91d0552da2a4580557ec65aedec04b278fe918df1f02b23c971ca45cc3d97c
expected_version: v1
expected_commit: 2a35f97071c95b23bccb8c973099f2991c998599
expected_total: 30
public_url: https://staging.ssw590-08.me
proxy_network: gitea-net
\end{minted}
The record holds metadata only, never credentials.
\textbf{Deployment.} The stage runs a syntax check and then the deployment:
\begin{minted}[breaklines,breakanywhere]{bash}
ansible-playbook -i ansible/inventory.ini ansible/deploy.yml --syntax-check
ansible-playbook -i ansible/inventory.ini ansible/deploy.yml \
--private-key "$DEPLOY_KEY" -e @release-v1-staging.yml
\end{minted}
The playbook validates its inputs, creates \texttt{/opt/startup/pricing-staging},
renders the Compose file, starts the selected digest without rebuilding~\cite{AnsibleCompose}, waits
for the container health check, and then checks
\url{https://staging.ssw590-08.me} for \texttt{/health}, version \texttt{v1},
the exact source commit, and a total of USD~30 for \texttt{quantity=3}. It
fails the run if any check fails; it does not roll back on its own.
\textbf{\Gls{idempotence}.} The \emph{Staging idempotence} stage runs exactly the
same command again and fails the build unless the recap shows
\texttt{changed=0 unreachable=0 failed=0}:
\begin{tabularx}{\linewidth}{L{2.6cm}Y}
\toprule
\textbf{Run} & \textbf{PLAY RECAP for \texttt{startup}}\\ \midrule
First & \texttt{ok=9 changed=3 unreachable=0 failed=0 skipped=0}\\
Second & \texttt{ok=9 changed=0 unreachable=0 failed=0 skipped=0}\\
\bottomrule
\end{tabularx}
\medskip
Jenkins run \href{https://ci.ssw590-08.me/job/Scrap-Web/job/feature\%252Fissue-24-delivery/8/}{\#8} (November 12, 2026, 11:51 PM EST): the first run created the environment and started the
container (\texttt{changed=3}); the identical second run changed nothing, and the
stage's check matched the recap line
\texttt{startup : ok=9 changed=0 unreachable=0 failed=0}. In the second run every
task reported \texttt{ok}, including the public HTTPS health, release-identity,
and price checks (\texttt{"msg": "All assertions passed"}).
\delfig{staging-idempotence.png}{1.0}{November 12, 2026, run \#8 --- Jenkins
Staging idempotence stage: the second, unchanged run passes every check and
reports \texttt{changed=0}.}{fig:del-idempotence}
\delfig{staging-check.png}{1.0}{November 13, 2026 --- staging, v1:
\url{https://staging.ssw590-08.me/} returns version \texttt{v1} and commit
\texttt{2a35f97}, and \texttt{/price?quantity=3} returns a total of USD 30.}{fig:del-staging}
\section{Approve and Promote the Same Image}
\label{sec:del-promote}
\FillIn{kholmes: restricted Jenkins input step with timeout, approver and
decision, v1-production record with the same digest, production smoke tests}
\section{Release v2 and Exercise Two Recovery Cases}
\label{sec:del-v2}
\FillIn{kholmes: v2 release in both environments, healthy rollback of
production to v1, failed staging deployment (Gunicorn on 8001) and recovery,
timeline and measured interruption, state-compatibility discussion}
\section{Reuse Monitoring and Document Operations}
\label{sec:del-ops}
\FillIn{kholmes: production /health Blackbox probe and Grafana panel, release
and rollback timestamps correlated with monitoring, runbooks, approvers,
resource use, cleanup plan}
\section{Traceability}
\label{sec:del-trace}
\begin{tabularx}{\linewidth}{L{3.4cm}YY}
\toprule
\textbf{Item} & \textbf{v1} & \textbf{v2}\\ \midrule
Source commit & \texttt{2a35f97} & \FillIn{}\\
Configuration commit & \FillIn{} & \FillIn{}\\
Image digest & \texttt{sha256:ce91d055\ldots} & \FillIn{}\\
Jenkins build & \href{https://ci.ssw590-08.me/job/Scrap-Web/job/feature\%252Fissue-24-delivery/8/}{\#8} (staging) & \FillIn{}\\
Scan result & \FillIn{} & \FillIn{}\\
Staging result & Passed: health, v1, commit, total 30; rerun \texttt{changed=0} & \FillIn{}\\
Approver and time & \FillIn{} & \FillIn{}\\
Production result & \FillIn{} & \FillIn{}\\
\bottomrule
\end{tabularx}
\fussy
Binary file not shown.

After

Width:  |  Height:  |  Size: 274 KiB

+49
View File
@@ -0,0 +1,49 @@
digraph G {
graph [rankdir=TB, fontname="DejaVu Sans", fontsize=20, labelloc=t, pad=0.2, nodesep=0.3, ranksep=0.5, newrank=true,
label="Gitea, Jenkins, and Monitoring on One Droplet (147.182.179.191)"];
node [fontname="DejaVu Sans", fontsize=14, shape=box, style="rounded,filled", color="#44546a", margin="0.12,0.07"];
edge [fontname="DejaVu Sans", fontsize=12, color="#44546a"];
browser [label="Browser (HTTPS)", shape=component, style=filled, fillcolor="#e8f0fb"];
discord [label="Discord\nwebhook, HTTPS 443", style="rounded,filled,dashed", fillcolor="#fdeee6"];
subgraph cluster_droplet {
label="Droplet"; fontsize=16; color="#6c7f99"; style="rounded"; margin=14;
caddy [label="Caddy\n80 / 443, TLS", fillcolor="#fff3d6"];
subgraph cluster_giteanet {
label="network: gitea-net (existing)"; fontsize=14; style="rounded,dashed"; color="#6c7f99"; margin=10;
gitea [label="Gitea 1.26.4\n:3000", fillcolor="#e6f4e6"];
jenkins [label="Jenkins\n:8080", fillcolor="#efe8fb"];
grafana [label="Grafana 13.2.5\n:3000, no host port", fillcolor="#dbe9fb"];
}
subgraph cluster_mon {
label="network: monitoring (new, private)"; fontsize=14; style="rounded,dashed"; color="#6c7f99"; margin=10;
prom [label="Prometheus v3.13.5\n:9090, 7 d / 5 GiB", fillcolor="#dbe9fb"];
nexp [label="Node Exporter v1.12.1\n:9100, read-only host root", fillcolor="#dbe9fb"];
bbx [label="Blackbox Exporter v0.29.0\n:9115, module http_2xx", fillcolor="#dbe9fb"];
}
vgraf [label="volume\ngrafana_data", shape=cylinder, style=filled, fillcolor="#f2f2f2"];
vprom [label="volume\nprometheus_data", shape=cylinder, style=filled, fillcolor="#f2f2f2"];
}
browser -> caddy [label="HTTPS 443"];
caddy -> gitea [label="git. :3000"];
caddy -> jenkins [label="ci. :8080"];
caddy -> grafana [label="metrics. :3000"];
gitea -> jenkins [label="webhook", style=dashed];
grafana -> prom [label="queries"];
prom -> nexp [label="scrape 30 s"];
prom -> bbx [label="scrape 30 s"];
bbx -> caddy [label="HTTPS probes via\npublic hostnames", style=dashed, constraint=false];
grafana -> discord [label="alerts", style=dashed];
grafana -> vgraf [dir=none, style=dotted];
prom -> vprom [dir=none, style=dotted];
{rank=same; gitea; jenkins; grafana; discord}
{rank=same; prom; nexp; bbx}
{rank=same; vgraf; vprom}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 188 KiB

+5
View File
@@ -0,0 +1,5 @@
# Pinned image versions only. No passwords in this file.
PROMETHEUS_TAG=v3.13.5
GRAFANA_TAG=13.2.5
NODE_EXPORTER_TAG=v1.12.1
BLACKBOX_TAG=v0.29.0
+2
View File
@@ -0,0 +1,2 @@
# Secrets stay on the Droplet only
grafana.secrets.env
+65
View File
@@ -0,0 +1,65 @@
# SSW 590 Monitoring Runbook
Dashboard: https://metrics.ssw590-08.me/d/ssw590-sre
Contact point: `team-alerts` (email). Times are America/New_York.
---
## ServiceUnavailable – Gitea or Jenkins HTTPS probe failing
**Owner:** samahk13 (primary), kholmes (backup)
**Severity:** critical
**Fires when:** `probe_success{job="https"}` is 0 for an instance for at least 1 minute,
or the probe series is missing (no data) / the query errors.
### 1. Acknowledge
Reply to the alert email (or post in the team chat) with "ack" and your name, and
note the time. This is the acknowledgement time in the incident timeline.
### 2. Is it the service or the monitoring?
- Open the dashboard. Check the **Scrape health (up)** row.
- `blackbox` or `https` shows DOWN / no data → the **monitoring** is broken,
not necessarily the service. Go to step 5.
- `up` is 1 but panel 4 or 5 shows DOWN → the probed request failed. Continue.
- Open the URL in a browser:
- Gitea: https://git.ssw590-08.me/user/login
- Jenkins: https://ci.ssw590-08.me/login
### 3. Check the container (SSH to the Droplet as root)
```
docker ps -a --format 'table {{.Names}}\t{{.Status}}'
docker logs --tail=50 jenkins # or: gitea
docker logs --tail=50 caddy # proxy / TLS problems
```
### 4. Restore
- Container stopped/exited:
```
docker start jenkins # or: docker start gitea
```
- Container running but unhealthy: `docker restart jenkins`
- Certificate/proxy error: check `docker logs caddy`; validate with
`docker exec caddy caddy validate --config /etc/caddy/Caddyfile`.
- **Never** use `docker compose down -v` (deletes data volumes).
Wait for the next probes (~30–60 s). The alert resolves when `probe_success` is 1
again; confirm the "Resolved" email arrives.
### 5. Monitoring itself is failing (no data / error)
```
cd /root/Scrap-Web/monitoring
docker compose ps
docker compose logs --tail=50 prometheus blackbox-exporter
docker compose start prometheus blackbox-exporter
```
### 6. After recovery
- Jenkins: run **Build Now** on `main` and confirm it passes.
- Gitea: confirm the web login and that Jenkins can still post commit statuses.
- Record the timeline in the incident issue.
---
## HostDiskLow – root filesystem below 15 % free
**Owner:** kholmes — *(partner to complete)*
+12
View File
@@ -0,0 +1,12 @@
#!/bin/sh
# Step 1 baseline - run on the Droplet BEFORE starting the monitoring stack.
# Output contains no secrets; paste it into the Gitea issue.
echo "== date"; date -Is
echo "== OS"; cat /etc/os-release | head -4; uname -r
echo "== CPU"; nproc; grep -m1 "model name" /proc/cpuinfo; uname -m
echo "== memory (bytes)"; free -b
echo "== root disk"; df -B1 /; df -h /
echo "== docker"; docker version --format '{{.Server.Version}}'; docker compose version
echo "== containers"; docker ps --format 'table {{.Names}}\t{{.Image}}\t{{.Status}}'
echo "== container usage"; docker stats --no-stream --format 'table {{.Name}}\t{{.CPUPerc}}\t{{.MemUsage}}'
echo "== load"; uptime
+12
View File
@@ -0,0 +1,12 @@
modules:
http_2xx:
prober: http
timeout: 10s
http:
method: GET
preferred_ip_protocol: ip4
valid_status_codes: [] # empty = any 2xx is success
follow_redirects: true
fail_if_not_ssl: true
tls_config:
insecure_skip_verify: false
+67
View File
@@ -0,0 +1,67 @@
# SSW 590 - Monitoring stack (Prometheus, Grafana OSS, Node Exporter, Blackbox Exporter)
# Only Grafana joins gitea-net so the existing Caddy container can proxy it.
# No host ports are published; Prometheus and the exporters stay on the private network.
services:
prometheus:
image: prom/prometheus:${PROMETHEUS_TAG:?choose a release}
container_name: prometheus
restart: unless-stopped
command:
- --config.file=/etc/prometheus/prometheus.yml
- --storage.tsdb.path=/prometheus
- --storage.tsdb.retention.time=7d
- --storage.tsdb.retention.size=5GB
volumes:
- ./prometheus/prometheus.yml:/etc/prometheus/prometheus.yml:ro
- prometheus_data:/prometheus
networks: [monitoring]
grafana:
image: grafana/grafana:${GRAFANA_TAG:?choose a release}
container_name: grafana
restart: unless-stopped
depends_on: [prometheus]
env_file: [grafana.secrets.env]
environment:
GF_SERVER_ROOT_URL: "https://metrics.ssw590-08.me/"
GF_SERVER_DOMAIN: "metrics.ssw590-08.me"
GF_AUTH_ANONYMOUS_ENABLED: "false"
GF_USERS_ALLOW_SIGN_UP: "false"
GF_DATE_FORMATS_DEFAULT_TIMEZONE: "America/New_York"
volumes:
- grafana_data:/var/lib/grafana
- ./grafana/provisioning:/etc/grafana/provisioning:ro
- ./grafana/dashboards:/var/lib/grafana/dashboards:ro
networks: [monitoring, gitea-net]
node-exporter:
image: quay.io/prometheus/node-exporter:${NODE_EXPORTER_TAG:?choose a release}
container_name: node-exporter
restart: unless-stopped
pid: host
command:
- --path.rootfs=/host
- --path.procfs=/host/proc
- --path.sysfs=/host/sys
volumes:
- /:/host:ro,rslave
networks: [monitoring]
blackbox-exporter:
image: quay.io/prometheus/blackbox-exporter:${BLACKBOX_TAG:?choose a release}
container_name: blackbox-exporter
restart: unless-stopped
command: ["--config.file=/config/blackbox.yml"]
volumes:
- ./blackbox/blackbox.yml:/config/blackbox.yml:ro
networks: [monitoring]
networks:
monitoring:
gitea-net:
external: true
name: gitea-net
volumes:
prometheus_data:
grafana_data:
+2
View File
@@ -0,0 +1,2 @@
# Copy to grafana.secrets.env on the Droplet and fill in. Never commit the real file.
GF_SECURITY_ADMIN_PASSWORD=CHANGE_ME
@@ -0,0 +1,139 @@
apiVersion: 1
groups:
- orgId: 1
name: availability
folder: SSW 590
interval: 30s
rules:
- uid: fg2n29o6c9a80d
title: ServiceUnavailable
condition: C
data:
- refId: A
relativeTimeRange:
from: 600
to: 0
datasourceUid: prometheus
model:
editorMode: code
expr: probe_success{job="https"}
instant: true
intervalMs: 1000
legendFormat: __auto
maxDataPoints: 43200
range: false
refId: A
- refId: C
queryType: expression
datasourceUid: __expr__
model:
conditions:
- evaluator:
params:
- 1
type: lt
operator:
type: and
query:
params:
- C
reducer:
params: []
type: last
type: query
datasource:
type: __expr__
uid: __expr__
expression: A
intervalMs: 1000
maxDataPoints: 43200
refId: C
type: threshold
noDataState: Alerting
execErrState: Alerting
for: 1m
annotations:
runbook_url: https://git.ssw590-08.me/SSW-590-08/Scrap-Web/src/branch/main/monitoring/RUNBOOK.md
summary: '{{ $labels.instance }} HTTPS probe failing for 1m'
labels:
owner: samahk13
severity: critical
team: ssw590
isPaused: false
notification_settings:
receiver: team-alerts
- orgId: 1
name: infrastructure-alerts
folder: SSW 590
interval: 30s
rules:
- uid: bg2tu8l6pb20wc
title: HostDiskLow
condition: C
data:
- refId: A
relativeTimeRange:
from: 600
to: 0
datasourceUid: prometheus
model:
editorMode: code
expr: |-
100 *
node_filesystem_avail_bytes{
mountpoint="/",
fstype!="rootfs",
device="/dev/vda1"
}
/
node_filesystem_size_bytes{
mountpoint="/",
fstype!="rootfs",
device="/dev/vda1"
}
instant: true
intervalMs: 1000
legendFormat: __auto
maxDataPoints: 43200
range: false
refId: A
- refId: C
queryType: expression
datasourceUid: __expr__
model:
conditions:
- evaluator:
params:
- 15
type: lt
operator:
type: and
query:
params:
- C
reducer:
params: []
type: last
type: query
datasource:
type: __expr__
uid: __expr__
expression: A
intervalMs: 1000
maxDataPoints: 43200
refId: C
type: threshold
noDataState: Alerting
execErrState: Alerting
for: 5m
annotations:
description: Investigate root filesystem capacity on the monitored Droplet. Check disk usage and Docker logs before taking action. Do not delete Docker volumes or container data as an emergency response.
runbook_url: https://git.ssw590-08.me/SSW-590-08/Scrap-Web/src/branch/main/monitoring/RUNBOOK.md
summary: Root filesystem free space below 15% on {{ $labels.instance }}
labels:
owner: kholmes7
severity: warning
team: ssw590
isPaused: false
notification_settings:
receiver: team-alerts

Some files were not shown because too many files have changed in this diff Show More