├── .gitignore ├── tests ├── inventory ├── test.yml └── run-centos-ci.sh ├── vars └── main.yml ├── handlers └── main.yml ├── roles ├── backend_reset │ ├── tests │ │ ├── inventory │ │ └── test.yml │ ├── vars │ │ └── main.yml │ ├── defaults │ │ └── main.yml │ ├── handlers │ │ └── main.yml │ ├── tasks │ │ └── main.yml │ ├── README.md │ └── meta │ │ └── main.yml ├── backend_setup │ ├── tests │ │ ├── inventory │ │ └── test.yml │ ├── vars │ │ └── main.yml │ ├── defaults │ │ └── main.yml │ ├── handlers │ │ └── main.yml │ ├── tasks │ │ ├── regenerate_new_lvm_filter_rules.yml │ │ ├── lvm_exclude_filter.yml │ │ ├── fstrim_service.yml │ │ ├── lvm_config.yml │ │ ├── main-lvm.yml │ │ ├── lvm_kernelparams.yml │ │ ├── get_vg_groupings.yml │ │ ├── blacklist_mpath_devices.yml │ │ ├── luks_device_encrypt.yml │ │ ├── mount.yml │ │ ├── cache_setup.yml │ │ ├── bind_tang_server.yml │ │ ├── vg_create.yml │ │ ├── vdo_create.yml │ │ ├── main.yml │ │ ├── fscreate.yml │ │ ├── thick_lv_create.yml │ │ ├── thin_volume_create.yml │ │ └── thin_pool_create.yml │ ├── .yamllint │ ├── molecule │ │ └── default │ │ │ ├── prepare.yml │ │ │ ├── INSTALL.rst │ │ │ ├── molecule.yml │ │ │ ├── destroy.yml │ │ │ ├── tests │ │ │ └── test_default.py │ │ │ ├── Dockerfile.j2 │ │ │ └── playbook.yml │ ├── templates │ │ └── fstrim.timer.j2 │ ├── meta │ │ └── main.yml │ └── README.md └── firewall_config │ ├── tests │ ├── inventory │ └── test.yml │ ├── handlers │ └── main.yml │ ├── defaults │ └── main.yml │ ├── molecule │ └── default │ │ ├── prepare.yml │ │ ├── molecule.yml │ │ ├── INSTALL.rst │ │ ├── playbook.yml │ │ ├── tests │ │ └── test_default.py │ │ └── Dockerfile.j2 │ ├── vars │ └── main.yml │ ├── tasks │ └── main.yml │ ├── meta │ └── main.yml │ └── README.md ├── playbooks ├── brick_reset.yml ├── brick_reset_vars.yml ├── create_brick.yml ├── bricks_vdo.yml └── bricks.yml ├── meta └── main.yml ├── defaults └── main.yml ├── tasks └── main.yml ├── gluster-ansible-infra.spec ├── README.md └── LICENSE /.gitignore: -------------------------------------------------------------------------------- 1 | *.pyc 2 | -------------------------------------------------------------------------------- /tests/inventory: -------------------------------------------------------------------------------- 1 | localhost 2 | 3 | -------------------------------------------------------------------------------- /vars/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # vars file for gluster.infra -------------------------------------------------------------------------------- /handlers/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # handlers file for gluster.infra -------------------------------------------------------------------------------- /roles/backend_reset/tests/inventory: -------------------------------------------------------------------------------- 1 | localhost 2 | 3 | -------------------------------------------------------------------------------- /roles/backend_setup/tests/inventory: -------------------------------------------------------------------------------- 1 | localhost 2 | 3 | -------------------------------------------------------------------------------- /roles/firewall_config/tests/inventory: -------------------------------------------------------------------------------- 1 | localhost 2 | 3 | -------------------------------------------------------------------------------- /roles/backend_reset/vars/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # vars file for backend-reset -------------------------------------------------------------------------------- /roles/backend_reset/defaults/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # defaults file for backend-reset -------------------------------------------------------------------------------- /roles/backend_reset/handlers/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # handlers file for backend-reset -------------------------------------------------------------------------------- /roles/backend_setup/vars/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # vars file for backend-setup\n 3 | -------------------------------------------------------------------------------- /roles/backend_setup/defaults/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # defaults file for backend-setup 3 | -------------------------------------------------------------------------------- /roles/backend_setup/handlers/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # handlers file for backend-setup\n 3 | -------------------------------------------------------------------------------- /tests/test.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - hosts: localhost 3 | remote_user: root 4 | roles: 5 | - gluster.infra -------------------------------------------------------------------------------- /roles/backend_reset/tests/test.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - hosts: localhost 3 | remote_user: root 4 | roles: 5 | - backend-reset -------------------------------------------------------------------------------- /roles/backend_setup/tests/test.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - hosts: localhost 3 | remote_user: root 4 | roles: 5 | - backend-setup -------------------------------------------------------------------------------- /roles/firewall_config/tests/test.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - hosts: localhost 3 | remote_user: root 4 | roles: 5 | - firewall_config -------------------------------------------------------------------------------- /roles/firewall_config/handlers/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # handlers file for firewall_config 3 | - name: Reload firewall 4 | command: firewall-cmd --reload 5 | -------------------------------------------------------------------------------- /roles/backend_setup/tasks/regenerate_new_lvm_filter_rules.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - name: Regenerate new LVM filter rules 3 | shell: > 4 | vdsm-tool config-lvm-filter -y 5 | -------------------------------------------------------------------------------- /roles/backend_setup/tasks/lvm_exclude_filter.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - name: Remove the existing LVM filter 3 | shell: > 4 | sed -i /^filter/d /etc/lvm/lvm.conf 5 | ignore_errors: yes 6 | 7 | -------------------------------------------------------------------------------- /playbooks/brick_reset.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - name: Reset the bricks 3 | remote_user: root 4 | gather_facts: no 5 | hosts: all 6 | vars_files: 7 | - brick_reset_vars.yml 8 | 9 | roles: 10 | - gluster.infra 11 | -------------------------------------------------------------------------------- /playbooks/brick_reset_vars.yml: -------------------------------------------------------------------------------- 1 | gluster_infra_reset_mnt_paths: 2 | - /mnt/brick0 3 | - /mnt/brick1 4 | gluster_infra_reset_volume_groups: 5 | - vg_vdb 6 | - vg_vdc 7 | gluster_infra_reset_vdos: 8 | - foo_1 9 | - foo_2 10 | -------------------------------------------------------------------------------- /playbooks/create_brick.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - name: Create a GlusterFS brick on the servers 3 | remote_user: root 4 | hosts: all 5 | gather_facts: false 6 | vars_files: 7 | - bricks.yml 8 | 9 | roles: 10 | - gluster.infra 11 | -------------------------------------------------------------------------------- /roles/backend_setup/.yamllint: -------------------------------------------------------------------------------- 1 | extends: default 2 | 3 | rules: 4 | braces: 5 | max-spaces-inside: 1 6 | level: error 7 | brackets: 8 | max-spaces-inside: 1 9 | level: error 10 | line-length: disable 11 | # NOTE(retr0h): Templates no longer fail this lint rule. 12 | # Uncomment if running old Molecule templates. 13 | # truthy: disable 14 | -------------------------------------------------------------------------------- /roles/firewall_config/defaults/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # defaults: For GlusterFS we need to enable these ports 3 | # gluster_infra_fw_ports: 4 | # - 111/tcp 5 | # - 2049/tcp 6 | # - 139/tcp 7 | # - 445/tcp 8 | # - 24007-24108/tcp 9 | # - 38465-38469/tcp 10 | # - 39543/tcp 11 | # - 49152-49251/tcp 12 | # - 54321/tcp 13 | # - 55863/tcp 14 | # gluster_infra_fw_services: 15 | # - glusterfs 16 | -------------------------------------------------------------------------------- /roles/firewall_config/molecule/default/prepare.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - name: Prepare 3 | hosts: all 4 | tasks: 5 | - name: Install Dependency Packages 6 | yum: 7 | name: "{{ packages }}" 8 | state: latest 9 | vars: 10 | packages: 11 | - firewalld 12 | - centos-release-gluster 13 | 14 | - name: Install Dependency Packages 15 | yum: 16 | name: glusterfs-server 17 | state: latest 18 | -------------------------------------------------------------------------------- /meta/main.yml: -------------------------------------------------------------------------------- 1 | galaxy_info: 2 | author: Sachidananda Urs 3 | description: https://github.com/sac 4 | company: Red Hat Inc. 5 | 6 | license: GPLv3 7 | min_ansible_version: 2.5 8 | github_branch: master 9 | 10 | platforms: 11 | - name: Fedora 12 | versions: 13 | - all 14 | - name: RHEL 15 | versions: 16 | - 7.3 or above 17 | galaxy_tags: 18 | - firewall 19 | - backend_setup 20 | 21 | dependencies: [] 22 | -------------------------------------------------------------------------------- /defaults/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # defaults file for gluster.infra 3 | # Defaults for firewall setup 4 | gluster_infra_fw_permanent: true 5 | gluster_infra_fw_state: enabled 6 | gluster_infra_fw_zone: public 7 | 8 | # Defaults for backend setup 9 | gluster_infra_disktype: JBOD 10 | gluster_infra_vdo_state: present 11 | gluster_infra_lv_cachelvname: glusterfs_ssd_cache 12 | # GlusterFS recommends 16G, if it has to be overridden set 13 | # this variable in playbooks 14 | -------------------------------------------------------------------------------- /roles/backend_setup/molecule/default/prepare.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - name: Prepare 3 | hosts: all 4 | tasks: 5 | - name: Allocate space to a file 6 | command: "fallocate -l 1G /var/{{item}}" 7 | args: 8 | creates: "/var/{{item}}" 9 | with_items: 10 | - data0 11 | - data1 12 | - name: Create loopback devices 13 | command: "losetup -f /var/{{item.1}}" 14 | with_together: 15 | - ['loop0', 'loop1'] 16 | - ['data0', 'data1'] 17 | loop_control: 18 | pause: 5 19 | -------------------------------------------------------------------------------- /roles/firewall_config/molecule/default/molecule.yml: -------------------------------------------------------------------------------- 1 | --- 2 | dependency: 3 | name: galaxy 4 | driver: 5 | name: docker 6 | lint: 7 | name: yamllint 8 | platforms: 9 | - name: instance 10 | image: centos/systemd 11 | command: /sbin/init 12 | volumes: 13 | - /sys/fs/cgroup:/sys/fs/cgroup:ro 14 | privileged: true 15 | provisioner: 16 | name: ansible 17 | lint: 18 | name: ansible-lint 19 | scenario: 20 | name: default 21 | verifier: 22 | name: testinfra 23 | lint: 24 | name: flake8 25 | -------------------------------------------------------------------------------- /roles/backend_setup/molecule/default/INSTALL.rst: -------------------------------------------------------------------------------- 1 | ******* 2 | Docker driver installation guide 3 | ******* 4 | 5 | Requirements 6 | ============ 7 | 8 | * General molecule dependencies (see https://molecule.readthedocs.io/en/latest/installation.html) 9 | * Docker Engine 10 | * docker-py 11 | * docker 12 | 13 | Install 14 | ======= 15 | 16 | Ansible < 2.6 17 | 18 | .. code-block:: bash 19 | 20 | $ sudo pip install docker-py 21 | 22 | Ansible >= 2.6 23 | 24 | .. code-block:: bash 25 | 26 | $ sudo pip install docker 27 | -------------------------------------------------------------------------------- /roles/firewall_config/molecule/default/INSTALL.rst: -------------------------------------------------------------------------------- 1 | ******* 2 | Docker driver installation guide 3 | ******* 4 | 5 | Requirements 6 | ============ 7 | 8 | * General molecule dependencies (see https://molecule.readthedocs.io/en/latest/installation.html) 9 | * Docker Engine 10 | * docker-py 11 | * docker 12 | 13 | Install 14 | ======= 15 | 16 | Ansible < 2.6 17 | 18 | .. code-block:: bash 19 | 20 | $ sudo pip install docker-py 21 | 22 | Ansible >= 2.6 23 | 24 | .. code-block:: bash 25 | 26 | $ sudo pip install docker 27 | -------------------------------------------------------------------------------- /roles/backend_setup/molecule/default/molecule.yml: -------------------------------------------------------------------------------- 1 | --- 2 | dependency: 3 | name: galaxy 4 | driver: 5 | name: docker 6 | lint: 7 | name: yamllint 8 | platforms: 9 | - name: instance 10 | image: centos/systemd 11 | command: /sbin/init 12 | volumes: 13 | - /sys/fs/cgroup:/sys/fs/cgroup:ro 14 | - /dev:/dev:rw 15 | privileged: true 16 | provisioner: 17 | name: ansible 18 | lint: 19 | name: ansible-lint 20 | scenario: 21 | name: default 22 | verifier: 23 | name: testinfra 24 | lint: 25 | name: flake8 26 | -------------------------------------------------------------------------------- /roles/firewall_config/molecule/default/playbook.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - name: Converge 3 | hosts: all 4 | roles: 5 | - role: firewall_config 6 | vars: 7 | gluster_infra_fw_ports: 8 | - 2049/tcp 9 | - 54321/tcp 10 | - 5900/tcp 11 | - 5900-6923/tcp 12 | - 5666/tcp 13 | - 16514/tcp 14 | gluster_infra_fw_permanent: true 15 | gluster_infra_fw_state: enabled 16 | gluster_infra_fw_zone: public 17 | gluster_infra_fw_services: 18 | - glusterfs 19 | -------------------------------------------------------------------------------- /roles/backend_setup/tasks/fstrim_service.yml: -------------------------------------------------------------------------------- 1 | --- 2 | 3 | - name: create fstrim-timer override directory 4 | file: 5 | path: /etc/systemd/system/fstrim.timer.d/ 6 | state: directory 7 | 8 | - name: schedule fstrim-timer 9 | template: 10 | src: fstrim.timer.j2 11 | dest: /etc/systemd/system/fstrim.timer.d/override.conf 12 | 13 | - name: reload systemd 14 | systemd: 15 | daemon_reload: yes 16 | 17 | - name: manage fstrim-timer 18 | systemd: 19 | name: fstrim.timer 20 | state: "{{ ((fstrim_service.enabled is defined and fstrim_service.enabled) and 'started') or 'stopped' }}" 21 | enabled: "{{ ((fstrim_service.enabled is defined and fstrim_service.enabled) and true) or false }}" 22 | 23 | 24 | -------------------------------------------------------------------------------- /tasks/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # tasks file for gluster.infra 3 | - name: Add firewall rules 4 | import_role: 5 | name: "gluster.infra/roles/firewall_config" 6 | when: > 7 | gluster_infra_fw_ports is defined or 8 | gluster_infra_fw_services is defined 9 | tags: 10 | - firewall 11 | 12 | - name: Configure the bricks 13 | import_role: 14 | name: "gluster.infra/roles/backend_setup" 15 | tags: 16 | - backend_setup 17 | 18 | - name: Reset backend 19 | import_role: 20 | name: "gluster.infra/roles/backend_reset" 21 | when: > 22 | gluster_infra_reset_mnt_paths is defined or 23 | gluster_infra_reset_volume_groups is defined or 24 | gluster_infra_reset_vdos is defined 25 | tags: 26 | - backend_reset -------------------------------------------------------------------------------- /roles/firewall_config/vars/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # List of variables supported in the firewall role for GlusterFS 3 | # gluster_infra_fw_ports is a list and the values are to be given in 4 | # port/protocol type: For example 5 | 6 | # gluster_infra_fw_ports: 7 | # - 111/tcp 8 | # - 445/tcp 9 | # gluster_infra_fw_ports: 10 | 11 | # Whether the rules added are permanent true/false are the allowed values 12 | # gluster_infra_fw_permanent: 13 | 14 | # Firewall state: enabled, disabled 15 | # gluster_infra_fw_state: 16 | 17 | # Zone choices (work, drop, internal, external, trusted, home, dmz, public, 18 | # block) 19 | # gluster_infra_fw_zone: 20 | 21 | # This is a list variable, list of services to be enabled/disabled 22 | # (default: glusterfs) 23 | # gluster_infra_fw_services: 24 | -------------------------------------------------------------------------------- /roles/firewall_config/molecule/default/tests/test_default.py: -------------------------------------------------------------------------------- 1 | import os 2 | 3 | import testinfra.utils.ansible_runner 4 | 5 | testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner( 6 | os.environ['MOLECULE_INVENTORY_FILE']).get_hosts('all') 7 | 8 | 9 | def test_hosts_file(host): 10 | cmd = host.run("firewall-cmd --list-all") 11 | for line in cmd.stdout.split("\n"): 12 | if "services" in line: 13 | assert "glusterfs" in line 14 | for line in cmd.stdout.split("\n"): 15 | if " ports:" in line: 16 | assert "2049/tcp" in line 17 | assert "54321/tcp" in line 18 | assert "5900/tcp" in line 19 | assert "5900-6923/tcp" in line 20 | assert "5666/tcp" in line 21 | assert "16514/tcp" in line 22 | -------------------------------------------------------------------------------- /roles/backend_setup/tasks/lvm_config.yml: -------------------------------------------------------------------------------- 1 | --- 2 | 3 | #thin_pool_autoextend_threshold = 100 4 | #thin_pool_autoextend_percent = 20 5 | - name: Configure lvm thinpool extend threshold 6 | lineinfile: 7 | path: /etc/lvm/lvm.conf 8 | regex: "thin_pool_autoextend_threshold" 9 | backrefs: true 10 | line: thin_pool_autoextend_threshold = {{ gluster_infra_lvm.autoexpand_threshold }} 11 | when: gluster_infra_lvm is defined and gluster_infra_lvm.autoexpand_threshold is defined 12 | 13 | - name: Configure lvm thinpool extend percentage 14 | lineinfile: 15 | path: /etc/lvm/lvm.conf 16 | regex: "thin_pool_autoextend_percent" 17 | backrefs: true 18 | line: thin_pool_autoextend_percent = {{ gluster_infra_lvm.autoexpand_percentage }} 19 | when: gluster_infra_lvm is defined and gluster_infra_lvm.autoexpand_percentage is defined -------------------------------------------------------------------------------- /tests/run-centos-ci.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # setting up virtual environment 4 | yum -y install epel-release 5 | yum -y install libselinux-python yum-utils \ 6 | device-mapper-persistent-data \ 7 | lvm2 gcc python-virtualenv 8 | virtualenv --system-site-packages env 9 | source env/bin/activate 10 | 11 | # install dependency packages 12 | pip install ansible molecule docker-py 13 | 14 | # prerequisites to install docker 15 | yum-config-manager \ 16 | --add-repo \ 17 | https://download.docker.com/linux/centos/docker-ce.repo 18 | yum -y install docker-ce 19 | 20 | # start and enable Docker service 21 | systemctl start docker 22 | systemctl enable docker 23 | 24 | # run tests 25 | cd gluster-ansible-infra/roles/firewall_config/ 26 | molecule create 27 | molecule test 28 | 29 | cd gluster-ansible-infra/roles/backend_setup/ 30 | molecule create 31 | molecule test 32 | -------------------------------------------------------------------------------- /roles/backend_setup/molecule/default/destroy.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - name: Prepare 3 | hosts: all 4 | tasks: 5 | - name: unmount device 6 | mount: 7 | path: "/mnt/{{item}}" 8 | state: absent 9 | with_items: 10 | - thicklv 11 | - thinlv1 12 | - thinlv2 13 | - name: Remove volume groups 14 | lvol: 15 | vg: vg_vdb 16 | state: absent 17 | pvs: /dev/loop0 18 | lv: thicklv_1 19 | force: true 20 | ignore_errors: true 21 | - name: Remove thinpool 22 | lvol: 23 | vg: vg_vdc 24 | state: absent 25 | pvs: /dev/loop1 26 | thinpool: foo_thinpool 27 | force: true 28 | ignore_errors: true 29 | - name: Clean up loopback devices 30 | command: "losetup -D" 31 | - name: Remove data files 32 | file: 33 | path: "/var/{{item}}" 34 | state: absent 35 | with_items: 36 | - data0 37 | - data1 38 | -------------------------------------------------------------------------------- /roles/backend_reset/tasks/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # tasks file for backend-reset 3 | # unmount the directories 4 | 5 | - name: unmount the directories (if mounted) 6 | mount: 7 | state: absent 8 | path: "{{ item }}" 9 | with_items: "{{ gluster_infra_reset_mnt_paths }}" 10 | when: gluster_infra_reset_mnt_paths is defined 11 | 12 | # Delete the volume groups and physical volumes 13 | - name: Delete volume groups 14 | command: "vgremove {{ item }} --force" 15 | # lvg: 16 | # vg: "{{ item }}" 17 | # state: absent 18 | # force: yes 19 | with_items: "{{ gluster_infra_reset_volume_groups }}" 20 | when: gluster_infra_reset_volume_groups is defined 21 | 22 | # Remove vdo devices if any 23 | - name: Remove VDO devices 24 | command: "vdo remove -n {{ item }} --force" 25 | # vdo: 26 | # name: "{{ item }}" 27 | # state: absent 28 | with_items: "{{ gluster_infra_reset_vdos }}" 29 | when: gluster_infra_reset_vdos is defined 30 | 31 | -------------------------------------------------------------------------------- /roles/backend_setup/molecule/default/tests/test_default.py: -------------------------------------------------------------------------------- 1 | import os 2 | 3 | import testinfra.utils.ansible_runner 4 | 5 | testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner( 6 | os.environ['MOLECULE_INVENTORY_FILE']).get_hosts('all') 7 | 8 | 9 | def test_hosts_file(host): 10 | cmd = host.run("vgdisplay") 11 | for line in cmd.stdout.split(" "): 12 | if "VG Name" in line: 13 | assert "vg_vdb" in line 14 | assert "vg_vdc" in line 15 | cmd = host.run("lvdisplay") 16 | for line in cmd.stdout.split(" "): 17 | if "LV Path" in line: 18 | assert "/dev/vg_vdc/vg_vdc_thinlv1" in line 19 | assert "/dev/vg_vdc/vg_vdc_thinlv2" in line 20 | assert "/dev/vg_vdb/thicklv_1" in line 21 | if "LV Name" in line: 22 | assert "foo_thinpool" in line 23 | assert "vg_vdc_thinlv1" in line 24 | assert "vg_vdc_thinlv2" in line 25 | assert "thicklv_1" in line 26 | -------------------------------------------------------------------------------- /roles/backend_setup/tasks/main-lvm.yml: -------------------------------------------------------------------------------- 1 | --- 2 | 3 | - name: Create a volume group 4 | import_tasks: vg_create.yml 5 | when: gluster_infra_volume_groups is defined 6 | tags: 7 | - vgcreate 8 | 9 | # If a thick volume is requested for the same vg 10 | - name: Create a thick logical volume 11 | import_tasks: thick_lv_create.yml 12 | when: gluster_infra_thick_lvs is defined 13 | tags: 14 | - thickvol 15 | 16 | # Create a thinpool for the given volume group 17 | - name: Create thin pool 18 | import_tasks: thin_pool_create.yml 19 | when: gluster_infra_thinpools is defined 20 | tags: 21 | - thinpool 22 | 23 | # Create a thin volume 24 | - name: Create thin logical volume 25 | import_tasks: thin_volume_create.yml 26 | when: gluster_infra_lv_logicalvols is defined 27 | tags: 28 | - thinvol 29 | 30 | # Setup cache on the given SSD 31 | - name: Setup cache 32 | import_tasks: cache_setup.yml 33 | when: gluster_infra_cache_vars is defined and gluster_infra_cache_vars is not none 34 | tags: 35 | - cachesetup 36 | 37 | -------------------------------------------------------------------------------- /roles/firewall_config/molecule/default/Dockerfile.j2: -------------------------------------------------------------------------------- 1 | # Molecule managed 2 | 3 | {% if item.registry is defined %} 4 | FROM {{ item.registry.url }}/{{ item.image }} 5 | {% else %} 6 | FROM {{ item.image }} 7 | {% endif %} 8 | 9 | RUN if [ $(command -v apt-get) ]; then apt-get update && apt-get install -y python sudo bash ca-certificates && apt-get clean; \ 10 | elif [ $(command -v dnf) ]; then dnf makecache && dnf --assumeyes install python sudo python-devel python2-dnf bash && dnf clean all; \ 11 | elif [ $(command -v yum) ]; then yum makecache fast && yum install -y python sudo yum-plugin-ovl bash && sed -i 's/plugins=0/plugins=1/g' /etc/yum.conf && yum clean all; \ 12 | elif [ $(command -v zypper) ]; then zypper refresh && zypper install -y python sudo bash python-xml && zypper clean -a; \ 13 | elif [ $(command -v apk) ]; then apk update && apk add --no-cache python sudo bash ca-certificates; \ 14 | elif [ $(command -v xbps-install) ]; then xbps-install -Syu && xbps-install -y python sudo bash ca-certificates && xbps-remove -O; fi 15 | -------------------------------------------------------------------------------- /roles/backend_setup/molecule/default/Dockerfile.j2: -------------------------------------------------------------------------------- 1 | # Molecule managed 2 | 3 | {% if item.registry is defined %} 4 | FROM {{ item.registry.url }}/{{ item.image }} 5 | {% else %} 6 | FROM {{ item.image }} 7 | {% endif %} 8 | 9 | RUN if [ $(command -v apt-get) ]; then apt-get update && apt-get install -y python sudo bash ca-certificates && apt-get clean; \ 10 | elif [ $(command -v dnf) ]; then dnf makecache && dnf --assumeyes install python sudo python-devel python2-dnf bash && dnf clean all; \ 11 | elif [ $(command -v yum) ]; then yum makecache fast && yum install -y python sudo yum-plugin-ovl bash && sed -i 's/plugins=0/plugins=1/g' /etc/yum.conf && yum clean all; \ 12 | elif [ $(command -v zypper) ]; then zypper refresh && zypper install -y python sudo bash python-xml && zypper clean -a; \ 13 | elif [ $(command -v apk) ]; then apk update && apk add --no-cache python sudo bash ca-certificates; \ 14 | elif [ $(command -v xbps-install) ]; then xbps-install -Syu && xbps-install -y python sudo bash ca-certificates && xbps-remove -O; fi 15 | 16 | RUN yum install -y lvm2 util-linux libudev-devel libselinux-python gcc python-virtualenv xfsprogs policycoreutils-python 17 | -------------------------------------------------------------------------------- /roles/backend_setup/templates/fstrim.timer.j2: -------------------------------------------------------------------------------- 1 | {% macro timeUnit(unit, max) -%} 2 | {%- if unit is not defined or unit is none -%} 3 | {{- max | random -}} 4 | {%- else -%} 5 | {{- unit -}} 6 | {%- endif -%} 7 | {%- endmacro -%} 8 | 9 | [Timer] 10 | #AccuracySec=1s 11 | {% if fstrim_service.schedule is defined and fstrim_service.schedule is not none 12 | and fstrim_service.schedule.dow is not defined and fstrim_service.schedule.dow is not none 13 | and fstrim_service.schedule.hour is not defined and fstrim_service.schedule.hour is not none 14 | and fstrim_service.schedule.second is not defined and fstrim_service.schedule.second is not none 15 | -%} 16 | {%- else -%} 17 | OnCalendar= 18 | OnCalendar={%- if fstrim_service.schedule.dow is not defined or fstrim_service.schedule.dow is none -%} 19 | {{- ['Mon','Tue','Wed','Thu','Fri','Sat','Sun'] | random() -}} 20 | {%- else -%} 21 | {{- fstrim_service.schedule.dow -}} 22 | {%- endif -%} 23 | {{- ' *-*-* ' -}} 24 | {{- timeUnit(fstrim_service.schedule.hour, 24) -}} 25 | {{- ':' -}} 26 | {{- timeUnit(fstrim_service.schedule.minute, 60) -}} 27 | {{- ':' -}} 28 | {{- timeUnit(fstrim_service.schedule.second, 60) -}} 29 | {%- endif -%} -------------------------------------------------------------------------------- /roles/firewall_config/tasks/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # tasks file for firewall_config 3 | - name: Start firewalld if not already started 4 | service: 5 | state: started 6 | name: firewalld 7 | 8 | - name: check if required variables are set 9 | fail: 10 | msg: "gluster_infra_fw_state is undefined" 11 | when: gluster_infra_fw_state is not defined 12 | 13 | - name: Open/Close firewalld ports 14 | firewalld: 15 | port: "{{ item }}" 16 | permanent: "{{ gluster_infra_fw_permanent | default('false') }}" 17 | state: "{{ gluster_infra_fw_state }}" 18 | zone: "{{ gluster_infra_fw_zone | default('public') }}" 19 | immediate: "{{ item.immediate | default('yes') }}" 20 | with_items: "{{ gluster_infra_fw_ports }}" 21 | when: gluster_infra_fw_ports is defined 22 | notify: Reload firewall 23 | 24 | - name: Add/Delete services to firewalld rules 25 | firewalld: 26 | service: "{{ item }}" 27 | permanent: "{{ gluster_infra_fw_permanent | default('false') }}" 28 | state: "{{ gluster_infra_fw_state }}" 29 | zone: "{{ gluster_infra_fw_zone | default('public') }}" 30 | immediate: "{{ gluster_infra_fw_immediate | default('yes') }}" 31 | with_items: "{{ gluster_infra_fw_services }}" 32 | when: gluster_infra_fw_services is defined 33 | notify: Reload firewall 34 | -------------------------------------------------------------------------------- /roles/backend_reset/README.md: -------------------------------------------------------------------------------- 1 | backend_reset 2 | ========= 3 | 4 | This role unmounts the filesystem and deletes specified logical volumes and volume groups. 5 | 6 | Note: The mounted filesystems should not be busy. For example, if the GlusterFS volumes are running, then umount fails and logical volumes will not be deleted. 7 | 8 | Requirements 9 | ------------ 10 | 11 | Ansible version 2.5 or above. 12 | VDO utilities (Optional) 13 | 14 | Role Variables 15 | -------------- 16 | 17 | | Name |Required?| Default value | Comments | 18 | |--------------------------|-------|-----------------------|-----------------------------------| 19 | | gluster_infra_reset_mnt_paths | No | | Mount point of the brick which has to be unmounted and logical volumes deleted. | 20 | | gluster_infra_reset_volume_groups | No | | Name of the volume group which has to be deleted. All corresponding logical volumes and physical volumes will be deleted. | 21 | | gluster_infra_reset_vdos | No | | Name of the vdo devices that have to be removed | 22 | 23 | Example Playbook 24 | ---------------- 25 | 26 | Unmount the filesystem and delete the roles 27 | 28 | - hosts: gluster_servers 29 | vars: 30 | - gluster_infra_reset_mnt_paths: /mnt/foo 31 | - gluster_infra_reset_volume_groups: gluster_vg 32 | roles: 33 | - gluster.infra 34 | 35 | License 36 | ------- 37 | 38 | GPLv3 39 | 40 | Author Information 41 | ------------------ 42 | 43 | Sachidananda Urs 44 | -------------------------------------------------------------------------------- /gluster-ansible-infra.spec: -------------------------------------------------------------------------------- 1 | %global rolesdir %{_sysconfdir}/ansible/roles/gluster.infra 2 | %global buildnum 1 3 | 4 | Name: gluster-ansible-infra 5 | Version: 1.0.0 6 | Release: 1%{?dist} 7 | Summary: Ansible roles for GlusterFS infrastructure management 8 | 9 | URL: https://github.com/gluster/gluster-ansible-infra 10 | Source0: %{url}/archive/v%{version}.tar.gz#/%{name}-%{version}-%{buildnum}.tar.gz 11 | License: GPLv3 12 | BuildArch: noarch 13 | 14 | Requires: ansible-core >= 2.12 15 | 16 | %description 17 | Collection of Ansible roles for the deploying and managing GlusterFS clusters. 18 | The infra role enables user to configure firewall, setup backend disks, reset 19 | backend disks. 20 | 21 | %prep 22 | %autosetup -p1 23 | 24 | %build 25 | 26 | %install 27 | mkdir -p %{buildroot}/%{rolesdir} 28 | cp -dpr defaults handlers meta roles tasks tests README.md LICENSE vars playbooks README.md\ 29 | %{buildroot}/%{rolesdir} 30 | 31 | %files 32 | %{rolesdir} 33 | 34 | %license LICENSE 35 | 36 | %changelog 37 | * Wed Feb 20 2019 Sachidananda Urs 1.0.0-1 38 | - Bump the version numer to 1 39 | 40 | * Thu Jan 03 2019 Sachidananda Urs 0.6 41 | - Add example and molecule tests 42 | 43 | * Mon Oct 15 2018 Sachidananda Urs 0.5 44 | - Add Gluster specific SeLinux label on brick mounts 45 | 46 | * Fri Oct 12 2018 Sachidananda Urs 0.4 47 | - Added tests, and enhanced documentation, fixed fscreate bug 48 | - Remove xfs runtime specific configuration 49 | 50 | * Tue Sep 25 2018 Sachidananda Urs 0.3 51 | - Remove the examples directory and add backend_reset role 52 | 53 | * Fri Aug 31 2018 Sachidananda Urs 0.2 54 | - Backend setup enhancements 55 | 56 | * Tue Apr 24 2018 Sachidananda Urs 0.1 57 | - Initial release. 58 | -------------------------------------------------------------------------------- /roles/backend_setup/molecule/default/playbook.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - name: Converge 3 | hosts: all 4 | roles: 5 | - role: backend_setup 6 | vars: 7 | # Set a disk type, Options: JBOD, RAID6, RAID10 8 | gluster_infra_disktype: JBOD 9 | 10 | # RAID6 and RAID10 diskcount (Needed only when disktype is raid) 11 | gluster_infra_diskcount: 10 12 | # Stripe unit size always in KiB 13 | gluster_infra_stripe_unit_size: 128 14 | 15 | # Variables for creating volume group 16 | gluster_infra_volume_groups: 17 | - vgname: vg_vdb 18 | pvname: /dev/loop0 19 | - vgname: vg_vdc 20 | pvname: /dev/loop1 21 | 22 | # Create a thick volume name 23 | gluster_infra_thick_lvs: 24 | - vgname: vg_vdb 25 | lvname: thicklv_1 26 | size: 500M 27 | 28 | # Create thinpools 29 | gluster_infra_thinpools: 30 | - vgname: vg_vdc 31 | thinpoolname: foo_thinpool 32 | thinpoolsize: 100M 33 | poolmetadatasize: 80M 34 | 35 | # Create a thin volume 36 | gluster_infra_lv_logicalvols: 37 | - lvname: vg_vdc_thinlv1 38 | lvsize: 60M 39 | thinpool: foo_thinpool 40 | vgname: vg_vdc 41 | - lvname: vg_vdc_thinlv2 42 | lvsize: 60M 43 | thinpool: foo_thinpool 44 | vgname: vg_vdc 45 | # Mount the devices 46 | gluster_infra_mount_devices: 47 | - path: /mnt/thicklv 48 | vgname: vg_vdb 49 | lvname: thicklv_1 50 | - path: /mnt/thinlv1 51 | vgname: vg_vdc 52 | lvname: vg_vdc_thinlv1 53 | - path: /mnt/thinlv2 54 | vgname: vg_vdc 55 | lvname: vg_vdc_thinlv2 56 | # gluster_set_selinux_labels: false 57 | gluster_infra_fs_force: false 58 | -------------------------------------------------------------------------------- /roles/backend_setup/tasks/lvm_kernelparams.yml: -------------------------------------------------------------------------------- 1 | --- 2 | 3 | 4 | - name: Add lvm thick volumes as kernel parameter 5 | lineinfile: 6 | path: /etc/default/grub 7 | regex: "^LVM_ADDITIONAL_DMS" 8 | insertbefore: BOF 9 | firstmatch: true 10 | line: > 11 | {%- set output = [] -%} 12 | {%- for lv in gluster_infra_thick_lvs -%} 13 | {%- if lv.atboot is defined and lv.atboot -%} 14 | {{- output.append( 'rd.lvm.lv=' ~ lv.vgname ~ '/' ~ lv.lvname) -}} 15 | {%- endif -%} 16 | {%- endfor -%} 17 | {{- 'LVM_ADDITIONAL_DMS="' ~ (output | join(' ')) ~ '"' -}} 18 | when: gluster_infra_thick_lvs is defined and gluster_infra_thick_lvs | selectattr("atboot","defined")| selectattr("atboot") | list | length > 0 19 | register: changed_lv_boot 20 | 21 | - name: check if grub kernel parameter contains the LVM_ADDITIONAL_DMS variable 22 | shell: "grep -E 'GRUB_CMDLINE_LINUX=.*?\\$LVM_ADDITIONAL_DMS.*?' /etc/default/grub" 23 | register: has_grub_var 24 | failed_when: false 25 | 26 | - name: add lvm volumes to grub kernel parameter line 27 | lineinfile: 28 | path: /etc/default/grub 29 | regex: 'GRUB_CMDLINE_LINUX="(.*)"' 30 | line: 'GRUB_CMDLINE_LINUX="\1 $LVM_ADDITIONAL_DMS"' 31 | backrefs: yes 32 | when: has_grub_var.rc != 0 33 | register: changed_grub_cmd_line 34 | 35 | - stat: path=/boot/efi/EFI/centos/grub.cfg 36 | register: grub_conf 37 | 38 | - stat: path=/sys/firmware/efi 39 | register: firm_efi 40 | 41 | 42 | - name: "rebuild efi boot" 43 | shell: grub2-mkconfig -o /boot/efi/EFI/centos/grub.cfg 44 | when: (changed_grub_cmd_line.changed or changed_lv_boot.changed) and firm_efi.stat.exists and grub_conf.stat.exists 45 | 46 | - name: "rebuild bios boot" 47 | shell: grub2-mkconfig -o /boot/grub2/grub.cfg 48 | when: (changed_grub_cmd_line.changed or changed_lv_boot.changed) and firm_efi.stat.exists==false and grub_conf.stat.exists==false 49 | -------------------------------------------------------------------------------- /roles/backend_reset/meta/main.yml: -------------------------------------------------------------------------------- 1 | galaxy_info: 2 | author: your name 3 | description: your description 4 | company: your company (optional) 5 | 6 | # If the issue tracker for your role is not on github, uncomment the 7 | # next line and provide a value 8 | # issue_tracker_url: http://example.com/issue/tracker 9 | 10 | # Some suggested licenses: 11 | # - BSD (default) 12 | # - MIT 13 | # - GPLv2 14 | # - GPLv3 15 | # - Apache 16 | # - CC-BY 17 | license: license (GPLv2, CC-BY, etc) 18 | 19 | min_ansible_version: 1.2 20 | 21 | # If this a Container Enabled role, provide the minimum Ansible Container version. 22 | # min_ansible_container_version: 23 | 24 | # Optionally specify the branch Galaxy will use when accessing the GitHub 25 | # repo for this role. During role install, if no tags are available, 26 | # Galaxy will use this branch. During import Galaxy will access files on 27 | # this branch. If Travis integration is configured, only notifications for this 28 | # branch will be accepted. Otherwise, in all cases, the repo's default branch 29 | # (usually master) will be used. 30 | #github_branch: 31 | 32 | # 33 | # platforms is a list of platforms, and each platform has a name and a list of versions. 34 | # 35 | # platforms: 36 | # - name: Fedora 37 | # versions: 38 | # - all 39 | # - 25 40 | # - name: SomePlatform 41 | # versions: 42 | # - all 43 | # - 1.0 44 | # - 7 45 | # - 99.99 46 | 47 | galaxy_tags: [] 48 | # List tags for your role here, one per line. A tag is a keyword that describes 49 | # and categorizes the role. Users find roles by searching for tags. Be sure to 50 | # remove the '[]' above, if you add tags to this list. 51 | # 52 | # NOTE: A tag is limited to a single word comprised of alphanumeric characters. 53 | # Maximum 20 tags per role. 54 | 55 | dependencies: [] 56 | # List your role dependencies here, one per line. Be sure to remove the '[]' above, 57 | # if you add dependencies to this list. -------------------------------------------------------------------------------- /roles/backend_setup/meta/main.yml: -------------------------------------------------------------------------------- 1 | galaxy_info: 2 | author: your name 3 | description: your description 4 | company: your company (optional) 5 | 6 | # If the issue tracker for your role is not on github, uncomment the 7 | # next line and provide a value 8 | # issue_tracker_url: http://example.com/issue/tracker 9 | 10 | # Some suggested licenses: 11 | # - BSD (default) 12 | # - MIT 13 | # - GPLv2 14 | # - GPLv3 15 | # - Apache 16 | # - CC-BY 17 | license: license (GPLv2, CC-BY, etc) 18 | 19 | min_ansible_version: 1.2 20 | 21 | # If this a Container Enabled role, provide the minimum Ansible Container version. 22 | # min_ansible_container_version: 23 | 24 | # Optionally specify the branch Galaxy will use when accessing the GitHub 25 | # repo for this role. During role install, if no tags are available, 26 | # Galaxy will use this branch. During import Galaxy will access files on 27 | # this branch. If Travis integration is configured, only notifications for this 28 | # branch will be accepted. Otherwise, in all cases, the repo's default branch 29 | # (usually master) will be used. 30 | #github_branch: 31 | 32 | # 33 | # platforms is a list of platforms, and each platform has a name and a list of versions. 34 | # 35 | # platforms: 36 | # - name: Fedora 37 | # versions: 38 | # - all 39 | # - 25 40 | # - name: SomePlatform 41 | # versions: 42 | # - all 43 | # - 1.0 44 | # - 7 45 | # - 99.99 46 | 47 | galaxy_tags: [] 48 | # List tags for your role here, one per line. A tag is a keyword that describes 49 | # and categorizes the role. Users find roles by searching for tags. Be sure to 50 | # remove the '[]' above, if you add tags to this list. 51 | # 52 | # NOTE: A tag is limited to a single word comprised of alphanumeric characters. 53 | # Maximum 20 tags per role. 54 | 55 | dependencies: [] 56 | # List your role dependencies here, one per line. Be sure to remove the '[]' above, 57 | # if you add dependencies to this list. -------------------------------------------------------------------------------- /roles/firewall_config/meta/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | galaxy_info: 3 | author: your name 4 | description: your description 5 | company: your company (optional) 6 | 7 | # If the issue tracker for your role is not on github, uncomment the 8 | # next line and provide a value 9 | # issue_tracker_url: http://example.com/issue/tracker 10 | 11 | # Some suggested licenses: 12 | # - BSD (default) 13 | # - MIT 14 | # - GPLv2 15 | # - GPLv3 16 | # - Apache 17 | # - CC-BY 18 | license: license (GPLv2, CC-BY, etc) 19 | 20 | min_ansible_version: 1.2 21 | 22 | # If this a Container Enabled role, provide the minimum 23 | # Ansible Container version. 24 | # min_ansible_container_version: 25 | 26 | # Optionally specify the branch Galaxy will use when accessing the GitHub 27 | # repo for this role. During role install, if no tags are available, 28 | # Galaxy will use this branch. During import Galaxy will access files on 29 | # this branch. If Travis integration is configured 30 | # only notifications for this 31 | # branch will be accepted. Otherwise, in all cases, the repo's default branch 32 | # (usually master) will be used. 33 | # github_branch: 34 | 35 | # platforms is a list of platforms, and each 36 | # platform has a name and a list of versions. 37 | # 38 | # platforms: 39 | # - name: Fedora 40 | # versions: 41 | # - all 42 | # - 25 43 | # - name: SomePlatform 44 | # versions: 45 | # - all 46 | # - 1.0 47 | # - 7 48 | # - 99.99 49 | 50 | galaxy_tags: [] 51 | # List tags for your role here, one per line. 52 | # A tag is a keyword that describes 53 | # and categorizes the role. Users find roles by searching for tags. Be sure to 54 | # remove the '[]' above, if you add tags to this list. 55 | # NOTE: A tag is limited to a single word 56 | # comprised of alphanumeric characters. 57 | # Maximum 20 tags per role. 58 | 59 | dependencies: [] 60 | # List your role dependencies here, one per line. 61 | # Be sure to remove the '[]' above, 62 | # if you add dependencies to this list. 63 | -------------------------------------------------------------------------------- /playbooks/bricks_vdo.yml: -------------------------------------------------------------------------------- 1 | # gluster_infra_disktype 2 | # Set a disk type. Options: JBOD, RAID6, RAID10 - Default: JBOD 3 | # 4 | 5 | gluster_infra_disktype: RAID10 6 | 7 | 8 | # gluster_infra_dalign 9 | # Dataalignment, for JBOD default is 256K if not provided. 10 | # For RAID{6,10} dataalignment is computed by multiplying 11 | # gluster_infra_diskcount and gluster_infra_stripe_unit_size. 12 | 13 | gluster_infra_dalign: 256K 14 | 15 | 16 | # gluster_infra_diskcount 17 | # Required only for RAID6 and RAID10. 18 | 19 | gluster_infra_diskcount: 10 20 | 21 | 22 | # gluster_infra_stripe_unit_size 23 | # Required only in case of RAID6 and RAID10. Stripe unit size always in KiB, do 24 | # not provide the trailing `K' in the value. 25 | 26 | gluster_infra_stripe_unit_size: 128 27 | 28 | # VDO creation 29 | gluster_infra_vdo: 30 | - { name: 'hc_vdo_1', device: '/dev/vdb' } 31 | - { name: 'hc_vdo_2', device: '/dev/vdc' } 32 | 33 | # gluster_infra_volume_groups 34 | # Variables for creating volume group 35 | 36 | gluster_infra_volume_groups: 37 | - { vgname: 'vg_vdb', pvname: '/dev/mapper/hc_vdo_1' } 38 | - { vgname: 'vg_vdc', pvname: '/dev/mapper/hc_vdo_2' } 39 | 40 | 41 | # gluster_infra_thick_lvs 42 | # Variable for thick lv creation 43 | gluster_infra_thick_lvs: 44 | - { vgname: 'vg_vdb', lvname: 'vg_vdb_thicklv1', size: '10G' } 45 | 46 | 47 | # gluster_infra_thinpools 48 | # thinpoolname is optional, if not provided `vgname' followed by _thinpool is 49 | # used for name. poolmetadatasize is optional, default 16G is used 50 | 51 | gluster_infra_thinpools: 52 | - {vgname: 'vg_vdb', thinpoolname: 'foo_thinpool', thinpoolsize: '10G', poolmetadatasize: '1G' } 53 | - {vgname: 'vg_vdc', thinpoolname: 'bar_thinpool', thinpoolsize: '20G', poolmetadatasize: '1G' } 54 | 55 | 56 | # gluster_infra_lv_logicalvols 57 | # Thinvolumes for the brick. `thinpoolname' is optional, if omitted `vgname' 58 | # followed by _thinpool is used 59 | 60 | gluster_infra_lv_logicalvols: 61 | - { vgname: 'vg_vdb', thinpool: 'foo_thinpool', lvname: 'vg_vdb_thinlv', lvsize: '500G' } 62 | - { vgname: 'vg_vdc', thinpool: 'bar_thinpool', lvname: 'vg_vdc_thinlv', lvsize: '500G' } 63 | 64 | # gluster_infra_mount_devices 65 | # 66 | gluster_infra_mount_devices: 67 | - { path: '/mnt/thicklv', vgname: 'vg_vdb', lvname: 'vg_vdb_thicklv1' } 68 | - { path: '/mnt/thinlv1', vgname: 'vg_vdb', lvname: 'vg_vdb_thinlv' } 69 | - { path: '/mnt/thinlv2', vgname: 'vg_vdc', lvname: 'vg_vdc_thinlv' } 70 | -------------------------------------------------------------------------------- /roles/firewall_config/README.md: -------------------------------------------------------------------------------- 1 | firewall_config 2 | =============== 3 | 4 | This role helps the user to configure the firewall. 5 | 6 | 7 | Requirements 8 | ------------ 9 | Ansible version 2.5 or above 10 | 11 | Role Variables 12 | -------------- 13 | 14 | The following are the variables available for this role 15 | 16 | ### firewall_config 17 | | Name |Choices| Default value | Comments | 18 | |--------------------------|-------|-----------------------|-----------------------------------| 19 | | gluster_infra_fw_state | enabled / disabled / present / absent | UNDEF | Enable or disable a setting. For ports: Should this port accept(enabled) or reject(disabled) connections. The states "present" and "absent" can only be used in zone level operations (i.e. when no other parameters but zone and state are set). | 20 | | gluster_infra_fw_ports | | UNDEF | A list of ports in the format PORT/PROTO. For example 111/tcp. This is a list value. | 21 | | gluster_infra_fw_permanent | true/false | true | Whether to make the rule permanenet. | 22 | | gluster_infra_fw_zone | work / drop / internal/ external / trusted / home 23 | / dmz/ public / block | public | The firewalld zone to add/remove to/from | 24 | | gluster_infra_fw_services | | UNDEF | Name of a service to add/remove to/from firewalld - service must be listed in output of firewall-cmd --get-services. This is a list variable| 25 | 26 | ### Tags 27 | -------- 28 | firewall 29 | 30 | ### Example Playbook 31 | -------------------- 32 | 33 | Configure the ports and services related to GlusterFS: 34 | 35 | 36 | ```yaml 37 | --- 38 | - name: Setting up backend 39 | remote_user: root 40 | hosts: gluster_servers 41 | gather_facts: false 42 | 43 | vars: 44 | # Firewall setup 45 | gluster_infra_fw_ports: 46 | - 2049/tcp 47 | - 54321/tcp 48 | - 5900/tcp 49 | - 5900-6923/tcp 50 | - 5666/tcp 51 | - 16514/tcp 52 | gluster_infra_fw_permanent: true 53 | gluster_infra_fw_state: enabled 54 | gluster_infra_fw_zone: public 55 | gluster_infra_fw_services: 56 | - glusterfs 57 | 58 | roles: 59 | - gluster.infra 60 | 61 | ``` 62 | 63 | The above playbook will be run as part of the gluster.infra. However if you 64 | want to run just the firewall role use the tag firewall. 65 | 66 | For example: 67 | \# ansible-playbook -i inventory_file playbook_file.yml --tags firewall 68 | 69 | License 70 | ------- 71 | 72 | GPLv3 73 | 74 | -------------------------------------------------------------------------------- /roles/backend_setup/tasks/get_vg_groupings.yml: -------------------------------------------------------------------------------- 1 | --- 2 | 3 | - name: Group devices by volume group name, including existing devices 4 | set_fact: 5 | gluster_volumes_by_groupname_pre: >- 6 | {%- set output={} -%} 7 | {%- for grouper, devicesConf in volume_groups | groupby('vgname') -%} 8 | {%- set confs=[] -%} 9 | {%- for deviceConf in devicesConf -%} 10 | {%- if deviceConf.pvname is defined -%} 11 | {%- for device in deviceConf.pvname.split(',') -%} 12 | {%- set deviceConfCln=dict(devicesConf | first) -%} 13 | {{- deviceConfCln.__setitem__('pvname',device | trim) -}} 14 | {{- confs.append(deviceConfCln) -}} 15 | {%- endfor -%} 16 | {%- endif -%} 17 | {%- endfor -%} 18 | {{- output.__setitem__(grouper, confs) -}} 19 | {%- endfor -%} 20 | {%- if hostvars[inventory_hostname].ansible_lvm is defined and hostvars[inventory_hostname].ansible_lvm.pvs is defined -%} 21 | {%- for device, pvs in hostvars[inventory_hostname].ansible_lvm.pvs.items() -%} 22 | {%- if pvs.vg in output and output[pvs.vg] | selectattr('pvname','equalto',device) | list | count == 0 -%} 23 | {{- output[pvs.vg].append({'pvname':device, 'vgname':pvs.vg }) -}} 24 | {%- endif -%} 25 | {%- endfor -%} 26 | {%- endif -%} 27 | {{- output -}} 28 | 29 | - name: Check if vg block device exists 30 | shell: > 31 | {% for pvsname in item.value | ovirt.ovirt.json_query('[].pvname') %} 32 | test -b {{ pvsname }} && echo "1" || echo "0"; 33 | {% endfor %} 34 | register: vg_device_exists 35 | loop: "{{gluster_volumes_by_groupname_pre | dict2items}}" 36 | 37 | - name: Filter none-existing devices 38 | set_fact: 39 | gluster_volumes_by_groupname: >- 40 | {%- set output={} -%} 41 | {%- for vgname, devicesConf in gluster_volumes_by_groupname_pre.items() -%} 42 | {%- for item in vg_device_exists.results | ovirt.ovirt.json_query('[?item.key==`' ~ vgname ~ '`]') -%} 43 | {%- set confs=[] -%} 44 | {%- for vgConfig in item.item.value -%} 45 | {%- if item.stdout_lines is defined and item.stdout_lines[loop.index0] == "1" -%} 46 | {%- set vgConfigCln=dict(item.item.value | first) -%} 47 | {{- vgConfigCln.__setitem__('pvname',vgConfig.pvname) -}} 48 | {{- confs.append(vgConfigCln) -}} 49 | {%- endif -%} 50 | {%- endfor -%} 51 | {{- output.__setitem__(vgname, confs) -}} 52 | {%- endfor -%} 53 | {%- endfor -%} 54 | {{- output -}} 55 | -------------------------------------------------------------------------------- /roles/backend_setup/tasks/blacklist_mpath_devices.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # This play is for blacklist devices 3 | - name: Check that the multipath.conf exists 4 | stat: 5 | path: /etc/multipath.conf 6 | register: file_exist 7 | 8 | - name: Ensure that multipathd services is enabled if not 9 | shell: vdsm-tool configure --module multipath 10 | when: file_exist.stat.exists == False 11 | 12 | - name: Ensure that multipathd services is running 13 | service: 14 | name: multipathd 15 | state: started 16 | enabled: yes 17 | 18 | - name: Create /etc/multipath/conf.d if doesn't exists 19 | file: 20 | path: /etc/multipath/conf.d 21 | recurse: yes 22 | state: directory 23 | 24 | - name: Get the UUID of the devices 25 | ignore_errors: True 26 | shell: multipath -a /dev/{% if item.startswith('sd') %}{{ item | regex_replace('[0-9]+$') }}{% else %}{{ item }}{% endif %} 27 | register: dev_uuid 28 | with_items: "{{ blacklist_mpath_devices }}" 29 | 30 | - name: Remove UUID of the devices from /etc/multipath/wwids 31 | ignore_errors: True 32 | shell: multipath -w {{ item.stdout.split()[1][1:-1] }} 33 | loop: "{{ dev_uuid.results }}" 34 | when: blacklist_mpath_devices | length > 0 and item.failed == false 35 | 36 | - name: Add entry in system.service 37 | ignore_errors: True 38 | command: lvmdevices --adddev /dev/{{ item }} 39 | with_items: "{{ blacklist_mpath_devices }}" 40 | when: blacklist_mpath_devices | length > 0 41 | 42 | - name: Clean device 43 | ignore_errors: True 44 | command: wipefs -a /dev/{{ item }} 45 | with_items: "{{ blacklist_mpath_devices }}" 46 | when: blacklist_mpath_devices | length > 0 47 | 48 | - name: Check that the blacklist.conf exists 49 | stat: 50 | path: /etc/multipath/conf.d/blacklist.conf 51 | register: stat_result 52 | 53 | - name: Create blacklist template content 54 | blockinfile: 55 | path: /etc/multipath/conf.d/blacklist.conf 56 | create: yes 57 | state: present 58 | block: | 59 | blacklist { 60 | } 61 | when: stat_result.stat.exists == False 62 | 63 | - name: Add wwid to blacklist in blacklist.conf file 64 | blockinfile: 65 | path: /etc/multipath/conf.d/blacklist.conf 66 | insertafter: 'blacklist' 67 | block: | 68 | wwid "{{ item.stdout.split()[1][1:-1] }}" 69 | marker: "# {mark} ANSIBLE MANAGED BLOCK {{ item.item }}" 70 | loop: "{{ dev_uuid.results }}" 71 | when: blacklist_mpath_devices | length > 0 and item.failed == false 72 | 73 | - name: Reload multipathd 74 | shell: systemctl reload multipathd 75 | 76 | tags: 77 | - cleanup_bricks 78 | -------------------------------------------------------------------------------- /playbooks/bricks.yml: -------------------------------------------------------------------------------- 1 | # gluster_infra_disktype 2 | # Set a disk type. Options: JBOD, RAID6, RAID10 - Default: JBOD 3 | # 4 | 5 | gluster_infra_disktype: RAID10 6 | 7 | 8 | # gluster_infra_dalign 9 | # Dataalignment, for JBOD default is 256K if not provided. 10 | # For RAID{6,10} dataalignment is computed by multiplying 11 | # gluster_infra_diskcount and gluster_infra_stripe_unit_size. 12 | 13 | gluster_infra_dalign: 256K 14 | 15 | 16 | # gluster_infra_diskcount 17 | # Required only for RAID6 and RAID10. 18 | 19 | gluster_infra_diskcount: 10 20 | 21 | 22 | # gluster_infra_stripe_unit_size 23 | # Required only in case of RAID6 and RAID10. Stripe unit size always in KiB, do 24 | # not provide the trailing `K' in the value. 25 | 26 | gluster_infra_stripe_unit_size: 128 27 | 28 | 29 | # gluster_infra_volume_groups 30 | # Variables for creating volume group 31 | 32 | gluster_infra_volume_groups: 33 | - { vgname: 'vg_vdb', pvname: '/dev/vdb' } 34 | - { vgname: 'vg_vdc', pvname: '/dev/vdc' } 35 | 36 | 37 | # gluster_infra_thick_lvs 38 | # Variable for thick lv creation 39 | gluster_infra_thick_lvs: 40 | - { vgname: 'vg_vdb', lvname: 'vg_vdb_thicklv1', size: '10G' } 41 | 42 | 43 | # gluster_infra_thinpools 44 | # thinpoolname is optional, if not provided `vgname' followed by _thinpool is 45 | # used for name. poolmetadatasize is optional, default 16G is used 46 | 47 | gluster_infra_thinpools: 48 | - {vgname: 'vg_vdb', thinpoolname: 'foo_thinpool', thinpoolsize: '10G', poolmetadatasize: '1G' } 49 | - {vgname: 'vg_vdc', thinpoolname: 'bar_thinpool', thinpoolsize: '20G', poolmetadatasize: '1G' } 50 | 51 | 52 | # gluster_infra_lv_logicalvols 53 | # Thinvolumes for the brick. `thinpoolname' is optional, if omitted `vgname' 54 | # followed by _thinpool is used 55 | 56 | gluster_infra_lv_logicalvols: 57 | - { vgname: 'vg_vdb', thinpool: 'foo_thinpool', lvname: 'vg_vdb_thinlv', lvsize: '500G' } 58 | - { vgname: 'vg_vdc', thinpool: 'bar_thinpool', lvname: 'vg_vdc_thinlv', lvsize: '500G' } 59 | 60 | 61 | # Setting up cache using SSD disks 62 | gluster_infra_cache_vars: 63 | - { vgname: 'vg_vdb', cachedisk: '/dev/vdd', 64 | cachethinpoolname: 'foo_thinpool', cachelvname: 'cachelv', 65 | cachelvsize: '20G', cachemetalvname: 'cachemeta', 66 | cachemetalvsize: '100M', cachemode: 'writethrough' } 67 | 68 | 69 | # gluster_infra_mount_devices 70 | # 71 | gluster_infra_mount_devices: 72 | - { path: '/mnt/thicklv', vgname: 'vg_vdb', lvname: 'vg_vdb_thicklv1' } 73 | - { path: '/mnt/thinlv1', vgname: 'vg_vdb', lvname: 'vg_vdb_thinlv' } 74 | - { path: '/mnt/thinlv2', vgname: 'vg_vdc', lvname: 'vg_vdc_thinlv' } 75 | -------------------------------------------------------------------------------- /roles/backend_setup/tasks/luks_device_encrypt.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # This play is for create key file with _key and encrypt devices 3 | 4 | - name: Create key file 5 | no_log: true 6 | copy: 7 | dest: "/etc/{{ item.devicename.split('/')[-1] }}_key" 8 | content: | 9 | {{ item.passphrase }} 10 | with_items: "{{ gluster_infra_luks_devices }}" 11 | when: gluster_infra_luks_devices is defined 12 | 13 | - name: Encrypt devices using key file 14 | no_log: true 15 | shell: echo ‘YES’ | cryptsetup luksFormat {{ item.devicename }} /etc/{{ item.devicename.split('/')[-1] }}_key 16 | with_items: "{{ gluster_infra_luks_devices }}" 17 | when: gluster_infra_luks_devices is defined 18 | 19 | - name: Open encrypt devices using key file 20 | no_log: true 21 | shell: cryptsetup luksOpen {{ item.devicename }} luks_{{ item.devicename.split('/')[-1] }} -d /etc/{{ item.devicename.split('/')[-1] }}_key 22 | with_items: "{{ gluster_infra_luks_devices }}" 23 | when: gluster_infra_luks_devices is defined 24 | 25 | - name: Generate new random key file 26 | no_log: true 27 | shell: dd bs=1024 count=8192 if=/dev/urandom of=/etc/{{ item.devicename.split('/')[-1] }}_keyfile iflag=fullblock status=progress 28 | with_items: "{{ gluster_infra_luks_devices }}" 29 | when: gluster_infra_luks_devices is defined 30 | 31 | - name: Set permission for new key file 32 | no_log: true 33 | shell: chmod 0400 /etc/{{ item.devicename.split('/')[-1] }}_keyfile 34 | with_items: "{{ gluster_infra_luks_devices }}" 35 | when: gluster_infra_luks_devices is defined 36 | 37 | - name: Add new key file to luks device 38 | no_log: true 39 | shell: cryptsetup luksAddKey {{ item.devicename }} /etc/{{ item.devicename.split('/')[-1] }}_keyfile --key-file=/etc/{{ item.devicename.split('/')[-1] }}_key 40 | with_items: "{{ gluster_infra_luks_devices }}" 41 | when: gluster_infra_luks_devices is defined 42 | 43 | - name: Find UUID for encrypted devices 44 | no_log: true 45 | shell: cryptsetup luksUUID {{ item.devicename }} 46 | register: device_uuid 47 | with_items: "{{ gluster_infra_luks_devices }}" 48 | when: gluster_infra_luks_devices is defined 49 | 50 | - name: Add encrypted device entry on /etc/crypttab to auto unlock 51 | no_log: true 52 | blockinfile: 53 | path: "/etc/crypttab" 54 | state: present 55 | block: | 56 | luks_{{ item.devicename.split('/')[-1] }} UUID={{ device_uuid.results[index].stdout }} /etc/{{ item.devicename.split('/')[-1] }}_keyfile 57 | marker: "# {mark} Entry for {{item.devicename}}" 58 | loop: "{{ gluster_infra_luks_devices }}" 59 | loop_control: 60 | index_var: index 61 | when: gluster_infra_luks_devices is defined 62 | 63 | - name: Remove key file which was created with passphrase 64 | no_log: true 65 | shell: rm -rf /etc/{{ item.devicename.split('/')[-1] }}_key 66 | with_items: "{{ gluster_infra_luks_devices }}" 67 | when: gluster_infra_luks_devices is defined 68 | -------------------------------------------------------------------------------- /roles/backend_setup/tasks/mount.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # Only XFS is supported in GlusterFS 3 | 4 | # Create mount directories if not already present 5 | - name: Create mount directories if not already present 6 | file: 7 | path: "{{ item.path }}" 8 | state: directory 9 | with_items: "{{ gluster_infra_mount_devices }}" 10 | 11 | # Reload systemctl daemon before mounting disks 12 | - name: Reload systemctl daemon 13 | systemd: 14 | daemon_reload: yes 15 | 16 | # In case of vdo disks, use different mount options 17 | - name: Set mount options for VDO 18 | set_fact: 19 | vdo_opts: ",_netdev,x-systemd.device-timeout=0,x-systemd.requires=vdo.service" 20 | when: gluster_infra_vdo is defined 21 | 22 | # Get the UUID of the disks to be mounted 23 | - name: Get the UUID of the devices 24 | shell: blkid /dev/{{item.vgname}}/{{item.lvname}} | 25 | awk '{ print $2 }' | sed 's/"//g' 26 | register: dev_uuid 27 | with_items: "{{ gluster_infra_mount_devices }}" 28 | 29 | # Build a new list of dictionaries of devices, including their UUID 30 | - name: Add UUID into the list of mount devices 31 | set_fact: 32 | mount_devices_with_uuid: "{{ mount_devices_with_uuid|default([]) + 33 | [item.item|combine({'uuid':item.stdout})] }}" 34 | loop: "{{ dev_uuid.results }}" 35 | no_log: true 36 | 37 | - name: Mount the vdo devices (If any) 38 | register: lvmount_vdo 39 | mount: 40 | path: "{{ item.path }}" 41 | state: mounted 42 | fstype: xfs 43 | opts: "inode64,noatime,nodiratime{{ vdo_opts|default('')}}" 44 | src: "{{ item.uuid }}" 45 | with_items: "{{ mount_devices_with_uuid }}" 46 | when: vdo_devs is defined and vdo_devs|length > 0 and item.vgname in vdo_devs 47 | 48 | - name: Mount the devices 49 | register: lvmount 50 | mount: 51 | path: "{{ item.path }}" 52 | state: mounted 53 | fstype: xfs 54 | opts: "inode64,noatime,nodiratime" 55 | src: "{{ item.uuid }}" 56 | with_items: "{{ mount_devices_with_uuid }}" 57 | when: vdo_devs is not defined or (vdo_devs is defined and item.vgname not in vdo_devs) 58 | 59 | - name: update mount fact's 60 | setup: 61 | filter: 'ansible_mounts' 62 | when: lvmount.changed or lvmount_vdo.changed 63 | 64 | - name: Set Gluster specific SeLinux context on the bricks 65 | command: "semanage fcontext -a -t glusterd_brick_t {{ (item.path | realpath) + '(/.*)?' }}" 66 | # sefcontext: 67 | # target: "{{ (item.path | realpath) + '(/.*)?' }}" 68 | # setype: glusterd_brick_t 69 | # state: present 70 | with_items: "{{ gluster_infra_mount_devices }}" 71 | when: gluster_set_selinux_labels| default(false)| bool == true 72 | ignore_errors: yes 73 | 74 | - name: restore file(s) default SELinux security contexts 75 | command: restorecon -Rv "{{ item.path }}" 76 | with_items: "{{ gluster_infra_mount_devices }}" 77 | when: gluster_set_selinux_labels| default(false)| bool == true 78 | -------------------------------------------------------------------------------- /roles/backend_setup/tasks/cache_setup.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # This playbook sets up lvm cache. Primarily written for the hyperconverged 3 | # setup. 4 | 5 | # Create PV for setting up cache with dataalignment of 256K for SSDs. 6 | # Extend the existing volume group with the SSD (assuming SSD is used for 7 | # caching) 8 | 9 | - name: Extend volume group 10 | command: "vgextend --dataalignment 256K {{ item.vgname }} {{ item.cachedisk.split(',')[1] }}" 11 | # lvg: 12 | # state: present 13 | # vg: "{{ item.vgname }}" 14 | # pvs: "{{ item.cachedisk }}" 15 | # pv_options: "--dataalignment 256K" 16 | with_items: "{{ gluster_infra_cache_vars }}" 17 | register: resp 18 | failed_when: resp.rc not in [0, 5] 19 | changed_when: resp.rc == 0 20 | 21 | #- name: Change attributes of LV 22 | # command: "lvchange --zero n --type thin-pool -n {{ item.cachethinpoolname }} {{ item.vgname }}" 23 | # lvol: 24 | # state: present 25 | # vg: "{{ item.vgname }}" 26 | # thinpool: "{{ item.cachethinpoolname }}" 27 | # opts: " --zero n " 28 | # with_items: "{{ gluster_infra_cache_vars }}" 29 | 30 | - name: Create LV for cache 31 | ansible.builtin.expect: 32 | command: "lvcreate -L {{ item.cachelvsize }} -n {{ item.cachelvname }} {{ item.vgname }}" 33 | responses: 34 | (.*)WARNING:(.*): "y" 35 | # lvol: 36 | # state: present 37 | # vg: "{{ item.vgname }}" 38 | # lv: "{{ item.cachelvname }}" 39 | # size: "{{ item.cachelvsize }}" 40 | with_items: "{{ gluster_infra_cache_vars }}" 41 | 42 | - name: Create metadata LV for cache 43 | command: "lvcreate -L {{ item.cachemetalvsize }} -n {{ item.cachemetalvname }} {{ item.vgname }}" 44 | # lvol: 45 | # state: present 46 | # vg: "{{ item.vgname }}" 47 | # lv: "{{ item.cachemetalvname }}" 48 | # size: "{{ item.cachemetalvsize }}" 49 | with_items: "{{ gluster_infra_cache_vars }}" 50 | when: item.cachemetalvname is defined 51 | 52 | - name: Convert logical volume to a cache pool LV 53 | command: > 54 | lvconvert -y --type cache-pool --poolmetadata {{ item.cachemetalvname }} 55 | --poolmetadataspare n 56 | --cachemode {{item.cachemode | default('writethrough')}} 57 | "/dev/{{item.vgname}}/{{item.cachelvname}}" 58 | with_items: "{{ gluster_infra_cache_vars }}" 59 | when: item.cachemetalvname is defined 60 | 61 | # It is valid not to have cachemetalvname! Writing a separate task not to 62 | # complicate things. 63 | - name: Convert logical volume to a cache pool LV without cachemetalvname 64 | command: > 65 | lvconvert -y --type cache-pool --poolmetadataspare n --cachemode {{item.cachemode | default('writethrough')}} /dev/{{item.vgname}}/{{item.cachelvname}} 66 | with_items: "{{ gluster_infra_cache_vars }}" 67 | when: item.cachemetalvname is not defined 68 | 69 | # Run lvs -a -o +devices to see the cache settings 70 | - name: Convert an existing logical volume to a cache LV 71 | command: > 72 | lvconvert -y --type cache --cachepool /dev/{{item.vgname}}/{{item.cachelvname}} /dev/{{item.vgname}}/{{item.cachethinpoolname}} 73 | with_items: "{{ gluster_infra_cache_vars }}" 74 | -------------------------------------------------------------------------------- /roles/backend_setup/tasks/bind_tang_server.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # Create key file with _key and encrypt devices 3 | 4 | - name: Create key root file 5 | no_log: true 6 | copy: 7 | dest: "/etc/root_key" 8 | content: "{{ rootpassphrase }}" 9 | when: gluster_infra_tangservers is defined 10 | 11 | - name: Download the advertisement from tang server for IPv4 12 | shell: 13 | cmd: curl -sfg "{{ item.url }}/adv" -o /etc/adv{{ index }}.jws 14 | warn: False 15 | loop: "{{ gluster_infra_tangservers }}" 16 | loop_control: 17 | index_var: index 18 | when: "gluster_infra_tangservers is defined and ip_version == 'IPv4'" 19 | 20 | - name: Download the advertisement from tang server for IPv6 21 | shell: 22 | cmd: curl -6 -sfg "{{ item.url }}/adv" -o /etc/adv{{ index }}.jws 23 | warn: False 24 | loop: "{{ gluster_infra_tangservers }}" 25 | loop_control: 26 | index_var: index 27 | when: "gluster_infra_tangservers is defined and ip_version == 'IPv6'" 28 | 29 | - name: Bind tang server with clevis 30 | no_log: true 31 | shell: clevis luks bind -f -k /etc/root_key -d {{ rootdevice }} tang '{"url":"{{item.url}}", "adv":"/etc/adv{{ index }}.jws"}' 32 | loop: "{{ gluster_infra_tangservers }}" 33 | loop_control: 34 | index_var: index 35 | when: gluster_infra_tangservers is defined 36 | 37 | # For DHCP 38 | - name: Add network entry for dhcp on /etc/dracut.conf.d/clevis.conf 39 | blockinfile: 40 | path: /etc/dracut.conf.d/clevis.conf 41 | create: yes 42 | state: present 43 | block: | 44 | kernel_cmdline="ip={{ networkinterface }}:dhcp" 45 | omit_dracutmodules+="ifcfg" 46 | omit_dracutmodules+="network-legacy" 47 | add_dracutmodules+="clevis network-manager" 48 | marker: "# {mark} Entry for {{networkinterface}}" 49 | when: "gluster_infra_tangservers is defined and ip_config_method == 'dhcp'" 50 | 51 | # For Static and IPv4 52 | - name: Add network entry for static and IPv4 on /etc/dracut.conf.d/clevis.conf 53 | blockinfile: 54 | path: /etc/dracut.conf.d/clevis.conf 55 | create: yes 56 | state: present 57 | block: | 58 | kernel_cmdline="ip={{host_ip_addr}}::{{host_net_gateway}}:{{host_ip_prefix}}::{{networkinterface}}:off" 59 | omit_dracutmodules+="ifcfg" 60 | omit_dracutmodules+="network-legacy" 61 | add_dracutmodules+="clevis network-manager" 62 | marker: "# {mark} Entry for {{networkinterface}}" 63 | when: "gluster_infra_tangservers is defined and ip_config_method == 'static' and ip_version == 'IPv4'" 64 | 65 | # For Static and IPv6 66 | - name: Add network entry for static and IPv6 on /etc/dracut.conf.d/clevis.conf 67 | blockinfile: 68 | path: /etc/dracut.conf.d/clevis.conf 69 | create: yes 70 | state: present 71 | block: | 72 | kernel_cmdline="ip=[{{host_ip_addr}}]::[{{host_net_gateway}}]:{{host_ip_prefix}}::{{networkinterface}}:off" 73 | omit_dracutmodules+="ifcfg" 74 | omit_dracutmodules+="network-legacy" 75 | add_dracutmodules+="clevis network-manager" 76 | marker: "# {mark} Entry for {{networkinterface}}" 77 | when: "gluster_infra_tangservers is defined and ip_config_method == 'static' and ip_version == 'IPv6'" 78 | 79 | - name: Execute dracut -vf to configure tang 80 | command: dracut -vf --regenerate-all 81 | when: gluster_infra_tangservers is defined 82 | 83 | - name: Remove root_key file 84 | file: 85 | path: /etc/root_key 86 | state: absent 87 | -------------------------------------------------------------------------------- /roles/backend_setup/tasks/vg_create.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # We have to set the dataalignment for physical volumes, and physicalextentsize 3 | # for volume groups. For JBODs we use a constant alignment value of 256K 4 | # however, for RAID we calculate it by multiplying the RAID stripe unit size 5 | # with the number of data disks. Hence in case of RAID stripe_unit_size and data 6 | # disks are mandatory parameters. 7 | 8 | - name: Check if valid disktype is provided 9 | fail: 10 | msg: "Unknown disktype. Allowed disktypes: JBOD, RAID6, RAID10, RAID5." 11 | when: gluster_infra_disktype not in [ 'JBOD', 'RAID6', 'RAID10', 'RAID5' ] 12 | 13 | 14 | # Set data alignment for JBODs, by default it is 256K. This set_fact is not 15 | # needed if we can always assume 256K for JBOD, however we provide this extra 16 | # variable to override it. 17 | - name: Set PV data alignment for JBOD 18 | set_fact: 19 | pv_dataalign: "{{ gluster_infra_dalign | default('256K') }}" 20 | when: gluster_infra_disktype == 'JBOD' 21 | 22 | # Set data alignment for RAID 23 | # We need KiB: ensure to keep the trailing `K' in the pv_dataalign calculation. 24 | - name: Set PV data alignment for RAID 25 | set_fact: 26 | pv_dataalign: > 27 | {{ gluster_infra_diskcount|int * 28 | gluster_infra_stripe_unit_size|int }}K 29 | when: > 30 | gluster_infra_disktype == 'RAID6' or 31 | gluster_infra_disktype == 'RAID10' or 32 | gluster_infra_disktype == 'RAID5' 33 | 34 | - name: Set VG physical extent size for RAID 35 | set_fact: 36 | vg_pesize: > 37 | {{ gluster_infra_diskcount|int * 38 | gluster_infra_stripe_unit_size|int }}K 39 | when: > 40 | gluster_infra_disktype == 'RAID6' or 41 | gluster_infra_disktype == 'RAID10' or 42 | gluster_infra_disktype == 'RAID5' 43 | 44 | - include_tasks: get_vg_groupings.yml 45 | vars: 46 | volume_groups: "{{ gluster_infra_volume_groups }}" 47 | when: gluster_infra_volume_groups is defined and gluster_infra_volume_groups is not none and gluster_infra_volume_groups|length >0 48 | 49 | - name: Record for missing devices for phase 2 50 | set_fact: 51 | gluster_phase2_has_missing_devices: true 52 | loop: "{{ vg_device_exists.results }}" 53 | when: item.stdout_lines is defined and "0" in item.stdout_lines 54 | 55 | - name: Print the gateway for each host when defined 56 | ansible.builtin.debug: 57 | msg: vg names {{ gluster_volumes_by_groupname }} 58 | 59 | # Tasks to create a volume group 60 | # The devices in `pvs' can be a regular device or a VDO device 61 | # Please take note; only the first item per volume group will define the actual configuraton! 62 | #TODO: fix pesize // {{ ((item.value | first).vg_pesize || vg_pesize) | default(4) }} 63 | - name: Create volume groups 64 | register: gluster_changed_vgs 65 | command: vgcreate --dataalignment {{ item.value.pv_dataalign | default(pv_dataalign) }} -s {{ vg_pesize | default(4) }} {{ (item.value | first).vgname }} {{ item.value | ovirt.ovirt.json_query('[].pvname') | unique | join(',') }} 66 | # lvg: 67 | # state: present 68 | # vg: "{{ (item.value | first).vgname }}" 69 | # pvs: "{{ item.value | json_query('[].pvname') | unique | join(',') }}" 70 | # pv_options: "--dataalignment {{ item.value.pv_dataalign | default(pv_dataalign) }}" 71 | # pesize is 4m by default for JBODs 72 | # pesize: "{{ vg_pesize | default(4) }}" 73 | loop: "{{gluster_volumes_by_groupname | default({}) | dict2items}}" 74 | when: gluster_volumes_by_groupname is defined and item.value|length>0 75 | 76 | - name: update LVM fact's 77 | setup: 78 | filter: 'ansible_lvm' 79 | when: gluster_changed_vgs.changed 80 | -------------------------------------------------------------------------------- /roles/backend_setup/tasks/vdo_create.yml: -------------------------------------------------------------------------------- 1 | --- 2 | 3 | 4 | - name: Check if vdo block device exists 5 | shell: test -b {{ item.device }} && echo "1" || echo "0" 6 | register: vdo_device_exists 7 | with_items: "{{ gluster_infra_vdo }}" 8 | when: item.device is defined 9 | 10 | 11 | - name: Record for missing devices for phase 2 12 | set_fact: 13 | gluster_phase2_has_missing_devices: true 14 | loop: "{{ vdo_device_exists.results }}" 15 | when: item.stdout is defined and item.stdout == "0" 16 | 17 | - name: "set fact if it will at least install 1 vdo device" 18 | set_fact: 19 | gluster_infra_vdo_will_create_vdo: true 20 | loop: "{{ gluster_infra_vdo if gluster_infra_vdo is defined and gluster_infra_vdo is not none and gluster_infra_vdo|length>0 else [] }}" 21 | loop_control: 22 | index_var: index 23 | when: (gluster_infra_vdo is defined and gluster_infra_vdo is not none and gluster_infra_vdo|length>0 and item is defined and item is not none) 24 | and item.device is defined and vdo_device_exists.results[index].stdout is defined and vdo_device_exists.results[index].stdout == "1" 25 | 26 | - name: Install VDO dependencies 27 | #maybe use package module? 28 | yum: 29 | name: "{{ packages }}" 30 | register: vdo_deps 31 | vars: 32 | packages: 33 | - kmod-kvdo 34 | - vdo 35 | when: ansible_os_family == 'RedHat' and gluster_infra_vdo_will_create_vdo is defined and gluster_infra_vdo_will_create_vdo==true 36 | and (gluster_infra_installed_vdo_deps is not defined or not gluster_infra_installed_vdo_deps) 37 | 38 | - name: set fact about vdo installed deps 39 | set_fact: 40 | gluster_infra_installed_vdo_deps: "{{not vdo_deps.failed}}" 41 | when: gluster_infra_installed_vdo_deps is not defined and vdo_deps is defined and vdo_deps.failed is defined 42 | 43 | # Start the vdo service (service can only be started after the dependencies are installed) 44 | - name: Enable and start vdo service 45 | service: 46 | name: vdo 47 | state: started 48 | enabled: yes 49 | when: ansible_os_family != 'RedHat' or 50 | (gluster_infra_vdo_will_create_vdo is defined and gluster_infra_vdo_will_create_vdo==true 51 | and gluster_infra_installed_vdo_deps is defined and gluster_infra_installed_vdo_deps==true) 52 | 53 | - name: Create VDO with specified size 54 | command: "vdo create -n {{ item.name }} --device {{ item.device }} --compression {{ item.compression | default('enabled') }} --emulate512 disabled --indexMem {{ item.indexmem | default('0.25') }} --vdoAckThreads {{ item.ackthreads | default('1') }} --vdoBioThreads {{ item.biothreads | default('4') }} --vdoCpuThreads {{ item.cputhreads | default('2') }} --vdoLogicalThreads {{ item.logicalthreads | default('1') }} --vdoPhysicalThreads {{ item.physicalthreads | default('1') }} {% if item.logicalsize | replace('G','') | int >= 2000 %} --vdoSlabSize 32G {% elif item.logicalsize | replace('G','') | int >= 1000 %} --vdoSlabSize 16G {% else %} --vdoSlabSize 8G {% endif %} " 55 | #vdo: 56 | # name: "{{ item.name }}" 57 | # device: "{{ item.device }}" 58 | # state: "{{ item.state | default('present') }}" # 59 | # activated: "{{ item.activated | default('yes') }}" # 60 | # running: "{{ item.running | default('yes') }}" # 61 | # logicalsize: "{{ item.logicalsize | default('') }}" # 62 | # compression: "{{ item.compression | default('enabled') }}" 63 | # blockmapcachesize: "{{ item.blockmapcachesize | default('128M') }}" # 64 | # emulate512: "{{ item.emulate512 | default('off') }}" 65 | # slabsize: "{{ item.slabsize | default('2G') }}" # 66 | # writepolicy: "{{ item.writepolicy | default('sync') }}" # 67 | # indexmem: "{{ item.indexmem | default('0.25') }}" 68 | # indexmode: "{{ item.indexmode | default('dense') }}" # 69 | # ackthreads: "{{ item.ackthreads | default('1') }}" 70 | # biothreads: "{{ item.biothreads | default('4') }}" 71 | # cputhreads: "{{ item.cputhreads | default('2') }}" 72 | # logicalthreads: "{{ item.logicalthreads | default('1') }}" 73 | # physicalthreads: "{{ item.physicalthreads | default('1') }}" 74 | with_items: "{{ gluster_infra_vdo }}" 75 | loop_control: 76 | index_var: index 77 | #when we have a device and it exists 78 | when: item.device is defined and vdo_device_exists.results[index].stdout is defined and vdo_device_exists.results[index].stdout == "1" 79 | 80 | # This is a workaround for now, as vdo ansible module has missing option for maxDiscardSize 81 | - name: Set VDO maxDiscardSize as 16M 82 | command: "vdo modify -a --maxDiscardSize 16M" 83 | 84 | - name: Stop VDO volumes 85 | command: "vdo stop -n {{ item.name }}" 86 | with_items: "{{ gluster_infra_vdo }}" 87 | 88 | - name: Start VDO volumes 89 | shell: "vdo start -n {{ item.name }}" 90 | with_items: "{{ gluster_infra_vdo }}" 91 | -------------------------------------------------------------------------------- /roles/backend_setup/tasks/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | 3 | # https://access.redhat.com/documentation/en-us/red_hat_gluster_storage/3.3/html/administration_guide/brick_configuration 4 | # https://access.redhat.com/documentation/en-US/Red_Hat_Storage/2.1/html/Administration_Guide/chap-Administration_Guide-Performance_Enhancements.html 5 | # https://github.com/solarkennedy/wiki.xkyle.com/wiki/XFS_Block_Sizes 6 | # https://ewen.mcneill.gen.nz/blog/entry/2019-01-08-xfs-storage-layout-considerations/ 7 | # https://raid.wiki.kernel.org/index.php/RAID_setup#XFS 8 | # https://wiki.gentoo.org/wiki/LVM/en 9 | # https://serverfault.com/questions/981694/why-does-xfs-uses-lvm-cache-chunk-size-instead-the-raid5-setup-for-sunit-swidth 10 | 11 | 12 | # Using Ansible facts to detect vdsm-python package is installed 13 | - name: Gather the package facts 14 | ansible.builtin.package_facts: 15 | manager: auto 16 | 17 | - name: Print the package facts 18 | ansible.builtin.debug: 19 | var: ansible_facts.packages 20 | verbosity: 1 21 | 22 | - name: Exclude LVM Filter rules 23 | import_tasks: lvm_exclude_filter.yml 24 | when: 25 | - 'gluster_infra_lvm is defined' 26 | - '"vdsm-python" in ansible_facts.packages' 27 | 28 | # Blacklist multipath devices 29 | - name: Blacklist multipath devices 30 | import_tasks: blacklist_mpath_devices.yml 31 | when: blacklist_mpath_devices is defined 32 | tags: 33 | - blacklistdevices 34 | 35 | # Gather facts to determine the distribution 36 | - name: Gather facts to determine the OS distribution 37 | setup: 38 | gather_subset: 39 | - '!all' 40 | - '!any' 41 | - distribution 42 | 43 | # Create a logical volume thinpool when thinpoolname is given 44 | - name: Change to Install lvm tools for debian systems. 45 | package: 46 | name: thin-provisioning-tools 47 | state: present 48 | when: ansible_distribution == "Debian" or ansible_distribution == "Ubuntu" 49 | 50 | - name: Change to Install lvm tools for RHEL systems. 51 | package: 52 | name: device-mapper-persistent-data 53 | state: present 54 | when: ansible_os_family == 'RedHat' 55 | 56 | - name: Install python-yaml package for Debian systems 57 | package: 58 | name: python-yaml 59 | state: present 60 | when: ansible_distribution == "Debian" or ansible_distribution == "Ubuntu" 61 | 62 | # Initialize vdo_devs to empty list, vdo_devs would not not be initialized if 63 | # search fails 64 | - name: Initialize vdo_devs array 65 | set_fact: 66 | vdo_devs: [] 67 | 68 | # Get the list of volume groups created on vdo disks 69 | # This is a bit hacky, we rely on pvname to get vdo disks 70 | # TODO: dynamically add VG's here 71 | - name: Record VDO devices (if any) 72 | set_fact: 73 | vdo_devs: "{{ vdo_devs|default([]) + [ item.vgname ] }}" 74 | with_items: "{{ gluster_infra_volume_groups | default([]) }}" 75 | when: item.pvname is defined and item.pvname is search("/dev/mapper/vdo") 76 | 77 | # set lvm config 78 | - name: Configure LVM 79 | import_tasks: lvm_config.yml 80 | when: gluster_infra_lvm is defined 81 | tags: 82 | - lvmconfig 83 | 84 | #phase #1 85 | - name: Create a vdo disk 86 | import_tasks: vdo_create.yml 87 | when: gluster_infra_vdo is defined 88 | tags: 89 | - vdocreate 90 | 91 | - name: "Execute phase #1 of LVM" 92 | import_tasks: main-lvm.yml 93 | 94 | #phase #2 95 | - name: "Create a vdo disk after LVM for phase #2" 96 | import_tasks: vdo_create.yml 97 | when: gluster_infra_vdo is defined and gluster_phase2_has_missing_devices is defined and gluster_phase2_has_missing_devices 98 | tags: 99 | - vdocreate 100 | 101 | - name: "Execute phase #2 of LVM" 102 | import_tasks: main-lvm.yml 103 | when: gluster_phase2_has_missing_devices is defined and gluster_phase2_has_missing_devices 104 | 105 | 106 | # Create a filesystem on the disks. 107 | - name: Create a filesystem on the disks 108 | import_tasks: fscreate.yml 109 | when: gluster_infra_lv_logicalvols is defined or 110 | gluster_infra_thick_lvs is defined 111 | tags: 112 | - fscreate 113 | 114 | # Mount the devices 115 | - name: Mount the devices 116 | import_tasks: mount.yml 117 | when: gluster_infra_mount_devices is defined and gluster_infra_mount_devices is not none 118 | tags: 119 | - mount 120 | 121 | # set kernel boot params for lvm volumes 122 | - name: Configure lvm kernel parameters 123 | import_tasks: lvm_kernelparams.yml 124 | when: gluster_infra_thick_lvs is defined and gluster_infra_thick_lvs | selectattr("atboot","defined")| selectattr("atboot") | list | length > 0 125 | tags: 126 | - lvmkernelparams 127 | 128 | # set fstrim service 129 | - name: Configure fstrim service 130 | import_tasks: fstrim_service.yml 131 | when: fstrim_service is defined 132 | tags: 133 | - fstrim 134 | 135 | # Encrypt devices with LUKS 136 | - name: Encrypt devices with LUKS 137 | import_tasks: luks_device_encrypt.yml 138 | when: gluster_infra_luks_devices is defined 139 | tags: 140 | - luksencrypt 141 | 142 | # Bind Tang server 143 | - name: Bind Tand server 144 | import_tasks: bind_tang_server.yml 145 | when: gluster_infra_tangservers is defined 146 | tags: 147 | - bindtang 148 | 149 | - name: Re-generate new LVM Filrer rules 150 | import_tasks: regenerate_new_lvm_filter_rules.yml 151 | when: 152 | - 'gluster_infra_lvm is defined' 153 | - '"vdsm-python" in ansible_facts.packages' 154 | -------------------------------------------------------------------------------- /roles/backend_setup/tasks/fscreate.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # If disktype is RAID we use the options: 3 | # -f -K -i size=512 -d sw=%s,su=%sk -n size=8192 where sw is the diskcount and 4 | # su is the stripe_unit_size 5 | - name: Set XFS options for JBOD 6 | set_fact: 7 | fs_options: " -f -K -i size=512 -n size=8192 " 8 | 9 | - name: Set XFS options for RAID devices 10 | set_fact: 11 | raid_options: 12 | " -d sw={{ gluster_infra_diskcount }},\ 13 | su={{ gluster_infra_stripe_unit_size }}k " 14 | when: > 15 | gluster_infra_disktype == 'RAID6' or 16 | gluster_infra_disktype == 'RAID10' or 17 | gluster_infra_disktype == 'RAID5' 18 | 19 | - name: Check if thin block devices exists 20 | shell: > 21 | {%if (item.pvs is defined) %} 22 | {% for pvsname in item.pvs.split(",") %} 23 | test -b {{ pvsname }} && echo "1" || echo "0"; 24 | {% endfor %} 25 | {% else %} 26 | echo "1" 27 | {% endif %} 28 | register: lvt_device_exists 29 | with_items: "{{ gluster_infra_lv_logicalvols }}" 30 | when: gluster_infra_lv_logicalvols is defined and item is not none 31 | 32 | # We support only XFS. Filesysem options sw, su are specific to XFS 33 | - name: Create filesystem on thin logical vols 34 | command: "mkfs.xfs -f {{- fs_options -}} 35 | {{- raid_options | default('') -}} 36 | {% if raid_options is not defined 37 | and item.raid is defined and item.raid is not none 38 | and item.raid.level is defined and item.raid.devices is defined and item.raid.stripe is defined 39 | and item.raid.level in [0,5,6,10]%} 40 | {% if item.raid.level == 0 %} 41 | {{ '-d sw=' ~ (item.raid.devices|int)|int}} 42 | {% elif item.raid.level == 5 %} 43 | {{ '-d sw=' ~ (item.raid.devices|int-1)|int }} 44 | {% elif item.raid.level == 6 %} 45 | {{ '-d sw=' ~ (item.raid.devices|int-2)|int }} 46 | {% elif item.raid.level == 10 %} 47 | {{ '-d sw=' ~ (item.raid.devices|int/2)|int}} 48 | {% endif %} 49 | {{ ' -d ,su=' ~ (item.raid.stripe|int) ~ 'k' }} 50 | {% endif %} /dev/{{ item.vgname }}/{{ item.lvname }}" 51 | # filesystem: 52 | # fstype: xfs 53 | # dev: "/dev/{{ item.vgname }}/{{ item.lvname }}" 54 | # opts: >- 55 | # {{- fs_options -}} 56 | # {{- raid_options | default('') -}} 57 | # {% if raid_options is not defined 58 | # and item.raid is defined and item.raid is not none 59 | # and item.raid.level is defined and item.raid.devices is defined and item.raid.stripe is defined 60 | # and item.raid.level in [0,5,6,10]%} 61 | # {% if item.raid.level == 0 %} 62 | # {{ '-d sw=' ~ (item.raid.devices|int)|int}} 63 | # {% elif item.raid.level == 5 %} 64 | # {{ '-d sw=' ~ (item.raid.devices|int-1)|int }} 65 | # {% elif item.raid.level == 6 %} 66 | # {{ '-d sw=' ~ (item.raid.devices|int-2)|int }} 67 | # {% elif item.raid.level == 10 %} 68 | # {{ '-d sw=' ~ (item.raid.devices|int/2)|int}} 69 | # {% endif %} 70 | # {{ " -d su=" ~ (item.raid.stripe|int) ~ "k" }} 71 | # {% endif %} 72 | # force: "{{ gluster_infra_fs_force | default('no') }}" 73 | with_items: "{{ (gluster_infra_lv_logicalvols is not none and gluster_infra_lv_logicalvols) or [] }}" 74 | loop_control: 75 | index_var: index 76 | when: > 77 | gluster_infra_lv_logicalvols is defined and (item.skipfs is not defined or not item.skipfs) 78 | and lvt_device_exists.results[index].stdout_lines is defined and "0" not in lvt_device_exists.results[index].stdout_lines 79 | 80 | 81 | - name: Check if thick block devices exists 82 | shell: > 83 | {%if (item.pvs is defined) %} 84 | {% for pvsname in item.pvs.split(",") %} 85 | test -b {{ pvsname }} && echo "1" || echo "0"; 86 | {% endfor %} 87 | {% else %} 88 | echo "1" 89 | {% endif %} 90 | register: lv_device_exists 91 | with_items: "{{ gluster_infra_thick_lvs }}" 92 | when: gluster_infra_thick_lvs is defined and item is not none 93 | 94 | - name: Create filesystem on thick logical vols 95 | command: "mkfs.xfs -f {{- fs_options -}} 96 | {{- raid_options | default('') -}} 97 | {% if raid_options is not defined 98 | and item.raid is defined and item.raid is not none 99 | and item.raid.level is defined and item.raid.devices is defined and item.raid.stripe is defined 100 | and item.raid.level in [0,5,6,10]%} 101 | {% if item.raid.level == 0 %} 102 | {{ '-d sw=' ~ (item.raid.devices|int)|int}} 103 | {% elif item.raid.level == 5 %} 104 | {{ '-d sw=' ~ (item.raid.devices|int-1)|int }} 105 | {% elif item.raid.level == 6 %} 106 | {{ '-d sw=' ~ (item.raid.devices|int-2)|int }} 107 | {% elif item.raid.level == 10 %} 108 | {{ '-d sw=' ~ (item.raid.devices|int/2)|int}} 109 | {% endif %} 110 | {{ ' -d ,su=' ~ (item.raid.stripe|int) ~ 'k' }} 111 | {% endif %} /dev/{{ item.vgname }}/{{ item.lvname }}" 112 | # filesystem: 113 | # fstype: xfs 114 | # dev: "/dev/{{ item.vgname }}/{{ item.lvname }}" 115 | # opts: >- 116 | # {{- fs_options -}} 117 | # {{- raid_options | default('') -}} 118 | # {% if raid_options is not defined 119 | # and item.raid is defined and item.raid is not none 120 | # and item.raid.level is defined and item.raid.devices is defined and item.raid.stripe is defined 121 | # and item.raid.level in [0,5,6,10]%} 122 | # {% if item.raid.level == 0 %} 123 | # {{ '-d sw=' ~ (item.raid.devices|int)|int}} 124 | # {% elif item.raid.level == 5 %} 125 | # {{ '-d sw=' ~ (item.raid.devices|int-1)|int }} 126 | # {% elif item.raid.level == 6 %} 127 | # {{ '-d sw=' ~ (item.raid.devices|int-2)|int }} 128 | # {% elif item.raid.level == 10 %} 129 | # {{ '-d sw=' ~ (item.raid.devices|int/2)|int}} 130 | # {% endif %} 131 | # {{ " -d su=" ~ (item.raid.stripe|int) ~ "k" }} 132 | # {% endif %} 133 | # force: "{{ gluster_infra_fs_force | default('no') }}" 134 | with_items: "{{ (gluster_infra_thick_lvs is not none and gluster_infra_thick_lvs) or [] }}" 135 | loop_control: 136 | index_var: index 137 | when: > 138 | gluster_infra_thick_lvs is defined and (item.skipfs is not defined or not item.skipfs) 139 | and lv_device_exists.results[index].stdout_lines is defined and "0" not in lv_device_exists.results[index].stdout_lines 140 | 141 | -------------------------------------------------------------------------------- /roles/backend_setup/tasks/thick_lv_create.yml: -------------------------------------------------------------------------------- 1 | --- 2 | 3 | - name: Check if thick-lv block devices exists 4 | shell: > 5 | {%if (item.pvs is defined) %} 6 | {% for pvsname in item.pvs.split(",") %} 7 | test -b {{ pvsname }} && echo "1" || echo "0"; 8 | {% endfor %} 9 | {% else %} 10 | echo "1" 11 | {% endif %} 12 | register: lv_device_exists 13 | with_items: "{{ gluster_infra_thick_lvs }}" 14 | when: item is not none 15 | 16 | - name: Record for missing devices for phase 2 17 | set_fact: 18 | gluster_phase2_has_missing_devices: true 19 | loop: "{{ lv_device_exists.results }}" 20 | when: item.stdout_lines is defined and "0" in item.stdout_lines 21 | 22 | 23 | - include_tasks: get_vg_groupings.yml 24 | vars: 25 | volume_groups: >- 26 | {%- set output=[] -%} 27 | {%- for cnf in gluster_infra_thick_lvs -%} 28 | {%- if cnf is defined and cnf is not none and cnf.vgname is defined 29 | and (cnf.pvs is defined) 30 | -%} 31 | {{- output.append({"vgname": cnf.vgname, "raid": cnf.raid | default() , "pvname": (cnf.pvs|default('')).split(',') | select | list | unique | join(',')}) -}} 32 | {%- endif -%} 33 | {%- endfor -%} 34 | {{- output -}} 35 | when: gluster_infra_thick_lvs is defined and gluster_infra_thick_lvs is not none and gluster_infra_thick_lvs|length >0 36 | 37 | - name: Make sure thick pvs exists in volume group 38 | register: gluster_changed_vgs 39 | shell: "vgcreate -s {%- if (item.value | first).raid is defined and (item.value | first).raid is not none 40 | and (item.value | first).raid.level is defined and (item.value | first).raid.devices is defined and (item.value | first).raid.stripe is defined 41 | and (item.value | first).raid.level in [0,5,6,10] -%} 42 | {%- if (item.value | first).raid.level == 0 -%} 43 | {{- ((item.value | first).raid.devices|int * (item.value | first).raid.stripe|int)|int ~ 'K'-}} 44 | {%- elif (item.value | first).raid.level == 5 -%} 45 | {{- (((item.value | first).raid.devices|int-1) * (item.value | first).raid.stripe|int)|int ~ 'K'-}} 46 | {%- elif (item.value | first).raid.level == 6 -%} 47 | {{- (((item.value | first).raid.devices|int-2) * (item.value | first).raid.stripe|int)|int ~ 'K'-}} 48 | {%- elif (item.value | first).raid.level == 10 %} 49 | {{- (((item.value | first).raid.devices|int/2) * (item.value | first).raid.stripe|int)|int ~ 'K'-}} 50 | {%- endif -%} 51 | {%- else -%} 52 | {{- 4 -}} 53 | {%- endif -%} {{ (item.value | first).vgname }} {{ item.value | json_query('[].pvname') | unique | join(',') }} {% if (item.value | first).raid is defined and (item.value | first).raid is not none 54 | and (item.value | first).raid.level is defined and (item.value | first).raid.devices is defined and (item.value | first).raid.stripe is defined 55 | and (item.value | first).raid.level in [0,5,6,10]%} 56 | {% if (item.value | first).raid.level == 0 %} 57 | {{ '--dataalignment ' ~ ((item.value | first).raid.devices|int * (item.value | first).raid.stripe|int)|int ~ 'K'}} 58 | {% elif (item.value | first).raid.level == 5 %} 59 | {{ '--dataalignment ' ~ (((item.value | first).raid.devices|int-1) * (item.value | first).raid.stripe|int)|int ~ 'K'}} 60 | {% elif (item.value | first).raid.level == 6 %} 61 | {{ '--dataalignment ' ~ (((item.value | first).raid.devices|int-2) * (item.value | first).raid.stripe|int)|int ~ 'K'}} 62 | {% elif (item.value | first).raid.level == 10 %} 63 | {{ '--dataalignment ' ~ (((item.value | first).raid.devices|int/2) * (item.value | first).raid.stripe|int)|int ~ 'K'}} 64 | {% endif %} 65 | {% else %} 66 | {{ '--dataalignment 256K' }} 67 | {% endif %}" 68 | #lvg: 69 | # state: present 70 | # vg: "{{ (item.value | first).vgname }}" 71 | # pvs: "{{ item.value | json_query('[].pvname') | unique | join(',') }}" 72 | # pv_options: >- 73 | # {% if (item.value | first).raid is defined and (item.value | first).raid is not none 74 | # and (item.value | first).raid.level is defined and (item.value | first).raid.devices is defined and (item.value | first).raid.stripe is defined 75 | # and (item.value | first).raid.level in [0,5,6,10]%} 76 | # {% if (item.value | first).raid.level == 0 %} 77 | # {{ '--dataalignment ' ~ ((item.value | first).raid.devices|int * (item.value | first).raid.stripe|int)|int ~ 'K'}} 78 | # {% elif (item.value | first).raid.level == 5 %} 79 | # {{ '--dataalignment ' ~ (((item.value | first).raid.devices|int-1) * (item.value | first).raid.stripe|int)|int ~ 'K'}} 80 | # {% elif (item.value | first).raid.level == 6 %} 81 | # {{ '--dataalignment ' ~ (((item.value | first).raid.devices|int-2) * (item.value | first).raid.stripe|int)|int ~ 'K'}} 82 | # {% elif (item.value | first).raid.level == 10 %} 83 | # {{ '--dataalignment ' ~ (((item.value | first).raid.devices|int/2) * (item.value | first).raid.stripe|int)|int ~ 'K'}} 84 | # {% endif %} 85 | # {% else %} 86 | # {{ "--dataalignment 256K" }} 87 | # {% endif %} 88 | # 89 | # pesize: >- 90 | # {%- if (item.value | first).raid is defined and (item.value | first).raid is not none 91 | # and (item.value | first).raid.level is defined and (item.value | first).raid.devices is defined and (item.value | first).raid.stripe is defined 92 | # and (item.value | first).raid.level in [0,5,6,10] -%} 93 | # {%- if (item.value | first).raid.level == 0 -%} 94 | # {{- ((item.value | first).raid.devices|int * (item.value | first).raid.stripe|int)|int ~ 'K'-}} 95 | # {%- elif (item.value | first).raid.level == 5 -%} 96 | # {{- (((item.value | first).raid.devices|int-1) * (item.value | first).raid.stripe|int)|int ~ 'K'-}} 97 | # {%- elif (item.value | first).raid.level == 6 -%} 98 | # {{- (((item.value | first).raid.devices|int-2) * (item.value | first).raid.stripe|int)|int ~ 'K'-}} 99 | # {%- elif (item.value | first).raid.level == 10 %} 100 | # {{- (((item.value | first).raid.devices|int/2) * (item.value | first).raid.stripe|int)|int ~ 'K'-}} 101 | # {%- endif -%} 102 | # {%- else -%} 103 | # {{- 4 -}} 104 | # {%- endif -%} 105 | loop: "{{ gluster_volumes_by_groupname | dict2items if gluster_volumes_by_groupname is defined and gluster_volumes_by_groupname is not none else [] }}" 106 | loop_control: 107 | index_var: index 108 | when: > 109 | gluster_volumes_by_groupname is defined and gluster_volumes_by_groupname is not none and gluster_volumes_by_groupname|length >0 110 | and item is defined and item.value is defined and item.value|length>0 111 | 112 | - name: update LVM fact's 113 | setup: 114 | filter: 'ansible_lvm' 115 | when: gluster_changed_vgs.changed 116 | 117 | # Create a thick logical volume. 118 | - name: Create thick logical volume 119 | command: "lvcreate -L {{ item.size | default('100%FREE') }} -n {{ item.lvname }} {{ item.pvs | default() }} {{ item.vgname }} " 120 | #lvol: 121 | # state: present 122 | # vg: "{{ item.vgname }}" 123 | # lv: "{{ item.lvname }}" 124 | # size: "{{ item.size | default('100%FREE') }}" 125 | # pvs: "{{ item.pvs | default() }}" 126 | # opts: "{{ item.opts | default() }}" 127 | # shrink: "{{ item.shrink if item.shrink is defined and item.shrink is not none else true }}" 128 | with_items: "{{ gluster_infra_thick_lvs }}" 129 | loop_control: 130 | index_var: index 131 | when: item is not none and lv_device_exists.results[index].stdout_lines is defined and "0" not in lv_device_exists.results[index].stdout_lines 132 | -------------------------------------------------------------------------------- /roles/backend_setup/tasks/thin_volume_create.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # Create a thin logical volume. A thinpool should already have been created by 3 | # now. There can be more than one thinvolume on a thinpool 4 | 5 | - name: Check if thin-lv block devices exists 6 | shell: > 7 | {% if (item.pvs is defined) or (item.meta_pvs is defined) %} 8 | {% for pvsname in (item.pvs|default('')).split(",") | union((item.meta_pvs|default('')).split(",")) %} 9 | {% if pvsname|length>0 %} 10 | test -b {{ pvsname }} && echo "1" || echo "0"; 11 | {% endif %} 12 | {% endfor %} 13 | {% else %} 14 | echo "1" 15 | {% endif %} 16 | register: lvt_device_exists 17 | with_items: "{{ gluster_infra_lv_logicalvols }}" 18 | when: item is not none 19 | 20 | 21 | - name: Record for missing devices for phase 2 22 | set_fact: 23 | gluster_phase2_has_missing_devices: true 24 | loop: "{{ lvt_device_exists.results }}" 25 | when: item.stdout_lines is defined and "0" in item.stdout_lines 26 | 27 | 28 | - name: Check if thinlv exists 29 | shell: "lvs --options 'lv_attr' -a --noheadings {{item.vgname}}/{{item.lvname}}| sed 's/^ *//;s/$//'" 30 | register: thinlv_attrs 31 | with_items: "{{ gluster_infra_lv_logicalvols }}" 32 | loop_control: 33 | index_var: index 34 | when: > 35 | gluster_infra_lv_logicalvols is defined and gluster_infra_lv_logicalvols is not none and gluster_infra_lv_logicalvols|length >0 and item is defined and item is not none 36 | and lvt_device_exists.results[index].stdout_lines is defined and "0" not in lvt_device_exists.results[index].stdout_lines 37 | and ((item.opts is defined and "raid" in item.opts) or item.meta_pvs is defined or item.meta_opts is defined) 38 | 39 | 40 | - include_tasks: get_vg_groupings.yml 41 | vars: 42 | volume_groups: >- 43 | {%- set output=[] -%} 44 | {%- for cnf in gluster_infra_lv_logicalvols -%} 45 | {%- if cnf is defined and cnf is not none and cnf.vgname is defined 46 | and (thinlv_attrs.results[loop.index0].stdout is not defined or thinlv_attrs.results[loop.index0].stdout.find("V") != 0) 47 | and (cnf.meta_pvs is defined or cnf.pvs is defined) 48 | -%} 49 | {{- output.append({"vgname": cnf.vgname, "pvname": (cnf.pvs|default('') ~ ',' ~ (cnf.meta_pvs|default(''))).split(',') | select | list | unique | join(',')}) -}} 50 | {%- endif -%} 51 | {%- endfor -%} 52 | {{- output -}} 53 | when: gluster_infra_lv_logicalvols is defined and gluster_infra_lv_logicalvols is not none and gluster_infra_lv_logicalvols|length >0 54 | 55 | 56 | - name: Make sure meta and thin pvs exists in volume group 57 | register: gluster_changed_vgs 58 | command: "vgcreate --dataalignment 256K -s {{ vg_pesize | default(4) }} {{ (item.value | first).vgname }} {{ item.value | json_query('[].pvname') | unique | join(',') }}" 59 | # lvg: 60 | # state: present 61 | # vg: "{{ (item.value | first).vgname }}" 62 | # pvs: "{{ item.value | json_query('[].pvname') | unique | join(',') }}" 63 | # pv_options: "--dataalignment 256K" 64 | loop: "{{ gluster_volumes_by_groupname | dict2items }}" 65 | loop_control: 66 | index_var: index 67 | when: > 68 | gluster_volumes_by_groupname is defined and gluster_volumes_by_groupname is not none and gluster_volumes_by_groupname|length >0 69 | and item.value|length>0 70 | 71 | - name: update LVM fact's 72 | setup: 73 | filter: 'ansible_lvm' 74 | when: gluster_changed_vgs.changed 75 | 76 | 77 | - name: Create a LV thinlv-data 78 | command: "lvcreate -l {{ item.lvsize | default('100%FREE') }} --options {{ item.opts | default('') }} -n {{ item.lvname }} {{ item.pvs | default() }} {{ item.vgname }} " 79 | # lvol: 80 | # state: present 81 | # shrink: false 82 | # vg: "{{ item.vgname }}" 83 | # lv: "{{ item.lvname }}" 84 | # pvs: "{{ item.pvs | default() }}" 85 | # size: "{{ item.lvsize | default('100%FREE') }}" 86 | # opts: " 87 | # {{ item.opts | default('') }} " 88 | with_items: "{{ gluster_infra_lv_logicalvols }}" 89 | loop_control: 90 | index_var: index 91 | when: > 92 | gluster_infra_lv_logicalvols is defined and gluster_infra_lv_logicalvols is not none and gluster_infra_lv_logicalvols|length >0 and item is defined and item is not none 93 | and lvt_device_exists.results[index].stdout_lines is defined and "0" not in lvt_device_exists.results[index].stdout_lines 94 | and (thinlv_attrs.results[index].stdout is not defined or thinlv_attrs.results[index].stdout.find("V") != 0) 95 | and ((item.opts is defined and "raid" in item.opts) or item.meta_pvs is defined or item.meta_opts is defined) 96 | 97 | 98 | - name: Create a LV thinlv-meta 99 | command: "lvcreate -l {{ item.meta_size | default('16G') }} --options {{ ((item.meta_opts is defined and item.meta_opts) or item.opts) | default('') }} -n {{ item.lvname }}_meta {{ ((item.meta_pvs is defined and item.meta_pvs) or item.pvs) | default() }} {{ item.vgname }} " 100 | # lvol: 101 | # state: present 102 | # shrink: false 103 | # vg: "{{ item.vgname }}" 104 | # lv: "{{ item.lvname }}_meta" 105 | # pvs: "{{ ((item.meta_pvs is defined and item.meta_pvs) or item.pvs) | default() }}" 106 | # size: "{{ item.meta_size | default('16G') }}" 107 | # opts: " 108 | # {{ ((item.meta_opts is defined and item.meta_opts) or item.opts) | default('') }} " 109 | with_items: "{{ gluster_infra_lv_logicalvols }}" 110 | loop_control: 111 | index_var: index 112 | when: > 113 | gluster_infra_lv_logicalvols is defined and gluster_infra_lv_logicalvols is not none and gluster_infra_lv_logicalvols|length >0 and item is defined and item is not none 114 | and lvt_device_exists.results[index].stdout_lines is defined and "0" not in lvt_device_exists.results[index].stdout_lines 115 | and (thinlv_attrs.results[index].stdout is not defined or thinlv_attrs.results[index].stdout.find("V") != 0) 116 | and ((item.opts is defined and "raid" in item.opts) or item.meta_pvs is defined or item.meta_opts is defined) 117 | 118 | 119 | - name: Convert logical volume to a thin-lv 120 | shell: > 121 | lvconvert -y --type thin {{item.vgname}}/{{item.lvname}} 122 | --thinpool {{item.vgname}}/{{item.thinpool}} 123 | --poolmetadata {{ item.lvname }}_meta 124 | --zero n 125 | with_items: "{{ gluster_infra_lv_logicalvols }}" 126 | loop_control: 127 | index_var: index 128 | when: > 129 | gluster_infra_lv_logicalvols is defined and gluster_infra_lv_logicalvols is not none and gluster_infra_lv_logicalvols|length >0 and item is defined and item is not none 130 | and lvt_device_exists.results[index].stdout_lines is defined and "0" not in lvt_device_exists.results[index].stdout_lines 131 | and (thinlv_attrs.results[index].stdout is not defined or thinlv_attrs.results[index].stdout.find("V") != 0) 132 | and ((item.opts is defined and "raid" in item.opts) or item.meta_pvs is defined or item.meta_opts is defined) 133 | 134 | #this fails when the pool doesn't exist 135 | - name: Create thin logical volume 136 | command: "lvcreate -T {{ item.vgname }}/{{ item.thinpool }} -V {{ item.lvsize }} -n {{ item.lvname }}" 137 | # lvol: 138 | # state: present 139 | # vg: "{{ item.vgname }}" 140 | # lv: "{{ item.lvname }}" 141 | # thinpool: "{{ item.thinpool }}" 142 | # size: "{{ item.lvsize }}" 143 | # pvs: "{{ item.pvs | default() }}" 144 | # shrink: "{{ item.shrink | default(true) }}" 145 | # opts: > 146 | # {{ item.opts | default() }} 147 | with_items: "{{ gluster_infra_lv_logicalvols }}" 148 | loop_control: 149 | index_var: index 150 | when: > 151 | gluster_infra_lv_logicalvols is defined and gluster_infra_lv_logicalvols is not none and gluster_infra_lv_logicalvols|length >0 and item is defined and item is not none 152 | and lvt_device_exists.results[index].stdout_lines is defined and "0" not in lvt_device_exists.results[index].stdout_lines 153 | and ((item.opts is not defined or "raid" not in item.opts) and item.meta_pvs is not defined and item.meta_opts is not defined) 154 | -------------------------------------------------------------------------------- /roles/backend_setup/README.md: -------------------------------------------------------------------------------- 1 | gluster.infra 2 | ========= 3 | 4 | This role helps the user to setup the backend for GlusterFS filesystem. 5 | 6 | backend_setup: 7 | - Create volume groups, logical volumes (thinpool, thin lv, thick lv) 8 | - Create xfs filesystem 9 | - Mount the filesystem 10 | 11 | Requirements 12 | ------------ 13 | 14 | Ansible version 2.5 or above 15 | 16 | 17 | Role Variables 18 | -------------- 19 | 20 | ### backend_setup 21 | ----------------- 22 | | Name |Choices| Default value | Comments | 23 | |--------------------------|-------|-----------------------|-----------------------------------| 24 | | gluster_infra_vdo || UNDEF | Mandatory argument if vdo has to be setup. Key/Value pairs have to be given. name and device are the keys, see examples for syntax. | 25 | | gluster_infra_disktype | JBOD / RAID6 / RAID10 | UNDEF | Backend disk type. | 26 | | gluster_infra_diskcount || UNDEF | RAID diskcount, can be ignored if disktype is JBOD | 27 | | gluster_infra_volume_groups || | Mandatory variable, key/value pairs of vgname and pvname. pvname can be comma-separated values if more than a single pv is needed for a vg. See below for syntax. | 28 | | gluster_infra_stripe_unit_size || UNDEF| Stripe unit size (KiB). *DO NOT* including trailing 'k' or 'K' | 29 | | gluster_infra_thinpools || | Thinpool data. This is a dictionary with keys vgname, thinpoolname, thinpoolsize, and poolmetadatasize. See below for syntax and example. | 30 | | gluster_infra_lv_logicalvols || UNDEF | This is a list of hash/dictionary variables, with keys, lvname and lvsize. See below for example. | 31 | | gluster_infra_thick_lvs || UNDEF | Optional. Needed only if thick volume has to be created. This is a dictionary with vgname, lvname, and size as keys. See below for example | 32 | | gluster_infra_mount_devices | | UNDEF | This is a dictionary with mount values. path, vgname, and lv are the keys. | 33 | | gluster_infra_cache_vars | | UNDEF | This variable contains list of dictionaries for setting up LV cache. Variable has following keys: vgname, cachedisk, cachethinpoolname, cachelvname, cachelvsize, cachemetalvname, cachemetalvsize, cachemode. The keys are explained in more detail below| 34 | 35 | 36 | #### VDO Variable 37 | ------------ 38 | If the backend disk has to be configured with VDO the variable gluster_infra_vdo has to be defined. 39 | 40 | | Name |Choices| Default value | Comments | 41 | |--------------------------|-------|-----------------------|-----------------------------------| 42 | | gluster_infra_vdo || UNDEF | Mandatory argument if vdo has to be setup. Key/Value pairs have to be given. See below for syntax and list of keys and values supported. | 43 | 44 | 45 | ``` 46 | For Example: 47 | gluster_infra_vdo: 48 | - { name: 'hc_vdo_1', device: '/dev/vdb' } 49 | - { name: 'hc_vdo_2', device: '/dev/vdc' } 50 | - { name: 'hc_vdo_3', device: '/dev/vdd' } 51 | ``` 52 | 53 | The gluster_infra_vdo variable supports the following keys: 54 | 55 | | VDO Key | Default value | Comments | 56 | |--------------------------|-----------------------|-----------------------------------| 57 | | state | present | VDO state, if present VDO will be created, if absent VDO will be deleted. | 58 | | activated | 'yes' | Whether VDO has to be activated upon creation. | 59 | | running | 'yes' | Whether VDO has to be started | 60 | | logicalsize | UNDEF | Logical size for the vdo | 61 | | compression | 'enabled' | Whether compression has to be enabled | 62 | | blockmapcachesize | '128M' | The amount of memory allocated for caching block map pages, in megabytes (or may be issued with an LVM-style suffix of K, M, G, or T). The default (and minimum) value is 128M. | 63 | | readcache | 'disabled' | Enables or disables the read cache. | 64 | | readcachesize | 0 | Specifies the extra VDO device read cache size in megabytes. | 65 | | emulate512 | 'off' | Enables 512-byte emulation mode, allowing drivers or filesystems to access the VDO volume at 512-byte granularity, instead of the default 4096-byte granularity. | 66 | | slabsize | '2G' | The size of the increment by which the physical size of a VDO volume is grown, in megabytes (or may be issued with an LVM-style suffix of K, M, G, or T). Must be a power of two between 128M and 32G. | 67 | | writepolicy | 'sync' | Specifies the write policy of the VDO volume. The 'sync' mode acknowledges writes only after data is on stable storage. | 68 | | indexmem | '0.25' | Specifies the amount of index memory in gigabytes. | 69 | | indexmode | 'dense' | Specifies the index mode of the Albireo index. | 70 | | ackthreads | '1' | Specifies the number of threads to use for acknowledging completion of requested VDO I/O operations. Valid values are integer values from 1 to 100 (lower numbers are preferable due to overhead). The default is 1.| 71 | | biothreads | '4' | Specifies the number of threads to use for submitting I/O operations to the storage device. Valid values are integer values from 1 to 100 (lower numbers are preferable due to overhead). The default is 4. | 72 | | cputhreads | '2' | Specifies the number of threads to use for CPU-intensive work such as hashing or compression. Valid values are integer values from 1 to 100 (lower numbers are preferable due to overhead). The default is 2. | 73 | | logicalthreads | '1' | Specifies the number of threads across which to subdivide parts of the VDO processing based on logical block addresses. Valid values are integer values from 1 to 100 (lower numbers are preferable due to overhead). The default is 1.| 74 | | physicalthreads | '1' | Specifies the number of threads across which to subdivide parts of the VDO processing based on physical block addresses. Valid values are integer values from 1 to 16 (lower numbers are preferable due to overhead). The physical space used by the VDO volume must be larger than (slabsize * physicalthreads). The default is 1. | 75 | 76 | 77 | #### Volume Groups variable 78 | ------------------------ 79 | | Name |Choices| Default value | Comments | 80 | |--------------------------|-------|-----------------------|-----------------------------------| 81 | | gluster_infra_volume_groups || UNDEF | This is a list of hash/dictionary variables, with keys, vgname and pvname. See below for example. | 82 | 83 | ``` 84 | For Example: 85 | gluster_infra_volume_groups: 86 | - { vgname: 'volgroup1', pvname: '/dev/sdb' } 87 | - { vgname: 'volgroup2', pvname: '/dev/mapper/vdo_device1' } 88 | - { vgname: 'volgroup3', pvname: '/dev/sdc,/dev/sdd' } 89 | ``` 90 | 91 | #### Logical Volume variable 92 | ----------------------- 93 | | Name |Choices| Default value | Comments | 94 | |--------------------------|-------|-----------------------|-----------------------------------| 95 | | gluster_infra_lv_logicalvols || UNDEF | This is a list of hash/dictionary variables, with keys, lvname, vgname, thinpool, and lvsize. See below for example. | 96 | 97 | ``` 98 | For Example: 99 | gluster_infra_lv_logicalvols: 100 | - { vgname: 'vg_vdb', thinpool: 'foo_thinpool', lvname: 'vg_vdb_thinlv', lvsize: '500G' } 101 | - { vgname: 'vg_vdc', thinpool: 'bar_thinpool', lvname: 'vg_vdc_thinlv', lvsize: '500G' } 102 | ``` 103 | 104 | #### Thick LV variable 105 | ----------------------- 106 | | Name |Choices| Default value | Comments | 107 | |--------------------------|-------|-----------------------|-----------------------------------| 108 | | gluster_infra_thick_lvs || UNDEF | This is a list of hash/dictionary variables, with keys: vgname, lvname, and size. See below for example. | 109 | 110 | 111 | ``` 112 | For Example: 113 | gluster_infra_thick_lvs: 114 | - { vgname: 'vg_ssd', lvname: 'thick_lv_1', size: '500G' } 115 | - { vgname: 'vg_sdc', lvname: 'thick_lv_2', size: '100G' } 116 | ``` 117 | 118 | #### Thinpool variable 119 | ---------------------- 120 | | Name |Choices| Default value | Comments | 121 | |--------------------------|-------|-----------------------|-----------------------------------| 122 | | gluster_infra_thinpools || UNDEF | This is a list of hash/dictionary variables, with keys: vgname, thinpoolname, thinpoolsize, and poolmetadatasize. See below for example. | 123 | 124 | ``` 125 | gluster_infra_thinpools: 126 | - {vgname: 'vg_vdb', thinpoolname: 'foo_thinpool', thinpoolsize: '10G', poolmetadatasize: '1G' } 127 | - {vgname: 'vg_vdc', thinpoolname: 'bar_thinpool', thinpoolsize: '20G', poolmetadatasize: '1G' } 128 | ``` 129 | 130 | * poolmetadatasize: Metadata size for LV, recommended value 16G is used by default. That value can be overridden by setting the variable. Include the unit [G\|M\|K] 131 | * thinpoolname: Can be ignored, a name is formed using the given vgname followed by '_thinpool' 132 | * vgname: Name of the volume group this thinpool should belong to. 133 | 134 | #### Variables for setting up cache 135 | ----------------------------------------- 136 | | Name |Choices| Default value | Comments | 137 | |--------------------------|-------|-----------------------|-----------------------------------| 138 | | gluster_infra_cache_vars | | UNDEF | This is a dictionary with keys: vgname, cachedisk, cachethinpoolname, cachelvname, cachelvsize, cachemetalvname, cachemetalvsize, cachemode | 139 | 140 | ``` 141 | vgname - The vg which will be extended to setup cache. 142 | cachedisk - The SSD disk which will be used to setup cache. Complete path, for eg: /dev/sdd 143 | NOTE: In case of Ansible >= 2.8 this variable is a comma separated list of PVs, comprising of the existing PVs part of the volume group and the PV that has to be added as cache. For example if a cache disk sdd has to be added to a volume group foo_vg containing PVs sdb and sdc, this variable looks like '/dev/sdb,/dev/sdc,/dev/sdd' 144 | cachethinpoolname - The existing thinpool on the volume group mentioned above. 145 | cachelvname - Logical volume name for setting up cache, an lv with this name is created. 146 | cachelvsize - Cache logical volume size 147 | cachemetalvname - Meta LV name. 148 | cachemetalvsize - Meta LV size 149 | cachemode - Cachemode, default is writethrough. 150 | ``` 151 | 152 | For example: 153 | ``` 154 | - { vgname: 'vg_vdc', cachedisk: '/dev/vdc,/dev/vdd', cachethinpoolname: 'foo_thinpool', cachelvname: 'cachelv', cachelvsize: '20G', cachemetalvname: 'cachemeta', cachemetalvsize: '100M', cachemode: 'writethrough' } 155 | ``` 156 | 157 | 158 | #### Variables for mounting the filesystem 159 | ----------------------------------------- 160 | | Name |Choices| Default value | Comments | 161 | |--------------------------|-------|-----------------------|-----------------------------------| 162 | | gluster_infra_mount_devices | | UNDEF | This is a dictionary with mount values. path, vgname, and lv are the keys. | 163 | 164 | ``` 165 | For example: 166 | gluster_infra_mount_devices: 167 | - { path: '/mnt/thinv', vgname: , lv: } 168 | - { path: '/mnt/thicklv', vgname: , lv: 'thick_lv_1' } 169 | ``` 170 | 171 | 172 | Example Playbook 173 | ---------------- 174 | 175 | Configure the ports and services related to GlusterFS, create logical volumes and mount them. 176 | 177 | 178 | ``` 179 | --- 180 | - name: Setting up backend 181 | remote_user: root 182 | hosts: gluster_servers 183 | gather_facts: false 184 | 185 | vars: 186 | # Firewall setup 187 | gluster_infra_fw_ports: 188 | - 2049/tcp 189 | - 54321/tcp 190 | - 5900/tcp 191 | - 5900-6923/tcp 192 | - 5666/tcp 193 | - 16514/tcp 194 | gluster_infra_fw_services: 195 | - glusterfs 196 | 197 | # Set a disk type, Options: JBOD, RAID6, RAID10 198 | gluster_infra_disktype: RAID6 199 | 200 | # RAID6 and RAID10 diskcount (Needed only when disktype is raid) 201 | gluster_infra_diskcount: 10 202 | # Stripe unit size always in KiB 203 | gluster_infra_stripe_unit_size: 128 204 | 205 | # Variables for creating volume group 206 | gluster_infra_volume_groups: 207 | - { vgname: 'vg_vdb', pvname: '/dev/vdb' } 208 | - { vgname: 'vg_vdc', pvname: '/dev/vdc' } 209 | 210 | # Create a thick volume name 211 | gluster_infra_thick_lvs: 212 | - { vgname: 'vg_vdb', lvname: 'thicklv_1', size: '100G' } 213 | 214 | # Create thinpools 215 | gluster_infra_thinpools: 216 | - {vgname: 'vg_vdb', thinpoolname: 'foo_thinpool', thinpoolsize: '100G', poolmetadatasize: '16G'} 217 | - {vgname: 'vg_vdc', thinpoolname: 'bar_thinpool', thinpoolsize: '500G', poolmetadatasize: '16G'} 218 | 219 | # Create a thin volume 220 | gluster_infra_lv_logicalvols: 221 | - { vgname: 'vg_vdb', thinpool: 'foo_thinpool', lvname: 'vg_vdb_thinlv', lvsize: '500G' } 222 | - { vgname: 'vg_vdc', thinpool: 'bar_thinpool', lvname: 'vg_vdc_thinlv', lvsize: '500G' } 223 | 224 | # Mount the devices 225 | gluster_infra_mount_devices: 226 | - { path: '/mnt/thicklv', vgname: 'vg_vdb', lvname: 'thicklv_1' } 227 | - { path: '/mnt/thinlv1', vgname: 'vg_vdb', lvname: 'vg_vdb_thinlv' } 228 | - { path: '/mnt/thinlv2', vgname: 'vg_vdc', lvname: 'vg_vdc_thinlv' } 229 | 230 | roles: 231 | - gluster.infra 232 | ``` 233 | 234 | See also: https://github.com/gluster/gluster-ansible-infra/tree/master/playbooks 235 | 236 | 237 | License 238 | ------- 239 | 240 | GPLv3 241 | -------------------------------------------------------------------------------- /roles/backend_setup/tasks/thin_pool_create.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # Chunksize is calculated as follows for GlusterFS' optimal performance. 3 | # RAID6: 4 | # full_stripe_size = stripe_unit_size * no_of_data_disks 5 | # 6 | # Where full_stripe_size should be between 1 MiB and 2 MiB. And chunksize is set 7 | # to full_stripe_size 8 | # 9 | - name: Calculate chunksize for RAID6/RAID10/RAID5 10 | set_fact: 11 | lv_chunksize: > 12 | {{ gluster_infra_stripe_unit_size|int * 13 | gluster_infra_diskcount|int }}KiB 14 | when: > 15 | gluster_infra_disktype == 'RAID6' or 16 | gluster_infra_disktype == 'RAID10' or 17 | gluster_infra_disktype == 'RAID5' 18 | 19 | # For JBOD the thin pool chunk size is set to 256 KiB. 20 | - name: Set chunksize for JBOD 21 | set_fact: 22 | lv_chunksize: '256K' 23 | when: gluster_infra_disktype == 'JBOD' 24 | 25 | - name: Check if thin-pool block devices exists 26 | shell: > 27 | {%if (item.pvs is defined) or (item.meta_pvs is defined) %} 28 | {% for pvsname in (item.pvs|default('')).split(",") | union((item.meta_pvs|default('')).split(",")) %} 29 | {% if pvsname|length>0 %} 30 | test -b {{ pvsname }} && echo "1" || echo "0"; 31 | {% endif %} 32 | {% endfor %} 33 | {% else %} 34 | echo "1" 35 | {% endif %} 36 | register: lvtp_device_exists 37 | with_items: "{{ gluster_infra_thinpools }}" 38 | when: item is not none 39 | 40 | 41 | - name: Record for missing devices for phase 2 42 | set_fact: 43 | gluster_phase2_has_missing_devices: true 44 | loop: "{{ lvtp_device_exists.results }}" 45 | when: item.stdout_lines is defined and "0" in item.stdout_lines 46 | 47 | - name: Check if thinpool exists 48 | shell: "lvs --options 'lv_attr' -a --noheadings {{item.vgname}}/{{item.thinpoolname}}| sed 's/^ *//;s/$//'" 49 | register: thinpool_attrs 50 | with_items: "{{ gluster_infra_thinpools }}" 51 | loop_control: 52 | index_var: index 53 | when: > 54 | gluster_infra_thinpools is defined and gluster_infra_thinpools is not none and gluster_infra_thinpools|length >0 55 | and item is defined and item is not none and item.thinpoolname is defined and item.thinpoolname is defined and item.vgname is defined 56 | and lvtp_device_exists.results[index].stdout_lines is defined and "0" not in lvtp_device_exists.results[index].stdout_lines 57 | and ((item.opts is defined and "raid" in item.opts) or item.meta_pvs is defined or item.meta_opts is defined) 58 | 59 | - include_tasks: get_vg_groupings.yml 60 | vars: 61 | volume_groups: >- 62 | {%- set output=[] -%} 63 | {%- for cnf in gluster_infra_thinpools -%} 64 | {%- if cnf is defined and cnf is not none and cnf.thinpoolname is defined and cnf.vgname is defined 65 | and (thinpool_attrs.results[loop.index0].stdout is not defined or thinpool_attrs.results[loop.index0].stdout.find("t") != 0) 66 | and (cnf.meta_pvs is defined or cnf.pvs is defined) 67 | -%} 68 | {{- output.append({"vgname": cnf.vgname, "pvname": (cnf.pvs|default('') ~ ',' ~ (cnf.meta_pvs|default(''))).split(',') | select | list | unique | join(',')}) -}} 69 | {%- endif -%} 70 | {%- endfor -%} 71 | {{- output -}} 72 | when: gluster_infra_thinpools is defined and gluster_infra_thinpools is not none and gluster_infra_thinpools|length >0 73 | 74 | # https://github.com/ansible/ansible/issues/13262 75 | # block of tasks, which is executed when there are valid pools and pool items are configured. 76 | # also it checks if the pool doesn't already exists 77 | 78 | - name: Make sure meta and pool pvs exists in volume group 79 | register: gluster_changed_vgs 80 | command: "vgcreate -s {%- if (item.value | first).raid is defined and (item.value | first).raid is not none 81 | and (item.value | first).raid.level is defined and (item.value | first).raid.devices is defined and (item.value | first).raid.stripe is defined 82 | and (item.value | first).raid.level in [0,5,6,10] -%} 83 | {%- if (item.value | first).raid.level == 0 -%} 84 | {{- ((item.value | first).raid.devices|int * (item.value | first).raid.stripe|int)|int ~ 'K'-}} 85 | {%- elif (item.value | first).raid.level == 5 -%} 86 | {{- (((item.value | first).raid.devices|int-1) * (item.value | first).raid.stripe|int)|int ~ 'K'-}} 87 | {%- elif (item.value | first).raid.level == 6 -%} 88 | {{- (((item.value | first).raid.devices|int-2) * (item.value | first).raid.stripe|int)|int ~ 'K'-}} 89 | {%- elif (item.value | first).raid.level == 10 %} 90 | {{- (((item.value | first).raid.devices|int/2) * (item.value | first).raid.stripe|int)|int ~ 'K'-}} 91 | {%- endif -%} 92 | {%- else -%} 93 | {{- 4 -}} 94 | {%- endif -%} {{ (item.value | first).vgname }} {{ item.value | json_query('[].pvname') | unique | join(',') }} {% if (item.value | first).raid is defined and (item.value | first).raid is not none 95 | and (item.value | first).raid.level is defined and (item.value | first).raid.devices is defined and (item.value | first).raid.stripe is defined 96 | and (item.value | first).raid.level in [0,5,6,10]%} 97 | {% if (item.value | first).raid.level == 0 %} 98 | {{ '--dataalignment ' ~ ((item.value | first).raid.devices|int * (item.value | first).raid.stripe|int)|int ~ 'K'}} 99 | {% elif (item.value | first).raid.level == 5 %} 100 | {{ '--dataalignment ' ~ (((item.value | first).raid.devices|int-1) * (item.value | first).raid.stripe|int)|int ~ 'K'}} 101 | {% elif (item.value | first).raid.level == 6 %} 102 | {{ '--dataalignment ' ~ (((item.value | first).raid.devices|int-2) * (item.value | first).raid.stripe|int)|int ~ 'K'}} 103 | {% elif (item.value | first).raid.level == 10 %} 104 | {{ '--dataalignment ' ~ (((item.value | first).raid.devices|int/2) * (item.value | first).raid.stripe|int)|int ~ 'K'}} 105 | {% endif %} 106 | {% else %} 107 | {{ '--dataalignment 256K' }} 108 | {% endif %}" 109 | #lvg: 110 | # state: present 111 | # vg: "{{ (item.value | first).vgname }}" 112 | # pvs: "{{ item.value | json_query('[].pvname') | unique | join(',') }}" 113 | # pv_options: >- 114 | # {% if (item.value | first).raid is defined and (item.value | first).raid is not none 115 | # and (item.value | first).raid.level is defined and (item.value | first).raid.devices is defined and (item.value | first).raid.stripe is defined 116 | # and (item.value | first).raid.level in [0,5,6,10]%} 117 | # {% if (item.value | first).raid.level == 0 %} 118 | # {{ '--dataalignment ' ~ ((item.value | first).raid.devices|int * (item.value | first).raid.stripe|int)|int ~ 'K'}} 119 | # {% elif (item.value | first).raid.level == 5 %} 120 | # {{ '--dataalignment ' ~ (((item.value | first).raid.devices|int-1) * (item.value | first).raid.stripe|int)|int ~ 'K'}} 121 | # {% elif (item.value | first).raid.level == 6 %} 122 | # {{ '--dataalignment ' ~ (((item.value | first).raid.devices|int-2) * (item.value | first).raid.stripe|int)|int ~ 'K'}} 123 | # {% elif (item.value | first).raid.level == 10 %} 124 | # {{ '--dataalignment ' ~ (((item.value | first).raid.devices|int/2) * (item.value | first).raid.stripe|int)|int ~ 'K'}} 125 | # {% endif %} 126 | # {% else %} 127 | # {{ "--dataalignment 256K" }} 128 | # {% endif %} 129 | 130 | # pesize: >- 131 | # {%- if (item.value | first).raid is defined and (item.value | first).raid is not none 132 | # and (item.value | first).raid.level is defined and (item.value | first).raid.devices is defined and (item.value | first).raid.stripe is defined 133 | # and (item.value | first).raid.level in [0,5,6,10] -%} 134 | # {%- if (item.value | first).raid.level == 0 -%} 135 | # {{- ((item.value | first).raid.devices|int * (item.value | first).raid.stripe|int)|int ~ 'K'-}} 136 | # {%- elif (item.value | first).raid.level == 5 -%} 137 | # {{- (((item.value | first).raid.devices|int-1) * (item.value | first).raid.stripe|int)|int ~ 'K'-}} 138 | # {%- elif (item.value | first).raid.level == 6 -%} 139 | # {{- (((item.value | first).raid.devices|int-2) * (item.value | first).raid.stripe|int)|int ~ 'K'-}} 140 | # {%- elif (item.value | first).raid.level == 10 %} 141 | # {{- (((item.value | first).raid.devices|int/2) * (item.value | first).raid.stripe|int)|int ~ 'K'-}} 142 | # {%- endif -%} 143 | # {%- else -%} 144 | # {{- 4 -}} 145 | # {%- endif -%} 146 | loop: "{{ gluster_volumes_by_groupname | dict2items }}" 147 | loop_control: 148 | index_var: index 149 | when: > 150 | gluster_volumes_by_groupname is defined and gluster_volumes_by_groupname is not none and gluster_volumes_by_groupname|length >0 151 | and item.value|length>0 152 | 153 | - name: update LVM fact's 154 | setup: 155 | filter: 'ansible_lvm' 156 | when: gluster_changed_vgs.changed 157 | 158 | - name: Create a LV thinpool-data 159 | command: "lvcreate -l {{ item.thinpoolsize | default('100%FREE') }} --options {{ item.opts | default('') }} -n {{ item.thinpoolname }} {{ item.pvs | default() }} {{ item.vgname }} " 160 | # lvol: 161 | # state: present 162 | # shrink: false 163 | # vg: "{{ item.vgname }}" 164 | # lv: "{{ item.thinpoolname }}" 165 | # pvs: "{{ item.pvs | default() }}" 166 | # size: "{{ item.thinpoolsize | default('100%FREE') }}" 167 | # opts: " 168 | # {{ item.opts | default('') }} " 169 | with_items: "{{ gluster_infra_thinpools }}" 170 | loop_control: 171 | index_var: index 172 | when: > 173 | gluster_infra_thinpools is defined and gluster_infra_thinpools is not none and gluster_infra_thinpools|length >0 174 | and item is defined and item is not none and item.thinpoolname is defined and item.thinpoolname is defined and item.vgname is defined 175 | and lvtp_device_exists.results[index].stdout_lines is defined and "0" not in lvtp_device_exists.results[index].stdout_lines 176 | and (thinpool_attrs.results[index].stdout is not defined or thinpool_attrs.results[index].stdout.find("t") != 0) 177 | and ((item.opts is defined and "raid" in item.opts) or item.meta_pvs is defined or item.meta_opts is defined) 178 | 179 | 180 | - name: Create a LV thinpool-meta 181 | command: "lvcreate -l {{ item.poolmetadatasize | default('16G') }} --options {{ ((item.meta_opts is defined and item.meta_opts) or item.opts) | default('') }} -n {{ item.thinpoolname }}_meta {{ ((item.meta_pvs is defined and item.meta_pvs) or item.pvs) | default() }} {{ item.vgname }} " 182 | # lvol: 183 | # state: present 184 | # shrink: false 185 | # vg: "{{ item.vgname }}" 186 | # lv: "{{ item.thinpoolname }}_meta" 187 | # pvs: "{{ ((item.meta_pvs is defined and item.meta_pvs) or item.pvs) | default() }}" 188 | # size: "{{ item.poolmetadatasize | default('16G') }}" 189 | # opts: " 190 | # {{ ((item.meta_opts is defined and item.meta_opts) or item.opts) | default('') }} " 191 | with_items: "{{ gluster_infra_thinpools }}" 192 | loop_control: 193 | index_var: index 194 | when: > 195 | gluster_infra_thinpools is defined and gluster_infra_thinpools is not none and gluster_infra_thinpools|length >0 196 | and item is defined and item is not none and item.thinpoolname is defined and item.thinpoolname is defined and item.vgname is defined 197 | and lvtp_device_exists.results[index].stdout_lines is defined and "0" not in lvtp_device_exists.results[index].stdout_lines 198 | and (thinpool_attrs.results[index].stdout is not defined or thinpool_attrs.results[index].stdout.find("t") != 0) 199 | and ((item.opts is defined and "raid" in item.opts) or item.meta_pvs is defined or item.meta_opts is defined) 200 | 201 | 202 | 203 | - name: Convert logical volume to a thin-pool 204 | shell: >- 205 | lvconvert -y --type thin-pool {{item.vgname}}/{{item.thinpoolname}} 206 | --poolmetadata {{ item.thinpoolname }}_meta 207 | {% if item.raid is defined and item.raid is not none 208 | and item.raid.level is defined and item.raid.devices is defined and item.raid.stripe is defined 209 | and item.raid.level in [0,5,6,10]%} 210 | {% if item.raid.level == 0 %} 211 | {{ '--chunksize' ~ (item.raid.devices|int * item.raid.stripe|int)|int ~ 'K'}} 212 | {% elif item.raid.level == 5 %} 213 | {{ '--chunksize' ~ ((item.raid.devices|int-1) * item.raid.stripe|int)|int ~ 'K'}} 214 | {% elif item.raid.level == 6 %} 215 | {{ '--chunksize' ~ ((item.raid.devices|int-2) * item.raid.stripe|int)|int ~ 'K'}} 216 | {% elif item.raid.level == 10 %} 217 | {{ '--chunksize' ~ ((item.raid.devices|int/2) * item.raid.stripe|int)|int ~ 'K'}} 218 | {% endif %} 219 | {% else %} 220 | {{ "--chunksize 256K" }} 221 | {% endif %} 222 | --zero n 223 | with_items: "{{ gluster_infra_thinpools }}" 224 | loop_control: 225 | index_var: index 226 | when: > 227 | gluster_infra_thinpools is defined and gluster_infra_thinpools is not none and gluster_infra_thinpools|length >0 228 | and item is defined and item is not none and item.thinpoolname is defined and item.thinpoolname is defined and item.vgname is defined 229 | and lvtp_device_exists.results[index].stdout_lines is defined and "0" not in lvtp_device_exists.results[index].stdout_lines 230 | and (thinpool_attrs.results[index].stdout is not defined or thinpool_attrs.results[index].stdout.find("t") != 0) 231 | and ((item.opts is defined and "raid" in item.opts) or item.meta_pvs is defined or item.meta_opts is defined) 232 | 233 | 234 | - name: Create a LV thinpool 235 | command: "lvcreate {% if item.thinpoolsize is defined %} -L {{ item.thinpoolsize }} {% else %} -l 100%FREE {% endif %} --options {% if item.raid is defined and item.raid is not none 236 | and item.raid.level is defined and item.raid.devices is defined and item.raid.stripe is defined 237 | and item.raid.level in [0,5,6,10]%} 238 | {% if item.raid.level == 0 %} 239 | {{ '--chunksize' ~ (item.raid.devices|int * item.raid.stripe|int)|int ~ 'K'}} 240 | {% elif item.raid.level == 5 %} 241 | {{ '--chunksize' ~ ((item.raid.devices|int-1) * item.raid.stripe|int)|int ~ 'K'}} 242 | {% elif item.raid.level == 6 %} 243 | {{ '--chunksize' ~ ((item.raid.devices|int-2) * item.raid.stripe|int)|int ~ 'K'}} 244 | {% elif item.raid.level == 10 %} 245 | {{ '--chunksize' ~ ((item.raid.devices|int/2) * item.raid.stripe|int)|int ~ 'K'}} 246 | {% endif %} 247 | {% else %} 248 | {{ '--chunksize 256K' }} 249 | {% endif %} 250 | --poolmetadatasize {{ item.poolmetadatasize }} 251 | --zero n 252 | {{ item.opts | default('') }} -n {{ item.thinpoolname }} {{ item.pvs | default() }} {{ item.vgname }} " 253 | # lvol: 254 | # state: present 255 | # shrink: false 256 | # vg: "{{ item.vgname }}" 257 | # pvs: "{{ item.pvs | default() }}" 258 | # thinpool: "{{ item.thinpoolname }}" 259 | # size: "{{ item.thinpoolsize | default('100%FREE') }}" 260 | # opts: >- 261 | # {% if item.raid is defined and item.raid is not none 262 | # and item.raid.level is defined and item.raid.devices is defined and item.raid.stripe is defined 263 | # and item.raid.level in [0,5,6,10]%} 264 | # {% if item.raid.level == 0 %} 265 | # {{ '--chunksize' ~ (item.raid.devices|int * item.raid.stripe|int)|int ~ 'K'}} 266 | # {% elif item.raid.level == 5 %} 267 | # {{ '--chunksize' ~ ((item.raid.devices|int-1) * item.raid.stripe|int)|int ~ 'K'}} 268 | # {% elif item.raid.level == 6 %} 269 | # {{ '--chunksize' ~ ((item.raid.devices|int-2) * item.raid.stripe|int)|int ~ 'K'}} 270 | # {% elif item.raid.level == 10 %} 271 | # {{ '--chunksize' ~ ((item.raid.devices|int/2) * item.raid.stripe|int)|int ~ 'K'}} 272 | # {% endif %} 273 | # {% else %} 274 | # {{ '--chunksize 256K' }} 275 | # {% endif %} 276 | # --poolmetadatasize {{ item.poolmetadatasize }} 277 | # --zero n 278 | # {{ item.opts | default('') }} 279 | with_items: "{{ gluster_infra_thinpools }}" 280 | loop_control: 281 | index_var: index 282 | when: > 283 | gluster_infra_thinpools is defined and gluster_infra_thinpools is not none and gluster_infra_thinpools|length >0 284 | and item is defined and item is not none and item.thinpoolname is defined and item.thinpoolname is defined and item.vgname is defined 285 | and item.raid is defined 286 | #end-block 287 | 288 | - name: Create a LV thinpool for similar device types 289 | command: "lvcreate --type thin-pool --zero n {% if item.thinpoolsize is defined %} -L {{ item.thinpoolsize }} {% else %} -l 100%FREE {% endif %} --chunksize {{ lv_chunksize }} --poolmetadatasize {{ item.poolmetadatasize + \"iB\" }} -n {{ item.thinpoolname }} {{ item.vgname }} " 290 | # lvol: 291 | # state: present 292 | # shrink: false 293 | # vg: "{{ item.vgname }}" 294 | # thinpool: "{{ item.thinpoolname }}" 295 | # size: "{{ item.thinpoolsize | default('100%FREE') }}" 296 | # opts: " --chunksize {{ lv_chunksize }} 297 | # --poolmetadatasize {{ item.poolmetadatasize }} 298 | # --zero n" 299 | with_items: "{{ gluster_infra_thinpools }}" 300 | when: gluster_infra_thinpools is defined and item.raid is not defined 301 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | gluster.infra 2 | ========= 3 | 4 | The gluster.infra role allows the user to deploy a GlusterFS cluster. It has sub-roles which can be invoked by setting the variables. The sub-roles are 5 | 6 | 1. firewall_config: 7 | * Set up firewall rules (open ports, add services to zone) 8 | 2. backend_setup: 9 | * Create VDO volume (If vdo is selected) 10 | * Create volume groups, logical volumes (thinpool, thin lv, thick lv) 11 | * Create xfs filesystem 12 | * Mount the filesystem 13 | 14 | Requirements 15 | ------------ 16 | 17 | * Ansible version 2.5 or above 18 | * GlusterFS version 3.2 or above 19 | * VDO utilities (Optional) 20 | 21 | Role Variables 22 | -------------- 23 | 24 | These are the superset of role variables. They are explained again in the 25 | respective sub-roles directory. 26 | 27 | ------------------- 28 | ### firewall_config 29 | 30 | | Name |Choices| Default value | Comments | 31 | |--------------------------|-------|-----------------------|-----------------------------------| 32 | | gluster_infra_fw_state | enabled / disabled / present / absent | UNDEF | Enable or disable a setting. For ports: Should this port accept(enabled) or reject(disabled) connections. The states "present" and "absent" can only be used in zone level operations (i.e. when no other parameters but zone and state are set). | 33 | | gluster_infra_fw_ports | | UNDEF | A list of ports in the format PORT/PROTO. For example 111/tcp. This is a list value. | 34 | | gluster_infra_fw_permanent | true/false | true | Whether to make the rule permanent. | 35 | | gluster_infra_fw_zone | work / drop / internal / external / trusted / home / dmz / public / block | public | The firewalld zone to add/remove to/from | 36 | | gluster_infra_fw_services | | UNDEF | Name of a service to add/remove to/from firewalld - service must be listed in output of firewall-cmd --get-services. This is a list variable 37 | 38 | ----------------- 39 | ### backend_setup 40 | 41 | | Name |Choices| Default value | Comments | 42 | |--------------------------|-------|-----------------------|-----------------------------------| 43 | | gluster_infra_vdo || UNDEF | Mandatory argument if vdo has to be setup. Key/Value pairs have to be given. See examples for syntax. | 44 | | gluster_infra_disktype | JBOD / RAID6 / RAID10 | UNDEF | Backend disk type. | 45 | | gluster_infra_diskcount || UNDEF | Ignored if disktype is JBOD. The number of data disks in your RAID6/RAID10 array. Set this value to 10 if you're using RAID6 with 12 total disks (10 data + 2 parity disks). | 46 | | gluster_infra_volume_groups || UNDEF | Key/value pairs of vgname and pvname. pvname can be comma-separated values if more than a single pv is needed for a vg. See below for syntax. This variable is mandatory when PVs are not specified in the LVs | 47 | | gluster_infra_stripe_unit_size || UNDEF| Stripe unit size (KiB). *DO NOT* including trailing 'k' or 'K' | 48 | | gluster_infra_lv_poolmetadatasize || 16G | Metadata size for LV, recommended value 16G is used by default. That value can be overridden by setting the variable. Include the unit [G\|M\|K] | 49 | | gluster_infra_thinpools || | Thinpool data. This is a dictionary with keys vgname, thinpoolname, thinpoolsize, and poolmetadatasize. See below for syntax and example. | 50 | | gluster_infra_lv_logicalvols || UNDEF | This is a list of hash/dictionary variables, with keys, lvname and lvsize. See below for example. | 51 | | gluster_infra_thick_lvs || UNDEF | Optional. Needed only if thick volume has to be created. This is a dictionary with vgname, lvname, and size as keys. See below for example | 52 | | gluster_infra_mount_devices | | UNDEF | This is a dictionary with mount values. path, vgname, and lvname are the keys. | 53 | | gluster_infra_cache_vars | | UNDEF | This variable contains list of dictionaries for setting up LV cache. Variable has following keys: vgname, cachedisk, cachethinpoolname, cachelvname, cachelvsize, cachemetalvname, cachemetalvsize, cachemode. The keys are explained in more detail below| 54 | |gluster_infra_lvm| | UNDEF | This variable contains a dictionary, which defines how lvm should autoextend thinpools 55 | |fstrim_service|| UNDEF | This variable contains a dictionary, which enables when and how often a TRIM command should be send to the mounted fs, which support this 56 | 57 | ----------------- 58 | #### VDO Variable 59 | 60 | If the backend disk has to be configured with VDO the variable gluster_infra_vdo has to be defined. 61 | 62 | | Name |Choices| Default value | Comments | 63 | |--------------------------|-------|-----------------------|-----------------------------------| 64 | | gluster_infra_vdo || UNDEF | Mandatory argument if vdo has to be setup. Key/Value pairs have to be given. gluster_infra_vdo supports the keys explained below, see examples for syntax. | 65 | 66 | ``` 67 | For Example: 68 | gluster_infra_vdo: 69 | - { name: 'hc_vdo_1', device: '/dev/vdb' } 70 | - { name: 'hc_vdo_2', device: '/dev/vdc' } 71 | - { name: 'hc_vdo_3', device: '/dev/vdd' } 72 | ``` 73 | 74 | The gluster_infra_vdo variable supports the following keys: 75 | 76 | | VDO Key | Default value | Comments | 77 | |--------------------------|-----------------------|-----------------------------------| 78 | | state | present | VDO state, if present VDO will be created, if absent VDO will be deleted. | 79 | | activated | 'yes' | Whether VDO has to be activated upon creation. | 80 | | running | 'yes' | Whether VDO has to be started | 81 | | logicalsize | UNDEF | Logical size for the vdo | 82 | | compression | 'enabled' | Whether compression has to be enabled | 83 | | blockmapcachesize | '128M' | The amount of memory allocated for caching block map pages, in megabytes (or may be issued with an LVM-style suffix of K, M, G, or T). The default (and minimum) value is 128M. | 84 | | readcache | 'disabled' | Enables or disables the read cache. | 85 | | readcachesize | 0 | Specifies the extra VDO device read cache size in megabytes. | 86 | | emulate512 | 'off' | Enables 512-byte emulation mode, allowing drivers or filesystems to access the VDO volume at 512-byte granularity, instead of the default 4096-byte granularity. | 87 | | slabsize | '2G' | The size of the increment by which the physical size of a VDO volume is grown, in megabytes (or may be issued with an LVM-style suffix of K, M, G, or T). Must be a power of two between 128M and 32G. | 88 | | writepolicy | 'sync' | Specifies the write policy of the VDO volume. The 'sync' mode acknowledges writes only after data is on stable storage. | 89 | | indexmem | '0.25' | Specifies the amount of index memory in gigabytes. | 90 | | indexmode | 'dense' | Specifies the index mode of the Albireo index. | 91 | | ackthreads | '1' | Specifies the number of threads to use for acknowledging completion of requested VDO I/O operations. Valid values are integer values from 1 to 100 (lower numbers are preferable due to overhead). The default is 1.| 92 | | biothreads | '4' | Specifies the number of threads to use for submitting I/O operations to the storage device. Valid values are integer values from 1 to 100 (lower numbers are preferable due to overhead). The default is 4. | 93 | | cputhreads | '2' | Specifies the number of threads to use for CPU-intensive work such as hashing or compression. Valid values are integer values from 1 to 100 (lower numbers are preferable due to overhead). The default is 2. | 94 | | logicalthreads | '1' | Specifies the number of threads across which to subdivide parts of the VDO processing based on logical block addresses. Valid values are integer values from 1 to 100 (lower numbers are preferable due to overhead). The default is 1.| 95 | | physicalthreads | '1' | Specifies the number of threads across which to subdivide parts of the VDO processing based on physical block addresses. Valid values are integer values from 1 to 16 (lower numbers are preferable due to overhead). The physical space used by the VDO volume must be larger than (slabsize * physicalthreads). The default is 1. | 96 | 97 | ----------------- 98 | #### Volume Groups variable 99 | 100 | | Name |Choices| Default value | Comments | 101 | |--------------------------|-------|-----------------------|-----------------------------------| 102 | | gluster_infra_volume_groups || UNDEF | This is a list of hash/dictionary variables, with keys, vgname and pvname. See below for example. | 103 | 104 | ``` 105 | For Example: 106 | gluster_infra_volume_groups: 107 | - { vgname: 'volgroup1', pvname: '/dev/sdb' } 108 | - { vgname: 'volgroup2', pvname: '/dev/mapper/vdo_device1' } 109 | - { vgname: 'volgroup3', pvname: '/dev/sdc,/dev/sdd' } 110 | ``` 111 | 112 | * vgname: Required, string defining the VG name to belong to 113 | * pvname: Required, string defining the device paths to pass to the lvg module. Currently the behavior of passing multiple devices is undefined, but should be handled correctly in simple cases 114 | ----------------------- 115 | #### Logical Volume variable 116 | 117 | | Name |Choices| Default value | Comments | 118 | |--------------------------|-------|-----------------------|-----------------------------------| 119 | | gluster_infra_lv_logicalvols || UNDEF | This is a list of hash/dictionary variables, with keys, lvname, vgname, thinpool, and lvsize. See below for example. | 120 | 121 | ``` 122 | For Example: 123 | gluster_infra_lv_logicalvols: 124 | - { vgname: 'vg_vdb', thinpool: 'foo_thinpool', lvname: 'vg_vdb_thinlv', lvsize: '500G' } 125 | - { vgname: 'vg_vdc', thinpool: 'bar_thinpool', lvname: 'vg_vdc_thinlv', lvsize: '500G' } 126 | - { vgname: 'ans_vg', thinpool: 'ans_thinpool4', lvname: 'ans_thinlv5', lvsize: '1G', pvs: '/dev/sdd1,/dev/sdg1', opts: '--type raid1', meta_opts: '--type raid1', meta_pvs: '/dev/sde1,/dev/sdf1' } 127 | - { vgname: 'ans_vg3', thinpool: 'ans_thinpool8', lvname: 'ans_thinlv3', lvsize: '100M', raid: {level: 5, stripe: 64, devices: 3 }} 128 | ``` 129 | 130 | * vgname: Required, string defining the VG name to belong to 131 | * lvname: Required, string defining the name of the LV 132 | * thinpool: Required, string defining the name the thinpool this LV belongs to 133 | * lvsize: Optional, Default 100%, size of LV 134 | * pvs: Optional, Default empty, the physical devices the LV should be placed on 135 | * opts: Optional, Default empty, additional parameters being passed to the lvm module, which uses those in lvcreate 136 | * meta_pvs: Optional, Default empty, the physical devices the metadata volume should be placed on 137 | * meta_opts: Optional, Default empty, additional parameters to pass to lvcreate for creating the metadata volume 138 | * skipfs: Optional Boolean, Default no. When yes no XFS filesystem will be created on the 139 | * shrink: Optional Boolean, Default yes. When no the lvol module will not try to shrink the LV 140 | * raid: Optional Dict, see _raid_. This should be equal to the raid config of the thinpool! example: {level: 5, stripe: 64, devices: 3 } 141 | 142 | ----------------------- 143 | #### Thick LV variable 144 | 145 | | Name |Choices| Default value | Comments | 146 | |--------------------------|-------|-----------------------|-----------------------------------| 147 | | gluster_infra_thick_lvs || UNDEF | This is a list of hash/dictionary variables, with keys, vgname, lvname, and size. See below for example. | 148 | 149 | 150 | ``` 151 | For Example: 152 | gluster_infra_thick_lvs: 153 | - { vgname: 'vg_sdb', lvname: 'thick_lv_1', size: '500G' } 154 | - { vgname: 'vg_sdc', lvname: 'thick_lv_2', size: '100G' } 155 | - { vgname: 'ans_vg', lvname: 'ans_thick2_vdo', size: '9G', atboot: yes, skipfs: yes, opts: "", pvs: '/dev/sdd1,/dev/sdg1' } 156 | ``` 157 | 158 | * vgname: Required, string defining the VG name to belong to 159 | * lvname: Required, string defining the name of the LV 160 | * lvsize: Optional, Default 100%, size of LV 161 | * pvs: Optional, Default empty, the physical devices the LV should be placed on 162 | * opts: Optional, Default empty, additional parameters being passed to the lvm module, which uses those in lvcreate 163 | * skipfs: Optional Boolean, Default no. When yes no XFS filesystem will be created on the LV 164 | * atboot: Optional Boolean, Default no. When yes the parameter "rd.lvm.lv=DM" will be added to the kernel parameters in grub 165 | * shrink: Optional Boolean, Default yes. When no the lvol module will not try to shrink the LV 166 | * raid: Optional Dict, see _raid_. example: {level: 5, stripe: 512, devices: 4 } 167 | 168 | ---------------------- 169 | #### Thinpool variable 170 | 171 | | Name |Choices| Default value | Comments | 172 | |--------------------------|-------|-----------------------|-----------------------------------| 173 | | gluster_infra_thinpools || UNDEF | This is a list of hash/dictionary variables, with keys: vgname, thinpoolname, thinpoolsize, poolmetadatasize, pvs, opts, meta_pvs and meta_opts. See below for example. | 174 | 175 | 176 | ``` 177 | gluster_infra_thinpools: 178 | - {vgname: 'vg_vdb', thinpoolname: 'foo_thinpool', thinpoolsize: '10G', poolmetadatasize: '1G' } 179 | - {vgname: 'vg_vdc', thinpoolname: 'bar_thinpool', thinpoolsize: '20G', poolmetadatasize: '1G' } 180 | - {vgname: 'ans_vg', thinpoolname: 'ans_thinpool', thinpoolsize: '1G', poolmetadatasize: '15M', opts: "", pvs: '/dev/sdd1,/dev/sdg1', meta_opts: '--type raid1', meta_pvs: '/dev/sde1,/dev/sdf1' } 181 | - {vgname: 'ans_vg3', thinpoolname: 'ans_thinpool8', thinpoolsize: '1G', poolmetadatasize: '15M', opts: "--type raid5 --nosync -i 2", pvs: '/dev/sdb1,/dev/sdd1,/dev/sdg1', raid: {level: 5, stripe: 64, devices: 3 }} 182 | ``` 183 | 184 | * poolmetadatasize: Metadata size for LV, recommended value 16G is used by default. That value can be overridden by setting the variable. Include the unit [G\|M\|K] 185 | * thinpoolname: Can be ignored, a name is formed using the given vgname followed by '_thinpool' 186 | * vgname: Name of the volume group this thinpool should belong to. 187 | * thinpoolsize: The size of the thinpool 188 | * pvs: Optional, Default empty, the physical devices the LV should be placed on 189 | * opts: Optional, Default empty, additional parameters being passed to the lvm module, which uses those in lvcreate 190 | * meta_pvs: Optional, Default empty, the physical devices the metadata volume should be placed on 191 | * meta_opts: Optional, Default empty, additional parameters to pass to lvcreate for creating the metadata volume 192 | * raid: Optional Dict, see _raid_. example: {level: 5, stripe: 64, devices: 3 } 193 | 194 | 195 | ----------------------------------------- 196 | #### Variables for setting up cache 197 | 198 | | Name |Choices| Default value | Comments | 199 | |--------------------------|-------|-----------------------|-----------------------------------| 200 | | gluster_infra_cache_vars | | UNDEF | This is a dictionary with keys: vgname, cachedisk, cachetarget/cachethinpoolname, cachelvname, cachelvsize, cachemetalvname, cachemetalvsize, cachemode | 201 | 202 | ``` 203 | vgname - The vg which will be extended to setup cache. 204 | cachedisk - Comma seperated list of asbsolute-paths of block devices (e.g. SSD, NVMe; /dev/ssd) to use as caching medium. 205 | cachethinpoolname - (deprecated, see: cachetarget) The existing thinpool on the volume group mentioned above. 206 | cachetarget - The target thinpool or thick LV that should be cached 207 | cachelvname - Logical volume name for setting up cache, an lv with this name is created. 208 | cachelvsize - Cache logical volume size 209 | cachemetalvname - Meta LV name. 210 | cachemetalvsize - Meta LV size 211 | cachemode - Cachemode, default is writethrough. 212 | meta_pvs - Optional, Default empty, the physical devices the metadata volume should be placed on 213 | meta_opts - Optional, Default empty, additional parameters to pass to lvcreate for creating the metadata volume 214 | ``` 215 | 216 | For example: 217 | ``` 218 | - { vgname: 'vg_vdb', cachedisk: '/dev/vdd', cachethinpoolname: 'foo_thinpool', cachelvname: 'cachelv', cachelvsize: '20G', cachemetalvname: 'cachemeta', cachemetalvsize: '100M', cachemode: 'writethrough' } 219 | - { vgname: 'ans_vg', cachedisk: '/dev/sde1,/dev/sdf1', cachetarget: 'ans_thick', cachelvname: 'cache-ans_thinpool', cachelvsize: '10G', cachemetalvsize: '1G', meta_opts: '--type raid1', meta_pvs: '/dev/sde1,/dev/sdh1', cachemode: 'writethrough' } 220 | ``` 221 | 222 | 223 | ----------------------------------------- 224 | #### Variables for raid configurations 225 | 226 | this is a sub-structure for Thick/Thin, Pool LV's and XFS trying to achieve RAID alignment 227 | 228 | | Name |Choices| Default value | Comments | 229 | |--------------------------|-------|-----------------------|-----------------------------------| 230 | | level | 0,5,6,10 | UNDEF | The active raid level, when none defined the default or JBOD is assumed | 231 | | stripe || UNDEF | Stripe unit size (KiB). *DO NOT* including trailing 'k' or 'K' | 232 | | devices || UNDEF | The amount of devices the array consists of, this includes parity devices, thus for a RAID5 of 3 disks supply 3. The parity is calculated | 233 | 234 | ----------------------------------------- 235 | #### Variables for mounting the filesystem 236 | 237 | | Name |Choices| Default value | Comments | 238 | |--------------------------|-------|-----------------------|-----------------------------------| 239 | | gluster_infra_mount_devices | | UNDEF | This is a dictionary with mount values. path, vgname, and lvname are the keys. | 240 | 241 | ``` 242 | For example: 243 | gluster_infra_mount_devices: 244 | - { path: '/mnt/thinv', vgname: , lvname: } 245 | ``` 246 | 247 | ----------------------------------------- 248 | 249 | #### Variables for configuring LVM auto extend for thin pools 250 | ----------------------------------------- 251 | | Name |Choices| Default value | Comments | 252 | |--------------------------|-------|-----------------------|-----------------------------------| 253 | | gluster_infra_lvm | | UNDEF | This is a dictionary to configure the LVM auto extend. autoexpand_threshold and autoexpand_percentage are the keys. | 254 | 255 | ``` 256 | For example: 257 | gluster_infra_lvm: { 258 | autoexpand_threshold: 70, 259 | autoexpand_percentage: 15, 260 | } 261 | ``` 262 | 263 | * autoexpand_threshold: Optional default empty, the threshold in percentage when LVM should try to expand the thinpool (see lvm.conf) 264 | * autoexpand_percentage: Optional default empty, the percentage the thinpool should be expanded with (see lvm.conf) 265 | 266 | #### Variables for configuring fstimer service and timer 267 | ----------------------------------------- 268 | | Name |Choices| Default value | Comments | 269 | |--------------------------|-------|-----------------------|-----------------------------------| 270 | | fstrim_service | | UNDEF | This is a dictionary to configure the fstrim service. enabled and schedule are the keys. | 271 | 272 | ``` 273 | For example: 274 | fstrim_service: { 275 | enabled: yes, 276 | schedule: { 277 | hour: "{{ range(1, 4) | random() }}" 278 | } 279 | } 280 | ``` 281 | 282 | * enabled: Boolean default no. When yes the fstrim.timer unit will be enabled 283 | * schedule: Optional dictionary, to set the timer, by default doesn't override the schedule. can be usefull to not trigger the trim at the same time across the cluster. optionable subkeys; 284 | * dow: Optional String, specifying the Day of Week as required by the systemd calander. When empty a random day is chosen. 285 | * hour: Optional int, default a random hour, setting the hour the fstrim should run 286 | * minute: Optional int, default a random minute, setting the minute the fstrim should run 287 | * second: Optional int, default a random second, setting the second the fstrim should run 288 | 289 | Example Playbook 290 | ---------------- 291 | 292 | Configure the ports and services related to GlusterFS, create logical volumes and mount them. 293 | 294 | 295 | ``` 296 | --- 297 | - name: Setting up backend 298 | remote_user: root 299 | hosts: gluster_servers 300 | gather_facts: false 301 | 302 | vars: 303 | # Firewall setup 304 | gluster_infra_fw_ports: 305 | - 2049/tcp 306 | - 54321/tcp 307 | - 5900/tcp 308 | - 5900-6923/tcp 309 | - 5666/tcp 310 | - 16514/tcp 311 | gluster_infra_fw_services: 312 | - glusterfs 313 | 314 | # Set a disk type, Options: JBOD, RAID6, RAID10 315 | gluster_infra_disktype: RAID6 316 | 317 | # RAID6 and RAID10 diskcount (Needed only when disktype is raid) 318 | gluster_infra_diskcount: 10 319 | # Stripe unit size always in KiB 320 | gluster_infra_stripe_unit_size: 128 321 | 322 | # enable lvm auto-extend feature so that when the pool is at 70% it will be extended with 15% 323 | gluster_infra_lvm: { 324 | autoexpand_threshold: 70, 325 | autoexpand_percentage: 15, 326 | } 327 | 328 | # enable fstrim service so the TRIM command is executed once in a while to clean either ssd or thin/vdo volumes 329 | fstrim_service: { 330 | enabled: yes, 331 | schedule: { 332 | hour: "{{ range(1, 4) | random() }}" 333 | } 334 | } 335 | 336 | # Variables for creating volume group 337 | gluster_infra_volume_groups: 338 | - { vgname: 'vg_vdb', pvname: '/dev/vdb' } 339 | - { vgname: 'vg_vdc', pvname: '/dev/vdc' } 340 | 341 | # Create thinpools 342 | gluster_infra_thinpools: 343 | - {vgname: 'vg_vdb', thinpoolname: 'foo_thinpool', thinpoolsize: '100G', poolmetadatasize: '16G'} 344 | - {vgname: 'vg_vdc', thinpoolname: 'bar_thinpool', thinpoolsize: '500G', poolmetadatasize: '16G'} 345 | 346 | # Create a thin volume 347 | gluster_infra_lv_logicalvols: 348 | - { vgname: 'vg_vdb', thinpool: 'foo_thinpool', lvname: 'vg_vdb_thinlv', lvsize: '500G' } 349 | - { vgname: 'vg_vdc', thinpool: 'bar_thinpool', lvname: 'vg_vdc_thinlv', lvsize: '500G' } 350 | 351 | # Mount the devices 352 | gluster_infra_mount_devices: 353 | - { path: '/mnt/brick1', vgname: 'vg_vdb', lvname: 'vg_vdb_thinlv' } 354 | - { path: '/mnt/brick2', vgname: 'vg_vdc', lvname: 'vg_vdc_thinlv' } 355 | 356 | roles: 357 | - gluster.infra 358 | 359 | ``` 360 | 361 | See also: https://github.com/gluster/gluster-ansible-infra/tree/master/playbooks 362 | 363 | ------- 364 | License 365 | 366 | 367 | GPLv3 368 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS 622 | 623 | How to Apply These Terms to Your New Programs 624 | 625 | If you develop a new program, and you want it to be of the greatest 626 | possible use to the public, the best way to achieve this is to make it 627 | free software which everyone can redistribute and change under these terms. 628 | 629 | To do so, attach the following notices to the program. It is safest 630 | to attach them to the start of each source file to most effectively 631 | state the exclusion of warranty; and each file should have at least 632 | the "copyright" line and a pointer to where the full notice is found. 633 | 634 | 635 | Copyright (C) 636 | 637 | This program is free software: you can redistribute it and/or modify 638 | it under the terms of the GNU General Public License as published by 639 | the Free Software Foundation, either version 3 of the License, or 640 | (at your option) any later version. 641 | 642 | This program is distributed in the hope that it will be useful, 643 | but WITHOUT ANY WARRANTY; without even the implied warranty of 644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 645 | GNU General Public License for more details. 646 | 647 | You should have received a copy of the GNU General Public License 648 | along with this program. If not, see . 649 | 650 | Also add information on how to contact you by electronic and paper mail. 651 | 652 | If the program does terminal interaction, make it output a short 653 | notice like this when it starts in an interactive mode: 654 | 655 | Copyright (C) 656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 657 | This is free software, and you are welcome to redistribute it 658 | under certain conditions; type `show c' for details. 659 | 660 | The hypothetical commands `show w' and `show c' should show the appropriate 661 | parts of the General Public License. Of course, your program's commands 662 | might be different; for a GUI interface, you would use an "about box". 663 | 664 | You should also get your employer (if you work as a programmer) or school, 665 | if any, to sign a "copyright disclaimer" for the program, if necessary. 666 | For more information on this, and how to apply and follow the GNU GPL, see 667 | . 668 | 669 | The GNU General Public License does not permit incorporating your program 670 | into proprietary programs. If your program is a subroutine library, you 671 | may consider it more useful to permit linking proprietary applications with 672 | the library. If this is what you want to do, use the GNU Lesser General 673 | Public License instead of this License. But first, please read 674 | . 675 | --------------------------------------------------------------------------------