clustered-fucks/playbooks/deploy-silverbullet.yml

61 lines
1.7 KiB
YAML

---
- name: Deploy SilverBullet to databases
hosts: databases
become: yes
vars:
appdata_path: /home/docker/appdata/silverbullet
compose_src: ~/clustered-fucks/compose-files/databases/silverbullet
tasks:
- name: Create appdata directory
file:
path: "{{ appdata_path }}"
state: directory
mode: '0755'
- name: Copy docker-compose.yml
copy:
src: "{{ compose_src }}/docker-compose.yml"
dest: "{{ appdata_path }}/docker-compose.yml"
mode: '0644'
- name: Copy .env file
copy:
src: "{{ compose_src }}/.env"
dest: "{{ appdata_path }}/.env"
mode: '0600'
- name: Pull latest image
community.docker.docker_compose_v2:
project_src: "{{ appdata_path }}"
pull: always
state: present
- name: Start SilverBullet
community.docker.docker_compose_v2:
project_src: "{{ appdata_path }}"
state: present
- name: Wait for container to be healthy
shell: |
for i in {1..30}; do
status=$(docker inspect --format='{% raw %}{{.State.Health.Status}}{% endraw %}' silverbullet 2>/dev/null || echo "not_found")
if [ "$status" = "healthy" ]; then
echo "Container is healthy"
exit 0
fi
sleep 2
done
echo "Timeout waiting for healthy status"
exit 1
register: health_check
changed_when: false
- name: Show container status
shell: docker ps --filter name=silverbullet --format "table {% raw %}{{.Names}}\t{{.Status}}\t{{.Ports}}{% endraw %}"
register: container_status
changed_when: false
- name: Display status
debug:
var: container_status.stdout_lines