Rename roles

Allow roles to be renamed without having to manually stop the old
containers.

If you have config like:

```
servers:
  jobs:
    hosts:
      - vm3
```

And you want to rename `jobs` to `workers`, you can do:

```
servers:
  workers:
    previously:
      - jobs
    hosts:
      - vm3
```

And the deployment will take care of stopping the old "jobs" containers.

Once deployed you can remove the `previously` key.
This commit is contained in:
Donal McBreen
2024-03-26 13:48:04 +00:00
parent d475e88dbe
commit 9a5880208a
9 changed files with 137 additions and 28 deletions

View File

@@ -0,0 +1,42 @@
service: app
image: app
primary_role: app
servers:
app:
previously:
- web
hosts:
- vm1
- vm2
jobs:
previously:
- workers
hosts:
- vm3
cmd: sleep infinity
asset_path: /usr/share/nginx/html/versions
registry:
server: registry:4443
username: root
password: root
builder:
multiarch: false
args:
COMMIT_SHA: <%= `git rev-parse HEAD` %>
healthcheck:
cmd: wget -qO- http://localhost > /dev/null || exit 1
traefik:
args:
accesslog: true
accesslog.format: json
image: registry:4443/traefik:v2.10
accessories:
busybox:
service: custom-busybox
image: registry:4443/busybox:1.36.0
cmd: sh -c 'echo "Starting busybox..."; trap exit term; while true; do sleep 1; done'
roles:
- app
stop_wait_time: 1

View File

@@ -0,0 +1,3 @@
#!/bin/bash
cd $1 && cp -f config/deploy_renamed_roles.yml config/deploy.yml && git commit -am 'Rename roles'