Created
May 2, 2019 00:15
-
-
Save nikhiljha/4eec002b1f098c27fb6c65652b4f31d3 to your computer and use it in GitHub Desktop.
GlusterFS Ansible Setup
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
- hosts: gluster | |
become: true | |
vars: | |
gluster_mount_dir: /mnt/g1 | |
gluster_brick_dir: /bricks/brick1 | |
gluster_brick_name: g1 | |
tasks: | |
- name: Install parted | |
package: | |
name: parted | |
state: present | |
tags: | |
- setup | |
- name: Create Primary partition | |
parted: | |
device: /dev/mmcblk1 | |
number: 1 | |
state: present | |
tags: | |
- setup | |
- name: Create a ext4 filesystem on /dev/mmcblk1 | |
filesystem: | |
fstype: ext4 | |
dev: /dev/mmcblk1 | |
tags: | |
- setup | |
- name: Ensure Gluster brick and mount directories exist. | |
file: | |
path: "{{ item }}" | |
state: directory | |
mode: 0775 | |
with_items: | |
- "{{ gluster_brick_dir }}" | |
- "{{ gluster_mount_dir }}" | |
- name: Mount "{{ gluster_brick_dir }}" | |
mount: | |
path: "{{ gluster_brick_dir }}" | |
src: /dev/mmcblk1 | |
fstype: ext4 | |
state: present | |
tags: | |
- setup | |
- name: Configure Gluster volume. | |
gluster_volume: | |
state: present | |
name: "{{ gluster_brick_name }}" | |
brick: "{{ gluster_brick_dir }}" | |
replicas: "{{ groups.gluster | length }}" | |
cluster: "{{ groups.gluster | join(',') }}" | |
host: "{{ inventory_hostname }}" | |
force: yes | |
run_once: true | |
- name: Ensure Gluster volume is mounted. | |
mount: | |
name: "{{ gluster_mount_dir }}" | |
src: "{{ inventory_hostname }}:/{{ gluster_brick_name }}" | |
fstype: glusterfs | |
opts: "defaults,_netdev,log-level=WARNING,log-file=/var/log/gluster.log" | |
state: mounted |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment