wip glusterfs

This commit is contained in:
2021-12-24 22:45:48 -05:00
parent d3d692865c
commit 697b00fa4e
22 changed files with 560 additions and 0 deletions

View File

@@ -0,0 +1,67 @@
---
# playbook for gluster file servers
- name: Gluster FS management
hosts: gfs
gather_facts: true
become: true
vars:
# glusterfs_default_release: 6
glusterfs_ppa_version: 6
cluster:
- cubox-i
- home
mountpoints:
- /data/glusterfs/vmshares/brick1
- /data/glusterfs/gitea/brick1
- /data/glusterfs/jenkins/brick1
- /data/glusterfs/jenkins2/brick1
- /data/glusterfs/tmp/brick1
- /data/glusterfs/prometheus/brick1
- /data/glusterfs/nextcloud/brick1
- /data/glusterfs/mariadb/brick1
- /data/glusterfs/postgresql/brick1
volumes:
gitea:
- /data/glusterfs/gitea/brick1/brick
jenkins2:
- /data/glusterfs/jenkins2/brick1/brick
vmshares:
- /data/glusterfs/vmshares/brick1/brick
mariadb:
- /data/glusterfs/mariadb/brick1/brick
plex:
- /data/glusterfs/plex/brick1/brick
nextcloud:
- /data/glusterfs/nextcloud/brick1/brick
nextcloud2:
- /data/glusterfs/nextcloud2/brick1/brick
distributed_volumes:
tmp:
- /data/glusterfs/tmp/brick1/brick
prometheus:
- /data/glusterfs/prometheus/brick1
# elasticsearch:
# - /data/glusterfs/elasticsearch/brick1/brick
removed_volumes:
postgresql:
- /data/glusterfs/postgresql/brick1/brick
# jenkins:
# - /data/glusterfs/jenkins/brick1/brick
# tmp:
# - /data/glusterfs/tmp/brick1/brick
roles:
# - geerlingguy.glusterfs
- glusterfs
# - td-agent-bit
post_tasks:
- name: check service is up
ansible.builtin.service:
name: "{{ glusterfs_daemon }}"
state: started
enabled: true

View File

@@ -0,0 +1,2 @@
skip_list:
- '106'

View File

@@ -0,0 +1,4 @@
# These are supported funding model platforms
---
github: geerlingguy
patreon: geerlingguy

View File

@@ -0,0 +1,56 @@
# Configuration for probot-stale - https://github.com/probot/stale
# Number of days of inactivity before an Issue or Pull Request becomes stale
daysUntilStale: 90
# Number of days of inactivity before an Issue or Pull Request with the stale label is closed.
# Set to false to disable. If disabled, issues still need to be closed manually, but will remain marked as stale.
daysUntilClose: 30
# Only issues or pull requests with all of these labels are check if stale. Defaults to `[]` (disabled)
onlyLabels: []
# Issues or Pull Requests with these labels will never be considered stale. Set to `[]` to disable
exemptLabels:
- pinned
- security
- planned
# Set to true to ignore issues in a project (defaults to false)
exemptProjects: false
# Set to true to ignore issues in a milestone (defaults to false)
exemptMilestones: false
# Set to true to ignore issues with an assignee (defaults to false)
exemptAssignees: false
# Label to use when marking as stale
staleLabel: stale
# Limit the number of actions per hour, from 1-30. Default is 30
limitPerRun: 30
pulls:
markComment: |-
This pull request has been marked 'stale' due to lack of recent activity. If there is no further activity, the PR will be closed in another 30 days. Thank you for your contribution!
Please read [this blog post](https://www.jeffgeerling.com/blog/2020/enabling-stale-issue-bot-on-my-github-repositories) to see the reasons why I mark pull requests as stale.
unmarkComment: >-
This pull request is no longer marked for closure.
closeComment: >-
This pull request has been closed due to inactivity. If you feel this is in error, please reopen the pull request or file a new PR with the relevant details.
issues:
markComment: |-
This issue has been marked 'stale' due to lack of recent activity. If there is no further activity, the issue will be closed in another 30 days. Thank you for your contribution!
Please read [this blog post](https://www.jeffgeerling.com/blog/2020/enabling-stale-issue-bot-on-my-github-repositories) to see the reasons why I mark issues as stale.
unmarkComment: >-
This issue is no longer marked for closure.
closeComment: >-
This issue has been closed due to inactivity. If you feel this is in error, please reopen the issue or file a new issue with the relevant details.

View File

@@ -0,0 +1,3 @@
*.retry
*/__pycache__
*.pyc

View File

@@ -0,0 +1,33 @@
---
language: python
services: docker
env:
global:
- ROLE_NAME: glusterfs
matrix:
- MOLECULE_DISTRO: centos7
- MOLECULE_DISTRO: ubuntu1804
- MOLECULE_DISTRO: ubuntu1604
- MOLECULE_DISTRO: debian10
before_install:
# Upgrade Docker to work with docker-py.
- curl https://gist.githubusercontent.com/geerlingguy/ce883ad4aec6a5f1187ef93bd338511e/raw/36612d28981d92863f839c5aefe5b7dd7193d6c6/travis-ci-docker-upgrade.sh | sudo bash
install:
# Install test dependencies.
- pip install molecule[docker] yamllint ansible-lint docker
before_script:
# Use actual Ansible Galaxy role name for the project directory.
- cd ../
- mv ansible-role-$ROLE_NAME geerlingguy.$ROLE_NAME
- cd geerlingguy.$ROLE_NAME
script:
# Run tests.
- molecule test
notifications:
webhooks: https://galaxy.ansible.com/api/v1/notifications/

View File

@@ -0,0 +1,10 @@
---
extends: default
rules:
line-length:
max: 120
level: warning
ignore: |
.github/stale.yml

View File

@@ -0,0 +1,20 @@
The MIT License (MIT)
Copyright (c) 2017 Jeff Geerling
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

View File

@@ -0,0 +1,49 @@
# Ansible Role: GlusterFS
[![Build Status](https://travis-ci.org/geerlingguy/ansible-role-glusterfs.svg?branch=master)](https://travis-ci.org/geerlingguy/ansible-role-glusterfs)
Installs and configures GlusterFS on Linux.
## Requirements
For GlusterFS to connect between servers, TCP ports `24007`, `24008`, and `24009`/`49152`+ (that port, plus an additional incremented port for each additional server in the cluster; the latter if GlusterFS is version 3.4+), and TCP/UDP port `111` must be open. You can open these using whatever firewall you wish (this can easily be configured using the `geerlingguy.firewall` role).
This role performs basic installation and setup of Gluster, but it does not configure or mount bricks (volumes), since that step is easier to do in a series of plays in your own playbook. Ansible 1.9+ includes the [`gluster_volume`](https://docs.ansible.com/gluster_volume_module.html) module to ease the management of Gluster volumes.
## Role Variables
Available variables are listed below, along with default values (see `defaults/main.yml`):
glusterfs_default_release: ""
You can specify a `default_release` for apt on Debian/Ubuntu by overriding this variable. This is helpful if you need a different package or version for the main GlusterFS packages (e.g. GlusterFS 3.5.x instead of 3.2.x with the `wheezy-backports` default release on Debian Wheezy).
glusterfs_ppa_use: true
glusterfs_ppa_version: "LATEST"
For Ubuntu, specify whether to use the official Gluster PPA, and which version of the PPA to use. See Gluster's [Getting Started Guide](https://docs.gluster.org/en/latest/Install-Guide/Install/) for more info.
glusterfs_gpg_key_version: "7"
glusterfs_deb_version: "LATEST"
For Debian, specify the version of the GPG key and apt package repository to use. See Gluster's [Getting Started Guide](https://docs.gluster.org/en/latest/Install-Guide/Install/) for more info.
## Dependencies
None.
## Example Playbook
- hosts: server
roles:
- geerlingguy.glusterfs
For a real-world use example, read through [Simple GlusterFS Setup with Ansible](https://www.jeffgeerling.com/blog/simple-glusterfs-setup-ansible), a blog post by this role's author, which is included in Chapter 8 of [Ansible for DevOps](https://www.ansiblefordevops.com/).
## License
MIT / BSD
## Author Information
This role was created in 2015 by [Jeff Geerling](https://www.jeffgeerling.com/), author of [Ansible for DevOps](https://www.ansiblefordevops.com/).

View File

@@ -0,0 +1,11 @@
---
glusterfs_daemon: glusterd
# For Ubuntu.
glusterfs_default_release: ""
glusterfs_ppa_use: true
glusterfs_ppa_version: "7"
# For Debian.
glusterfs_gpg_key_version: "7"
glusterfs_deb_version: "LATEST"

View File

@@ -0,0 +1,2 @@
install_date: Fri 24 Dec 2021 01:28:19 AM
version: 3.1.2

View File

@@ -0,0 +1,34 @@
---
dependencies: []
galaxy_info:
role_name: glusterfs
author: geerlingguy
description: GlusterFS installation for Linux.
company: "Midwestern Mac, LLC"
license: "license (BSD, MIT)"
min_ansible_version: 2.0
platforms:
- name: EL
versions:
- 6
- 7
- name: Ubuntu
versions:
- trusty
- xenial
- bionic
- name: Debian
versions:
- wheezy
- jessie
- stretch
galaxy_tags:
- system
- networking
- cloud
- clustering
- files
- sharing
- gluster
- glusterfs

View File

@@ -0,0 +1,12 @@
---
- name: Converge
hosts: all
become: true
pre_tasks:
- name: Update apt cache.
apt: update_cache=yes cache_valid_time=600
when: ansible_os_family == 'Debian'
roles:
- role: geerlingguy.glusterfs

View File

@@ -0,0 +1,21 @@
---
dependency:
name: galaxy
driver:
name: docker
lint: |
set -e
yamllint .
ansible-lint
platforms:
- name: instance
image: "geerlingguy/docker-${MOLECULE_DISTRO:-centos7}-ansible:latest"
command: ${MOLECULE_DOCKER_COMMAND:-""}
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:ro
privileged: true
pre_build_image: true
provisioner:
name: ansible
playbooks:
converge: ${MOLECULE_PLAYBOOK:-converge.yml}

View File

@@ -0,0 +1,17 @@
---
- name: Override glusterfs_daemon for Ubuntu 14.04.
set_fact:
glusterfs_daemon: glusterfs-server
when:
- ansible_distribution == 'Ubuntu'
- ansible_distribution_version == "14.04"
# Setup/install tasks.
- include: setup-RedHat.yml
when: ansible_os_family == 'RedHat'
- include: setup-{{ ansible_distribution }}.yml
when: ansible_os_family == 'Debian'
- name: Ensure GlusterFS is started and enabled at boot.
service: "name={{ glusterfs_daemon }} state=started enabled=yes"

View File

@@ -0,0 +1,45 @@
---
- name: Ensure dependencies are installed.
apt:
name:
- gnupg2
- apt-transport-https
- ca-certificates
state: present
- name: Ensure repository pubkey for GlusterFS is present.
apt_key:
url: 'https://download.gluster.org/pub/gluster/glusterfs/{{ glusterfs_gpg_key_version }}/rsa.pub'
state: present
register: glusterfs_pub_key_added
- name: Get the DEB architecture.
command: dpkg --print-architecture
changed_when: false
register: deb_architecture
- name: Ensure debian repo is present.
apt_repository:
repo: "deb https://download.gluster.org/pub/gluster/glusterfs/{{ glusterfs_deb_version }}/Debian/\
{{ ansible_distribution_release }}/{{ deb_architecture.stdout }}/apt {{ ansible_distribution_release }} \
main"
state: present
filename: gluster
register: glusterfs_deb_source_added
- name: Ensure GlusterFS will reinstall if the DEB source was just added.
apt:
name:
- glusterfs-server
- glusterfs-client
state: absent
when: glusterfs_deb_source_added.changed
tags: ['skip_ansible_lint']
- name: Ensure GlusterFS is installed.
apt:
name:
- glusterfs-server
- glusterfs-client
state: present
default_release: "{{ glusterfs_default_release }}"

View File

@@ -0,0 +1,12 @@
---
- name: Ensure dependencies are installed.
yum:
name: "centos-release-gluster{{ glusterfs_default_release }}"
state: present
- name: Ensure Gluster packages are installed.
yum:
name:
- glusterfs-server
- glusterfs-client
state: present

View File

@@ -0,0 +1,30 @@
---
- name: Ensure dependencies are installed.
apt:
name: dirmngr
state: present
- name: Ensure PPA for GlusterFS is present.
apt_repository:
repo: 'ppa:gluster/glusterfs-{{ glusterfs_ppa_version }}'
state: present
update_cache: true
register: glusterfs_ppa_added
when: glusterfs_ppa_use
- name: Ensure GlusterFS will reinstall if the PPA was just added.
apt:
name:
- glusterfs-server
- glusterfs-client
state: absent
when: glusterfs_ppa_added.changed
tags: ['skip_ansible_lint']
- name: Ensure GlusterFS is installed.
apt:
name:
- glusterfs-server
- glusterfs-client
state: present
default_release: "{{ glusterfs_default_release }}"

View File

@@ -0,0 +1,29 @@
---
# main tasks for installing glusterfs
# install packages
- name: Ensure glusterfs server is installed.
apt:
name: "{{ item }}"
update_cache: yes
cache_valid_time: 3600
state: latest
with_items:
- glusterfs-server
- xfsprogs
- xfsdump
- name: Start service k3s, if not started
block:
- name: start on home
ansible.builtin.service:
name: glusterd
state: started
when: "ansible_lsb.major_release >= '20'"
- name: start on cubox-i
ansible.builtin.service:
name: glusterfs-server
state: started
when: "ansible_lsb.major_release < '20'"

View File

@@ -0,0 +1,15 @@
---
- name: install on ubuntu
ansible.builtin.include_role:
name: geerlingguy.glusterfs
when: ansible_architecture != 'armv7l'
- include_tasks: install.yaml
when: ansible_architecture == 'armv7l'
- include_tasks: manage_volumes.yml
#- include_tasks: prometheus_exporter.yml

View File

@@ -0,0 +1,57 @@
---
# glusterfs mounts
# create mount points
- name: create mount points for all bricks in all volumes
file:
path: "{{ item }}"
state: directory
mode: 0755
with_items: "{{mountpoints}}"
# manage volumes
#- name: remove old gluster volumes
# gluster_volume:
# state: absent
# name: "{{ item.key }}"
# rebalance: no
# replicas: false
# cluster: "{{cluster}}"
# with_dict: "{{removed_volumes}}"
# run_once: true
- name: create gluster volumes
gluster_volume:
state: present
start_on_create: yes
name: "{{ item.key }}"
brick: '{{ item.value | join(",")}}'
rebalance: no
replicas: 2
force: true
cluster: "{{cluster}}"
with_dict: "{{volumes}}"
run_once: true
#- name: create tmp gluster volumes
# gluster_volume:
# state: present
# name: "tmp"
# brick: '/data/glusterfs/tmp/brick1/brick'
# rebalance: no
# replicas: 1
# cluster: "{{cluster}}"
# run_once: true
- name: create distributed gluster volumes
gluster_volume:
state: present
name: "{{ item.key }}"
brick: '{{ item.value | join(",")}}'
rebalance: no
replicas: false
force: true
cluster: "{{cluster}}"
with_dict: "{{distributed_volumes}}"
run_once: true

View File

@@ -0,0 +1,31 @@
---
# tasks to install prometheus gluster_exporter
# https://github.com/ofesseler/gluster_exporter
# install packages
- name: Update apt cache.
apt: update_cache=yes cache_valid_time=86400
- name: Install gluster_exporter dependencies.
apt: "name={{ item }} state=installed"
with_items:
- golang-go
- name: make golang workspace
file:
path: /opt/golang
state: directory
mode: 0775
- name: install gluster_exporter
shell: GOPATH=/opt/golang go get github.com/ofesseler/gluster_exporter
- name: add gluster_exporter to startup
lineinfile:
dest: /etc/rc.local
regexp: '/opt/golang/bin/gluster_exporter'
line: 'nohup /opt/golang/bin/gluster_exporter --profile &'
insertbefore: "^exit 0"
- name: start gluster_exporter
shell: nohup /opt/golang/bin/gluster_exporter --profile &