Declarative programming states the desired result or state instead of prescribing every step needed to reach it. The tool handles the procedure, so you focus on what should exist and reuse the configuration across applications, servers, and hosts. section 1.1 section 4.1.1
A deployment request can describe the target state in plain language:
- Use a Python application with Python 3.10. section 1.1
- Run it on ports 80 and 443 and allow internet traffic. section 1.1
- Use example.com without specifying the server-by-server procedure. section 1.1
YAML makes declarative configuration readable at a glance. A GitHub Actions workflow declares its name, trigger, operating system, job, and steps; GitHub Actions decides how to execute that requested workflow. Python and JavaScript, by contrast, generally describe how data flows and what the application must do. section 4.1.1
From workflow to machine configuration
A workflow can run on every push or through a manual trigger, use ubuntu-latest, check out the repository, and execute an echo command. Ansible applies the same desired-state idea to machines through YAML playbooks: it installs Python, Node.js, NGINX, and Supervisor dependencies, configures services, and starts, restarts, or reloads them over SSH. section 4.1.1 section 4.2
Listing 4.2 Hello World with GitHub Actions
name: Hello World
on:
workflow_dispatch:
push:
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Hello World
run: echo "Hello World"
Inspect a minimal declarative GitHub Actions workflow with triggers, a runner, checkout, and a command. section 4.1.1













