From bff985deb46b1581c4a93e6ec87a9c820260e2a4 Mon Sep 17 00:00:00 2001 From: enggnr <129082112+enggnr@users.noreply.github.com> Date: Thu, 29 Jun 2023 12:48:00 +0530 Subject: [PATCH] Script to add servers to Storage Pool --- home/.chezmoi.yaml.tmpl | 5 +++ ...onchange_before_11-add-glusterfs-peer.tmpl | 33 +++++++++++++++++++ software.yml | 9 +++-- 3 files changed, 42 insertions(+), 5 deletions(-) create mode 100644 home/.chezmoiscripts/universal/run_onchange_before_11-add-glusterfs-peer.tmpl diff --git a/home/.chezmoi.yaml.tmpl b/home/.chezmoi.yaml.tmpl index bc2469e8..44da58f7 100644 --- a/home/.chezmoi.yaml.tmpl +++ b/home/.chezmoi.yaml.tmpl @@ -140,6 +140,11 @@ data: docker: doRegion: nyc1 domain: "{{ $domain }}" + glusterfs: + peers: + - 10.1.1.10 + - 10.1.1.11 + - 10.1.1.12 headless: {{ $headless }} home: "{{ .chezmoi.homeDir }}" homeParentFolder: "{{ if eq .chezmoi.os "linux" }}/home{{ else if eq .chezmoi.os "darwin" }}/Users{{ else }}C:\Users{{ end }}" diff --git a/home/.chezmoiscripts/universal/run_onchange_before_11-add-glusterfs-peer.tmpl b/home/.chezmoiscripts/universal/run_onchange_before_11-add-glusterfs-peer.tmpl new file mode 100644 index 00000000..cec4edef --- /dev/null +++ b/home/.chezmoiscripts/universal/run_onchange_before_11-add-glusterfs-peer.tmpl @@ -0,0 +1,33 @@ +{{- if (eq .host.distro.family "linux") -}} +#!/usr/bin/env bash +# @file GlusterFS Trusted Storage Pool +# @brief Adds servers to GlusterFS to create/expand a Trusted Storage Pool +# @description +# This script adds the given list of servers/peers to the Trusted Storage Pool. After installing Gluster +# on your servers and before creating a trusted storage pool, each server belongs to a storage pool +# consisting of only that server. This script performs 'peer probing' to add the given list of servers +# forming a Trusted Storage Pool. If a Trusted Storage Pool exists, the given servers are added to it. +# +# ## Configuration Variables +# +# The following chart details the input variable(s) that are used to determine the configuration of the glusterfs: +# +# | Variable | Description | +# |--------------------|------------------------------------------------------------| +# | `glusterfs.peers` | List of servers to be added to the Trusted Storage Pool | + +{{ includeTemplate "universal/profile-before" }} +{{ includeTemplate "universal/logg-before" }} + +### Add servers to Trusted Storage Pool +if command -v gluster > /dev/null; then + logg info 'Adding servers to Gluster Trusted Storage Pool' + {{ if and .glusterfs.peers (gt (len .glusterfs.peers) 0) }} + {{- range .glusterfs.peers -}} + sudo gluster peer probe {{ . }} || echo 'Failed adding the peer {{ . }}' + {{ end }} + {{ end }} +else + logg info 'Gluster is not installed or it is not available in the PATH' +fi +{{ end -}} diff --git a/software.yml b/software.yml index 362b17cb..09511f42 100644 --- a/software.yml +++ b/software.yml @@ -2359,7 +2359,7 @@ softwarePackages: cask: prezi-video orbstack: _bin: orb - _github: + _github: _name: OrbStack _when:cask: '! test -d /Applications/OrbStack.app' cask: orbstack @@ -3667,7 +3667,6 @@ softwarePackages: scoop: glow yay: glow glusterfs: - # TODO - The master / peer logic still needs to be implemented in the .chezmoiscripts _bin: gluster _desc: '[Gluster](https://www.gluster.org/) is a free and open source software scalable network filesystem. Gluster is a software defined distributed storage that can scale to several petabytes. It provides interfaces for object, block and file storage.' _docs: https://docs.gluster.org/en/latest/ @@ -5834,7 +5833,7 @@ softwarePackages: generator-ngx-rocket: _bin: ngx _github: https://github.com/ngx-rocket/generator-ngx-rocket - _name: Angular + _name: Angular npm: generator-ngx-rocket ngxtop: _bin: ngxtop @@ -7175,7 +7174,7 @@ softwarePackages: zypper: xrdp yay: xrdp kasmvnc: - _bin: + _bin: dnf: https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm responsively: _bin: null @@ -8372,7 +8371,7 @@ softwarePackages: scoop: dua xbps: dua-cli soduto: - _github: + _github: _name: Soduto _when:cask: '! test -d /Applications/Soduto.app' cask: soduto