Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
100 commits
Select commit Hold shift + click to select a range
2e23bb8
Test: the loader returns each stack's environments
davidjalbers Dec 6, 2026
d44bf28
The loader returns each stack's environments
davidjalbers Dec 6, 2026
4472d38
Test: doctor holds environment files to each other and to the compose…
davidjalbers Dec 6, 2026
3cffcf9
plx doctor holds a stack's environment files to each other and to its…
davidjalbers Dec 6, 2026
95b35b7
Test: a secret that is no pointer is listed under its name
davidjalbers Dec 6, 2026
80a328a
A secret that is no pointer is listed under its name and reported once
davidjalbers Dec 6, 2026
b58a11d
test: the platform playbook leaves a host's deployments of an earlier…
davidjalbers Dec 6, 2026
e596fbd
The platform playbook no longer reads plexus_apps
davidjalbers Dec 6, 2026
0fc0497
test: the platform playbook prepares a fresh host for stacks
davidjalbers Dec 6, 2026
690ee49
The platform playbook gives the deploy user the deploy root and the r…
davidjalbers Dec 6, 2026
b40e949
test: the deploy user reloads the proxy by one sudo rule and nothing …
davidjalbers Dec 6, 2026
33200d2
The deploy user may reload the proxy, and nothing else
davidjalbers Dec 6, 2026
d5b4621
test: a stack's route takes the fence and the maintenance page from t…
davidjalbers Dec 6, 2026
ce28dce
The root Caddyfile states what every stack's route does but its name …
davidjalbers Dec 6, 2026
6d6febe
test: the old routes and the fragments coexist while a host migrates
davidjalbers Dec 6, 2026
4f3c495
Test: the whole compose document is read for required variables, and …
davidjalbers Dec 6, 2026
e19dbc3
Required variables are read from the whole compose document and cover…
davidjalbers Dec 6, 2026
93fd38f
Test: one bad value is one finding; env values are strings; more case…
davidjalbers Dec 6, 2026
bce5fe3
Environment files: strings only, one finding per bad value, the platf…
davidjalbers Dec 6, 2026
87fa7a7
The old routes stay imported until apps.caddy is deleted, without a p…
davidjalbers Dec 6, 2026
efca360
Test: SinglePort lets a stack with environment files and no hostname …
davidjalbers Dec 6, 2026
0954da3
The platform playbook's header says it writes no route
davidjalbers Dec 6, 2026
8fb808a
SinglePort: a stack with environment files binds a port only where a …
davidjalbers Dec 6, 2026
fa65079
Test: host is an SSH destination parsed once; platform and doubled na…
davidjalbers Dec 6, 2026
e97916e
host is an SSH destination, parsed once by the loader; doubled and pl…
davidjalbers Dec 6, 2026
d2f65b3
Drop two guards of the host parser that others make redundant
davidjalbers Dec 6, 2026
ed08b51
Test: a version lands on the default branch of origin, whatever the r…
davidjalbers Dec 6, 2026
f78e562
Test: the integration fixtures give each origin a default branch, and…
davidjalbers Dec 6, 2026
4e6f7b8
plx update lands a version on the default branch of origin
davidjalbers Dec 6, 2026
f5519cc
Index: append the five requirement names of this change; ship regener…
davidjalbers Dec 6, 2026
0ff2151
Test: environment findings cite PLX-Stack requirements, SinglePort ha…
davidjalbers Dec 6, 2026
4abc83c
Environment findings are the requirements EnvironmentFile, Environmen…
davidjalbers Dec 6, 2026
75afb4f
Test: host forms with ssh options, a cyclic alias, one fault one find…
davidjalbers Dec 6, 2026
17190a4
host refuses ssh options and takes a DNS name, IPv4 or IPv6 address; …
davidjalbers Dec 6, 2026
0985106
compose.ts header: a cyclic alias is refused
davidjalbers Dec 6, 2026
d8a580d
test: the plexus_apps message says what the host no longer gets
davidjalbers Dec 6, 2026
15cbc9a
The plexus_apps message says what the host no longer gets, and what i…
davidjalbers Dec 6, 2026
3d5f743
test: a run fails on a proxy configuration that is invalid on disk
davidjalbers Dec 6, 2026
72240a1
ingress validates the proxy's whole configuration in every run
davidjalbers Dec 6, 2026
9a11aa6
test: an invalid sudo rule or root Caddyfile never lands, and apps.ca…
davidjalbers Dec 6, 2026
f37dd89
Test: a version lands on the default branch origin says now, not on a…
davidjalbers Dec 6, 2026
3f0fba7
plx update asks origin for its default branch and reads no record of it
davidjalbers Dec 6, 2026
e9dd4ce
ingress writes the reload rule first; its header states once what a f…
davidjalbers Dec 6, 2026
716ad59
The deploy root is /opt/stacks, no variable, on the platform's side
davidjalbers Dec 6, 2026
1dedaac
test: a dry run on a fresh host passes before the proxy is installed
davidjalbers Dec 6, 2026
1f4e159
ingress validates the whole configuration only where the proxy's bina…
davidjalbers Dec 6, 2026
e6f3ead
test: an invalid proxy configuration does not keep a host from being …
davidjalbers Dec 6, 2026
caa9bc3
Merge pull request #116 from plexus-ms/davidjalbers/plx-296-lib-reads…
davidjalbers Dec 6, 2026
e69d5d9
Merge remote-tracking branch 'origin/stacks-2' into davidjalbers/plx-…
davidjalbers Dec 6, 2026
135455a
findRepos names every reason a repo is skipped
davidjalbers Dec 6, 2026
795c0ad
A proxy configuration Caddy refuses fails the host after the lock-down
davidjalbers Dec 6, 2026
f7c96c0
test: a deploy root set to another path is named, and the run goes on
davidjalbers Dec 6, 2026
6745335
The platform playbook says where plexus_deploy_root names another path
davidjalbers Dec 6, 2026
0131b7b
Merge remote-tracking branch 'origin/stacks-2' into davidjalbers/plx-…
davidjalbers Dec 6, 2026
de7c98d
Test: the newborn update fixtures' origins have the repo's branch as …
davidjalbers Dec 6, 2026
152255e
Merge pull request #117 from plexus-ms/davidjalbers/plx-297-the-platf…
davidjalbers Dec 6, 2026
9894aa5
Merge remote-tracking branch 'origin/stacks-2' into davidjalbers/plx-…
davidjalbers Dec 6, 2026
c36294b
The stack playbook's test deploys from an environment's file
davidjalbers Dec 6, 2026
65f09e5
Index: append PLX-Stack/PreparedHost, which the stack playbook's head…
davidjalbers Dec 6, 2026
2fa626a
The stack playbook deploys from an environment's file
davidjalbers Dec 6, 2026
a6b4836
The image of a prepared host is shared by the tests of both playbooks
davidjalbers Dec 6, 2026
a76519c
The stack playbook's test deploys environments with a hostname onto a…
davidjalbers Dec 6, 2026
10b0365
The stack playbook claims an environment's port and writes its route
davidjalbers Dec 6, 2026
cae1f44
Merge pull request #118 from plexus-ms/davidjalbers/plx-327-plx-updat…
davidjalbers Dec 6, 2026
692c30e
Merge remote-tracking branch 'origin/stacks-2' into davidjalbers/plx-…
davidjalbers Dec 6, 2026
2fe7d02
The doctor's test no longer cites the removed requirement PathPrefix …
davidjalbers Dec 6, 2026
c37e345
The doctor no longer lists PLX-Stack/PathPrefix as a removed requirement
davidjalbers Dec 6, 2026
62972fe
The deploy verb's test deploys the stacks that have the environment's…
davidjalbers Dec 6, 2026
2381d41
The deploy job's setup test: the deploy key comes from a repository s…
davidjalbers Dec 6, 2026
2a3eef2
The workflows' tests: a deploy job checks out its own repo alone and …
davidjalbers Dec 6, 2026
8d1ad88
plx deploy deploys the stacks that have the environment's file, to th…
davidjalbers Dec 6, 2026
73971c5
plx-ci setup deploy holds the deploy key from a repository secret, re…
davidjalbers Dec 6, 2026
1f87667
The deploy jobs check out their own repo alone and hold the deploy ke…
davidjalbers Dec 6, 2026
35a727c
The stack template's test: a file for each environment the branches d…
davidjalbers Dec 6, 2026
6dfa69c
The newborn operations repo's deploy job deploys its stacks from thei…
davidjalbers Dec 6, 2026
ee909cc
The newborn repo's test lists the environment files of its stack, whi…
davidjalbers Dec 6, 2026
7867126
The template stack renders a file for each environment the branches d…
davidjalbers Dec 6, 2026
40200ab
The operations repo's marker says plx deploy takes each stack's envir…
davidjalbers Dec 6, 2026
9bdbb68
The newborn operations repo's stacks name a hostname in both environm…
davidjalbers Dec 6, 2026
d177671
The stack playbook's test drops every secret, and reads one that is e…
davidjalbers Dec 6, 2026
2da1794
The stack playbook writes an empty .env.secret, refuses an empty secr…
davidjalbers Dec 6, 2026
8ab9006
The stack playbook's test narrows a run, and ends a host or hostname …
davidjalbers Dec 6, 2026
a4fde3c
The stack playbook refuses a narrowed run, and a host or hostname end…
davidjalbers Dec 6, 2026
7ffa5d5
The stack playbook's test claims a port something listens on, and a h…
davidjalbers Dec 6, 2026
59731ef
The route script skips a port something listens on, and says why the …
davidjalbers Dec 6, 2026
917c85a
The deploy root is written once, and the stack playbook's header says…
davidjalbers Dec 6, 2026
0a925d9
plx deploy's test: the variables go as one JSON object, from a checko…
davidjalbers Dec 6, 2026
5ae3a69
plx deploy passes the playbook's variables as one JSON object, words …
davidjalbers Dec 6, 2026
b0cf0a2
The doctor's test: a deviation under a removed requirement is told th…
davidjalbers Dec 6, 2026
2795317
A deviation under PLX-Stack/PathPrefix or PLX-Ingress/PrefixInRecord …
davidjalbers Dec 6, 2026
674c326
merge's test: a birth-only path is written at a birth and never by an…
davidjalbers Dec 6, 2026
4b51e19
The engine's policy birth-only: a path written at a birth and never a…
davidjalbers Dec 6, 2026
9a8b66f
The stack's tests: an update adds no environment file to a stack, a b…
davidjalbers Dec 6, 2026
687675f
The template stack's environment files are birth-only: an update adds…
davidjalbers Dec 6, 2026
9f84c5d
The update newborn test: a stack of 0.138.0 gets no environment file …
davidjalbers Dec 6, 2026
2942d1d
Merge branch 'davidjalbers/plx-298-the-stack-playbook-applies-an' int…
davidjalbers Dec 6, 2026
4bc60e9
plx deploy's test: a run that exits 0 and prints no Result line is a …
davidjalbers Dec 6, 2026
f63ba76
plx deploy's test: a path holding {{ or {% is refused before anything…
davidjalbers Dec 6, 2026
52862a6
plx deploy refuses a path Ansible would template; the doctor's remove…
davidjalbers Dec 6, 2026
61d97da
Merge pull request #121 from plexus-ms/davidjalbers/plx-299-plx-deplo…
davidjalbers Dec 6, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions ansible/platform/galaxy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ readme: README.md
authors:
- David Julian Albers
description: >-
The platform layer (PLX-Platform): what makes an existing host run a tenant's apps —
deploy_user, caddy, ingress, secrets, apps — and the playbook plexus.platform.playbook that
mounts them with the host baseline on the inventory group platform; and the playbook
The platform layer (PLX-Platform): what prepares an existing host for a tenant's stacks —
deploy_user, caddy, ingress — and the playbook plexus.platform.playbook that mounts them
with the host baseline on the inventory group platform; and the playbook
plexus.platform.stack, which deploys one environment of a stack onto one host.
license:
- GPL-3.0-or-later
Expand Down
64 changes: 42 additions & 22 deletions ansible/platform/playbooks/playbook.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,24 @@
---
# The platform layer on a tenant's app hosts (PLX-Platform): the host
# baseline, then what makes the host run the tenant's apps, then the lock-down
# roles that have to come last. Mounted on the inventory group `platform`.
# baseline, then what prepares the host for stacks, then the lock-down roles
# that have to come last. Mounted on the inventory group `platform`.
#
# ansible-playbook plexus.platform.playbook # everything
# ansible-playbook plexus.platform.playbook --tags apps,secrets # the everyday pass
# ansible-playbook plexus.platform.playbook --tags platform # the layer without the baseline
# ansible-playbook plexus.platform.playbook --limit host-a --tags ingress
#
# Tags: every play carries its layer (`host`, `platform`) and every role its
# own name, so `--tags platform` is the whole layer and `--tags apps` one role.
# Not a deploy: deploying is the verb's act (§ 6 PLX-Delivery); this playbook
# binds apps to the host and hands them their environment.
# own name, so `--tags platform` is the whole layer and `--tags ingress` one role.
# It knows no stack: it prepares what every stack's environment needs on the
# host (the deploy user, the deploy root, the proxy with its directory of route
# fragments, and the one rule by which the deploy user reloads the proxy), and
# the stack playbook (plexus.platform.stack) does everything one environment
# needs. It starts, re-creates and removes no container, changes nothing below
# the deploy root, and writes no route. `plexus_apps`, the records of earlier
# versions, is not read, nor is plexus_deploy_root; a host that still sets
# records in the one or another path than /opt/stacks in the other is told so,
# and the run goes on. A proxy configuration Caddy refuses fails the host in the
# last play, after the lock-down roles have run.
#
# A fresh host is reached as root once (`-u root`), which creates the admins;
# every later run connects as an admin, and the first of those closes root
Expand Down Expand Up @@ -46,12 +54,29 @@
- name: Gather facts
ansible.builtin.setup:
tags: [always]
- name: Say that plexus_apps is no longer read
when: plexus_apps | default([]) | length > 0
ansible.builtin.debug:
msg: >-
plexus_apps is no longer read, and the platform playbook writes nothing from it: a change to a record's
values, secrets, port or route reaches no host any more, a rotated secret re-creates no container, and a
new record gets no directory, so it cannot be deployed. Each deployment on this host keeps running, and
keeps deploying, with the .env, .env.secret and route it has, until its repo holds its environment file
and the stack playbook writes them from there. The routes earlier versions wrote stay in
/etc/caddy/apps.caddy until removed by hand; remove the records once no deployment needs them.
tags: [always]
- name: Say that plexus_deploy_root is no longer read
when: plexus_deploy_root | default('/opt/stacks') != '/opt/stacks'
ansible.builtin.debug:
msg: >-
plexus_deploy_root is no longer read: the deploy root is /opt/stacks on every host, which the platform
playbook gives the deploy user, and the stack playbook works there alone. A deployment under
{{ plexus_deploy_root }} is not seen by the stack playbook and stays as it is; remove the variable.
tags: [always]
roles:
- { role: plexus.platform.deploy_user, tags: [deploy_user] }
- { role: plexus.platform.caddy, tags: [caddy] }
- { role: plexus.platform.ingress, tags: [ingress] }
- { role: plexus.platform.secrets, tags: [secrets] } # before apps, so the first up sees the secrets
- { role: plexus.platform.apps, tags: [apps] }

