feat(garage): add provisioning of and bootstraping
This commit is contained in:
parent
188a6f539f
commit
19986e1205
4 changed files with 194 additions and 5 deletions
51
roles/garage/tasks/bootstrap.yml
Normal file
51
roles/garage/tasks/bootstrap.yml
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
#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
|
||||
Loading…
Add table
Add a link
Reference in a new issue