# elway's own smoke-test playbook. Exercises: # - vars (inline default + CLI override) # - multi-step flow # - upload with mode # - tier 1 idempotency: `creates:` skip # - tier 2 idempotency: `changed_when:` to report ok vs changed # - verify phase that tolerates already-set-up state # # Rerunnable: second run should show mostly `ok`/`skipped`, proving # idempotency is wired correctly. vars: scratch_dir: /tmp/elway-smoke greeting: hello from elway steps: - name: Create scratch dir shell: mkdir -p {{ scratch_dir }} creates: "{{ scratch_dir }}" - name: Drop a greeting file shell: echo "{{ greeting }}" > {{ scratch_dir }}/greeting.txt # Skip the echo entirely if the file already contains exactly this line. # `when:` gates BEFORE running; `changed_when:` decides ok-vs-changed AFTER. # For "is the new state already the desired state?", `when:` is correct. when: "! grep -qxF '{{ greeting }}' {{ scratch_dir }}/greeting.txt 2>/dev/null" - name: Upload this playbook into the scratch dir upload: src: playbooks/elway-smoke.yaml dest: "{{ scratch_dir }}/uploaded.yaml" mode: "0644" - name: Record that we ran (a step with no idempotency hooks — always `changed`) shell: date -Iseconds > {{ scratch_dir }}/last-run.txt verify: - name: Greeting file has the expected content shell: grep -qxF "{{ greeting }}" {{ scratch_dir }}/greeting.txt # Verify steps don't actually "change" anything — they only attest. changed_when: "false" - name: Uploaded yaml is non-empty shell: test -s {{ scratch_dir }}/uploaded.yaml changed_when: "false" - name: last-run.txt exists shell: test -s {{ scratch_dir }}/last-run.txt changed_when: "false"