51 lines
No EOL
1.8 KiB
YAML
51 lines
No EOL
1.8 KiB
YAML
#SPDX-License-Identifier: MIT-0
|
|
---
|
|
# Provisioning tasks for garage (cluster bootstrap, S3 keys, and buckets)
|
|
# Cluster bootstrap tasks
|
|
- name: Get garage node ID
|
|
community.docker.docker_container_exec:
|
|
container: "{{ garage_service_name }}"
|
|
command: /garage node id -q
|
|
register: _garage_node_id
|
|
|
|
- name: Extract short node ID
|
|
ansible.builtin.set_fact:
|
|
_garage_node_id_short: "{{ _garage_node_id.stdout.split('@')[0] }}"
|
|
|
|
- name: Check if node layout is configured
|
|
community.docker.docker_container_exec:
|
|
container: "{{ garage_service_name }}"
|
|
command: /garage layout show
|
|
register: _garage_layout_show
|
|
failed_when: false
|
|
|
|
- name: Check if node is in layout
|
|
ansible.builtin.set_fact:
|
|
_node_in_layout: "{{ _garage_node_id_short in _garage_layout_show.stdout }}"
|
|
|
|
- name: Configure garage node layout
|
|
community.docker.docker_container_exec:
|
|
container: "{{ garage_service_name }}"
|
|
command: /garage layout assign -z {{ garage_bootstrap_zone }} -c {{ garage_bootstrap_capacity }} {{ _garage_node_id_short }}
|
|
register: _layout_assign_result
|
|
when:
|
|
- not _node_in_layout
|
|
|
|
- name: Extract current layout version
|
|
ansible.builtin.set_fact:
|
|
_current_layout_version: "{{ _garage_layout_show.stdout | regex_search('Current cluster layout version: (\\d+)', '\\1') | first | default('0') }}"
|
|
when:
|
|
- _layout_assign_result is changed
|
|
|
|
- name: Calculate next layout version
|
|
ansible.builtin.set_fact:
|
|
_next_layout_version: "{{ (_current_layout_version | int) + 1 }}"
|
|
when:
|
|
- _layout_assign_result is changed
|
|
|
|
- name: Apply garage layout
|
|
community.docker.docker_container_exec:
|
|
container: "{{ garage_service_name }}"
|
|
command: /garage layout apply --version {{ _next_layout_version }}
|
|
when:
|
|
- _layout_assign_result is changed |