stack-orchestrator/playbooks/biscayne-sync-tools.yml

129 lines
4.2 KiB
YAML

---
# Sync laconic-so and agave-stack to latest on biscayne
#
# Updates both repos that laconic-so deployment commands depend on:
# - stack-orchestrator (laconic-so itself, editable install)
# - agave-stack (stack definitions, compose files, container scripts)
#
# Then regenerates the deployment config from the updated stack.
# Does NOT restart anything — just syncs code and config.
#
# Usage:
# ansible-playbook -i inventory/biscayne.yml playbooks/biscayne-sync-tools.yml
#
# # Use a feature branch
# ansible-playbook -i inventory/biscayne.yml playbooks/biscayne-sync-tools.yml \
# -e laconic_so_branch=fix/kind-mount-propagation
#
# # Sync and rebuild the agave container image
# ansible-playbook -i inventory/biscayne.yml playbooks/biscayne-sync-tools.yml \
# --tags build-container
#
- name: Sync laconic-so and agave-stack
hosts: all
gather_facts: false
environment:
KUBECONFIG: /home/rix/.kube/config
vars:
deployment_dir: /srv/deployments/agave
stack_repo: /srv/deployments/agave-stack
stack_path: /srv/deployments/agave-stack/stack-orchestrator/stacks/agave
laconic_so: /home/rix/.local/bin/laconic-so
laconic_so_repo: /home/rix/stack-orchestrator
laconic_so_branch: fix/kind-mount-propagation
stack_branch: main
tasks:
- name: Update laconic-so (editable install)
ansible.builtin.shell: |
set -e
cd {{ laconic_so_repo }}
git fetch origin {{ laconic_so_branch }}
git reset --hard origin/{{ laconic_so_branch }}
vars:
ansible_become: false
register: laconic_so_update
changed_when: true
tags: [sync, build-container]
- name: Show laconic-so version
ansible.builtin.shell:
cmd: set -o pipefail && cd {{ laconic_so_repo }} && git log --oneline -1
executable: /bin/bash
register: laconic_so_version
changed_when: false
tags: [sync, build-container]
- name: Report laconic-so
ansible.builtin.debug:
msg: "laconic-so: {{ laconic_so_version.stdout }}"
tags: [sync, build-container]
- name: Pull agave-stack repo
ansible.builtin.shell: |
set -e
cd {{ stack_repo }}
git fetch origin {{ stack_branch }}
git reset --hard origin/{{ stack_branch }}
vars:
ansible_become: false
register: stack_update
changed_when: true
tags: [sync, build-container]
- name: Show agave-stack version
ansible.builtin.shell:
cmd: set -o pipefail && cd {{ stack_repo }} && git log --oneline -1
executable: /bin/bash
register: stack_version
changed_when: false
tags: [sync, build-container]
- name: Report agave-stack
ansible.builtin.debug:
msg: "agave-stack: {{ stack_version.stdout }}"
tags: [sync, build-container]
- name: Regenerate deployment config from updated stack
ansible.builtin.command: >
{{ laconic_so }}
--stack {{ stack_path }}
deploy create
--spec-file {{ deployment_dir }}/spec.yml
--deployment-dir {{ deployment_dir }}
--update
register: regen_result
changed_when: true
tags: [sync, build-container]
- name: Report sync complete
ansible.builtin.debug:
msg: >-
Sync complete. laconic-so and agave-stack updated to
origin/{{ laconic_so_branch }}. Deployment config regenerated.
Restart or redeploy required to apply changes.
tags: [sync, build-container]
# ---- optional: rebuild container image --------------------------------------
# Only runs when explicitly requested with --tags build-container.
# Safe to run while the validator is running — just builds a new image.
# The running pod keeps the old image until restarted.
- name: Build agave container image
ansible.builtin.command: >
{{ laconic_so }}
--stack {{ stack_path }}
build-containers
--include laconicnetwork-agave
tags:
- build-container
- never
register: build_result
changed_when: true
- name: Report build complete
ansible.builtin.debug:
msg: "Container image built. Will be used on next pod restart."
tags:
- build-container
- never