Add CLAUDE files. Add upgrade
This commit is contained in:
30
playbooks/tasks/patch_appwrite_compose.yml
Normal file
30
playbooks/tasks/patch_appwrite_compose.yml
Normal file
@@ -0,0 +1,30 @@
|
||||
---
|
||||
# Applies site-specific customizations to docker-compose.yml after it has been
|
||||
# written by the Appwrite upgrade container or downloaded fresh during install.
|
||||
#
|
||||
# Required variables (define in calling play):
|
||||
# appwrite_dir - absolute path to the appwrite directory on the host
|
||||
# appwrite_socket - host path to the container socket
|
||||
# appwrite_web_port - host port to map to container port 80 (default 8080)
|
||||
# appwrite_websecure_port - host port to map to container port 443 (default 8443)
|
||||
|
||||
- name: Remap traefik HTTP port
|
||||
ansible.builtin.replace:
|
||||
path: "{{ appwrite_dir }}/docker-compose.yml"
|
||||
regexp: '- "?80:80"?'
|
||||
replace: "- {{ appwrite_web_port }}:80"
|
||||
|
||||
- name: Remap traefik HTTPS port
|
||||
ansible.builtin.replace:
|
||||
path: "{{ appwrite_dir }}/docker-compose.yml"
|
||||
regexp: '- "?443:443"?'
|
||||
replace: "- {{ appwrite_websecure_port }}:443"
|
||||
|
||||
- name: Add host tmp mount to openruntimes-executor for docker file sharing
|
||||
# Inserts after the last occurrence of appwrite-builds:/storage/builds:rw,
|
||||
# which is in the openruntimes-executor volumes section.
|
||||
ansible.builtin.lineinfile:
|
||||
path: "{{ appwrite_dir }}/docker-compose.yml"
|
||||
line: " - {{ appwrite_dir }}/tmp:/tmp:z"
|
||||
insertafter: "appwrite-builds:/storage/builds:rw"
|
||||
state: present
|
||||
79
playbooks/tasks/upgrade_appwrite_step.yml
Normal file
79
playbooks/tasks/upgrade_appwrite_step.yml
Normal file
@@ -0,0 +1,79 @@
|
||||
---
|
||||
# Performs one upgrade+migrate cycle for a single Appwrite target version.
|
||||
# Called in a loop from upgrade_appwrite.yml with loop_var: appwrite_target_version.
|
||||
|
||||
- name: "Pull appwrite/appwrite:{{ appwrite_target_version }} image"
|
||||
community.docker.docker_image:
|
||||
name: appwrite/appwrite
|
||||
tag: "{{ appwrite_target_version }}"
|
||||
source: pull
|
||||
|
||||
- name: "Run Appwrite upgrade container for {{ appwrite_target_version }}"
|
||||
# Runs with -i so stdin can answer all interactive prompts.
|
||||
# Prompt order: overwrite confirmation, HTTP port, HTTPS port, API key,
|
||||
# Appwrite hostname, CNAME hostname, SSL email — all accept defaults except overwrite.
|
||||
# The container writes docker-compose.yml then attempts docker compose up internally;
|
||||
# that step fails because we manage the socket/service lifecycle ourselves.
|
||||
# We only fail this task if the compose file backup was not created (file not written).
|
||||
ansible.builtin.command:
|
||||
argv:
|
||||
- docker
|
||||
- run
|
||||
- --rm
|
||||
- -i
|
||||
- --volume
|
||||
- "{{ appwrite_socket }}:/var/run/docker.sock"
|
||||
- --volume
|
||||
- "{{ appwrite_dir }}:/usr/src/code/appwrite:rw"
|
||||
- --entrypoint=upgrade
|
||||
- "appwrite/appwrite:{{ appwrite_target_version }}"
|
||||
stdin: "y\n\n\n\n\n\n\n"
|
||||
register: upgrade_container_result
|
||||
changed_when: true
|
||||
failed_when: "'creating backup' not in upgrade_container_result.stdout"
|
||||
|
||||
- name: Re-apply site customizations after upgrade container rewrote docker-compose.yml
|
||||
ansible.builtin.include_tasks: patch_appwrite_compose.yml
|
||||
|
||||
- name: "Bring up Appwrite stack at {{ appwrite_target_version }}"
|
||||
ansible.builtin.command:
|
||||
argv:
|
||||
- docker
|
||||
- compose
|
||||
- up
|
||||
- -d
|
||||
chdir: "{{ appwrite_dir }}"
|
||||
changed_when: true
|
||||
|
||||
- name: Wait for appwrite container to be running
|
||||
ansible.builtin.command:
|
||||
argv:
|
||||
- docker
|
||||
- compose
|
||||
- ps
|
||||
- --status
|
||||
- running
|
||||
- --services
|
||||
chdir: "{{ appwrite_dir }}"
|
||||
register: running_services
|
||||
until: "'appwrite' in running_services.stdout"
|
||||
retries: 30
|
||||
delay: 10
|
||||
changed_when: false
|
||||
|
||||
- name: "Run database migration for {{ appwrite_target_version }}"
|
||||
ansible.builtin.command:
|
||||
argv:
|
||||
- docker
|
||||
- compose
|
||||
- exec
|
||||
- -T
|
||||
- appwrite
|
||||
- migrate
|
||||
chdir: "{{ appwrite_dir }}"
|
||||
register: migration_result
|
||||
changed_when: true
|
||||
|
||||
- name: Show migration output
|
||||
ansible.builtin.debug:
|
||||
var: migration_result.stdout_lines
|
||||
Reference in New Issue
Block a user