- name: Lock down the platform hosts
hosts: platform
Expand All @@ -66,21 +91,16 @@
- { role: plexus.host.firewall, tags: [firewall] } # after the roles that open ports in it
- { role: plexus.host.sshd, tags: [sshd] } # last: closes root logins once an admin has logged in

# The apps role records an app whose start failed and carries on with the
# others; the failure is raised here, once per host and after the lock-down
# roles, so that a failed start never leaves a host without its firewall and
# sshd settings. Any other failure (a rotation handler, the registry login,
# writing .env, resolving the secrets) still fails the host before them. Tagged `platform` and `apps`, so `--tags apps` reports it too.
- name: Report the apps that failed to start
# The proxy's configuration Caddy refused, which the ingress role records: the
# host fails here, after the lock-down roles, so that a route someone broke
# never keeps a host from its firewall and sshd settings. Tagged `platform`
# and `ingress`, so that `--tags ingress` reports it too.
- name: Report a proxy configuration Caddy refuses
hosts: platform
gather_facts: false
tags: [platform, apps]
tags: [platform, ingress]
tasks:
- name: Fail the host for the apps that did not start
when: apps_failures | default([]) | length > 0
- name: Fail the host whose proxy configuration Caddy refuses
when: ingress_invalid is defined
ansible.builtin.fail:
msg: |-
{{ apps_failures | length }} app(s) did not start:
{% for f in apps_failures %}
- {{ f.app }}: '{{ f.task }}' failed (rc {{ f.rc }}): {{ f.output }}
{% endfor %}
msg: "the proxy's configuration is invalid, and every reload fails until it is mended: {{ ingress_invalid }}"
177 changes: 120 additions & 57 deletions ansible/platform/playbooks/stack.yml
Original file line number Diff line number Diff line change
@@ -1,81 +1,144 @@
---
# The stack playbook: deploys one environment of one stack onto one host.
# It runs where the deploy starts, a CI job or a person's machine, connects
# as the deploy user, and is never installed on the host. The deploy itself
# is the role plexus.platform.stack; the platform playbook
# (plexus.platform.playbook) lays the environment out before its first deploy.
# The stack playbook: deploys one environment of one stack onto its host. It
# runs where the deploy starts, a CI job or a person's machine, reads there the
# environment's file and the rendered compose file, connects to the host the
# file names as the deploy user, and is never installed on the host. The
# deploy is the role plexus.platform.stack.
#
# ansible-playbook -i deploy@app-1.example.com, plexus.platform.stack \
# -e stack_name=shop -e stack_environment=staging -e stack_compose_file=./compose.yaml
# ansible-playbook plexus.platform.stack -e stack_name=shop \
# -e stack_environment_file=stack/staging.yaml -e stack_compose_file=./compose.yaml
#
# Variables, documented in the role's defaults: stack_name, stack_environment
# and stack_compose_file, given on every run; stack_root (/opt/stacks) and
# stack_wait_timeout (60 seconds).
# Variables, documented in the role's defaults: stack_name,
# stack_environment_file and stack_compose_file, given on every run; the
# environment is named after its file (staging.yaml is staging). Further
# stack_root (the deploy root, /opt/stacks), stack_port_range (20000-20999),
# stack_secret_timeout (30 seconds) and stack_wait_timeout (60 seconds).
#
# What it expects on the host: the directory <stack_root>/<stack>-<environment>,
# which the user it connects as may write, holding the .env (and .env.secret
# where the environment has secrets) that the platform playbook writes; Docker
# What the caller passes, and what not. No inventory (-i) and no --limit: the
# one host is the file's `host`, [user@]address[:port], reached as the user it
# names, else as plexus_deploy_user (the role deploy_user's default, plexus,
# whatever an inventory says), on the port it names, else 22; an inventory
# only lends the connection variables of a host of the same name. No --tags
# or --skip-tags. It refuses a --limit, --tags or --skip-tags it sees, but a
# --limit that leaves out localhost, or --skip-tags always, makes
# ansible-playbook run none of its tasks and exit 0 without a Result line.
# Arguments for the connection, such as --ssh-common-args or --private-key,
# apply. PLEXUS_TAG and PLEXUS_COMMIT_SHA are the caller's: it renders them
# into the compose file it hands over, each app's image pinned by its digest in
# place of ${PLEXUS_TAG} and the commit in place of ${PLEXUS_COMMIT_SHA}; the
# playbook writes neither, and the compose file is otherwise handed over
# uninterpolated, since the host interpolates it from .env.
#
# What it expects where it runs: the vault's CLI, op, with a session or a
# token, where the environment has secrets. On the host, as the platform
# playbook prepares it (PLX-Stack/PreparedHost): the deploy user, owner of
# /opt/stacks; where the environment has a hostname, the directory of route
# fragments the deploy user writes and the sudo rule by which it reloads the
# proxy (both as the header of the ingress role's tasks names them); Docker
# with its compose plugin, which that user may run (the docker group); and
# Python. It uses no privilege escalation. The compose project is
# <stack>-<environment>, the name the platform playbook writes into .env.
# Python. It uses no privilege escalation but that rule.
#
# In order:
# 1. Checks its variables, that the inventory holds one host, and that the
# directory and its .env are there.
# 2. Compares the compose file with the compose.yaml in place. Where they are
# the same, 3 to 5 are left out.
# 3. Keeps the compose.yaml in place as compose.yaml.prev and writes the new one.
# 4. Pulls the images, so that an image that cannot be had fails the deploy
# before migrate runs, and a tag that moved since the last deploy is
# fetched, which run and up, pulling only what is missing, would not do.
# Where the file is the one in place, nothing is pulled, so a tag that
# moved is fetched only by a deploy that changes the file.
# 5. Runs the service `migrate` once, where the file has one, and removes its
# container; where it fails, the line says its exit code and the last line
# it wrote.
# 6. Brings up every service Compose starts by itself, `migrate` excepted, with
# In order, where it runs:
# 1. Checks its arguments and variables, and reads the environment's file and
# checks that it can write it: a map of `host`, `hostname`, a DNS name,
# `env`, names to strings, and `secrets`, names to op:// pointers; plx
# doctor checks the file whole.
# 2. Reads each pointer under `secrets` with `op read`, also in a dry run,
# refusing a value that is empty in the vault, and adds the host the file
# names.
# On the host, into /opt/stacks/<stack>-<environment>, the compose project of
# that name:
# 3. Where the environment has a hostname, claims its loopback port and
# writes its route (the role's files/route.sh says how).
# 4. Creates the directory where it is missing, mode 0750.
# 5. Renders .env from `env`, with COMPOSE_PROJECT_NAME and, where the
# environment has a hostname, PLEXUS_LOOPBACK_PORT; .env.secret, mode
# 0600, from the secrets' values, where the environment has secrets or
# the directory holds one already, which ends empty once the environment
# has none; each value double-quoted and escaped (templates/dotenv.j2), so
# that Compose reads it back as written. Compares them, and the compose
# file, with the files in place: a file that changes is kept as
# <file>.prev, all of them before the first is written, and then written,
# .env, .env.secret, compose.yaml. .env.secret.prev, 0600, keeps the
# previous secrets until .env.secret changes again.
# 6. Pulls the images, where compose.yaml changed, so that an image that
# cannot be had fails the deploy before migrate runs, and a tag that moved
# since the last deploy is fetched, which run and up, pulling only what is
# missing, would not do.
# 7. Runs the service `migrate` once, where compose.yaml changed and has
# one, and removes its container; where it fails, the line says its exit
# code and the last line it wrote.
# 8. Brings up every service Compose starts by itself, `migrate` excepted, with
# --no-deps, so that a service that depends on migrate's completion does
# not run it again, and --remove-orphans, so that a service the file no
# longer has goes. Then waits for every service that declares a
# healthcheck to turn healthy; a service without one counts as soon as it
# runs. stack_wait_timeout bounds the whole wait, and a healthcheck's
# start_period does not extend it: a service that needs longer to turn
# healthy needs the variable raised. Compose re-creates a container only
# where its service changed: an image pinned by digest that did not change
# leaves its line, and its container, as they were. Where no service is
# left to start, a stack of `migrate` alone or of none, it starts nothing
# and takes down whatever the project still runs; a take-down of something
# it ran counts as deployed, as a start does.
# A failure after 3 restores compose.yaml.prev and runs 6 again. After a first
# deploy, where there is no previous file, it removes the stack's containers
# and networks and the compose.yaml; the volumes stay. Where the file was the
# one in place, a failure undoes nothing; so a run after a rollback, with the
# same file, deploys it again and fails the same way. .env and .env.secret are
# the platform playbook's and are neither written nor restored here.
# where its service changed, its image or the files it loads: an image
# pinned by digest that did not change, and values that did not, leave
# the container as it was. Where no service is left to start, a stack of
# `migrate` alone or of none, it starts nothing and takes down whatever
# the project still runs; a take-down of something it ran counts as
# deployed, as a start does.
# A failure after the first write of 5 restores the files that run replaced,
# each from its .prev, removes a file it created, and runs 8 again; the route
# is not rolled back, since it joins the hostname to a port that does not
# change. Where compose.yaml was not there before, a first deploy, it removes
# the stack's containers and networks and the compose.yaml instead; the
# volumes stay, and .env and .env.secret stay with the port the route names.
# Where no file changed, a failure undoes nothing; so a run after a rollback,
# with the same files, deploys them again and fails the same way. A run in
# which nothing changed changes no file, reloads nothing and re-creates no
# container.
#
# Nothing locks an environment as a whole: two runs for the same environment
# at the same time are not supported, and can both fail, one undoing what the
# other made. What keeps them apart is the pipeline's own order, one deploy job
# per branch at a time.
#
# Nothing locks an environment: two runs for the same environment at the same
# time are not supported, and can both fail, one undoing what the other made.
# What keeps them apart is the pipeline's own order, one deploy job per branch
# at a time.
# No secret's value appears in the run's output, with -v or --diff either:
# every task that holds one prints nothing of it.
#
# The last task, Result, prints one line as its `msg`:
# <stack>-<environment>: deployed the file changed, or a container was started or
# taken down; healthy
# The last task, Result, prints one line as its `msg`. Every run prints it, and
# exits 0 only where it says deployed, unchanged or would deploy, but for the
# two runs of no task above and a host that cannot be reached, which Ansible's
# own error ends, with exit code 4:
# <stack>-<environment>: deployed a file or the route changed, or a container was
# started or taken down; healthy
# <stack>-<environment>: unchanged nothing changed, and healthy
# <stack>-<environment>: would deploy under --check, where compose.yaml would change
# <stack>-<environment>: rolled back: <why> the previous compose.yaml is up and healthy again
# <stack>-<environment>: would deploy under --check, where a file or the route would change
# <stack>-<environment>: rolled back: <why> the previous files are up and healthy again
# <stack>-<environment>: failed: <why> nothing was rolled back, or the undo failed too
# <why> names the step that failed and the first line of its error, as in
# `'Bring the stack up and wait for health' failed (rc 1): General error:
# container shop-staging-web-1 is unhealthy`. Where the check of the
# variables fails, the line begins `the stack:`. The task, and with it the
# run, fails unless the line says deployed, unchanged or would deploy.
# arguments or the variables fails, the line begins `the stack:`.
#
# --check, with --diff, runs 1 and 2 and shows whether compose.yaml would
# change, and how. It pulls, migrates and starts nothing, so it says nothing
# about the images, migrate or health.
# --check, with --diff, runs 1 to 5 and shows whether .env, .env.secret,
# compose.yaml and the route would change, and how, but for .env.secret. It
# writes nothing, takes no lock, and pulls, migrates and starts nothing, so it
# says nothing about the images, migrate or health.
- name: Read the environment
hosts: localhost
connection: local
gather_facts: false
vars_files:
- ../roles/deploy_user/defaults/main.yml # plexus_deploy_user
tasks:
- name: Read the environment's file and its secrets
ansible.builtin.include_role:
name: plexus.platform.stack
tasks_from: environment.yml
apply: { tags: [always] }
tags: [always]

- name: Deploy one environment of a stack
hosts: all
hosts: stack_host
gather_facts: false
vars_files:
- ../roles/deploy_user/vars/main.yml # deploy_user_root
- ../roles/ingress/defaults/main.yml # ingress_fragments_dir
roles:
- { role: plexus.platform.stack }
- { role: plexus.platform.stack, tags: [always] }
19 changes: 0 additions & 19 deletions ansible/platform/roles/apps/handlers/main.yml

This file was deleted.

Loading