shortdudey123 / chef-gluster

Chef cookbook for deploying Gluster
https://supermarket.chef.io/cookbooks/gluster
Apache License 2.0
24 stars 47 forks source link

gluster Cookbook

Build Status Cookbook Version

This cookbook is used to install and configure Gluster on both servers and clients. This cookbook makes several assumptions when configuring Gluster servers:

  1. This cookbook is being run on at least two nodes, the exact number depends on the Gluster Volume type
  2. A second physical disk has been added, unformatted, to the server. This cookbook will install lvm and configure the disks automatically.
  3. All peers for a volume will be configured with the same number of bricks

Platforms

This cookbook has been tested on:

As this cookbook uses Semantic Versioning, major version number bumps are not backwards compatible. Especially the change from v4 to v5 will require a rebuild of the gluster nodes.

Attributes

gluster::default

gluster::client

Node attributes to specify volumes to mount. This has been deprecated in favor of using the 'gluster_mount' LWRP.

gluster::server

Node attributes to specify server volumes to create

The absolute minimum configuration is:

gluster::geo_replication

Node attributes to specify mountbroker details.

Other attributes include:

Custom Resources

gluster_volume

Use this resource to start, stop, or delete volumes:

gluster_volume 'volume_name' do
  action :start
end
gluster_volume 'volume_name' do
  action :stop
end
gluster_volume 'volume_name' do
  action :delete
end

It is also useful for checking existence in only_if blocks:

volume = gluster_volume 'volume_name' do
  action :nothing
end

some_resource 'foo' do
  only_if { volume.current_value }
end
gluster_volume 'volume_name' do
  action :start
  only_if { current_value }
end

Parameters

gluster_mount

Use this resource to mount volumes on clients:

gluster_mount 'volume_name' do
  server 'gluster1.example.com'
  backup_server 'gluster2.example.com'
  mount_point '/mnt/gluster/volume_name'
  action [:mount, :enable]
end
gluster_mount 'volume_name' do
  server 'gluster1.example.com'
  backup_server ['gluster2.example.com', 'gluster3.example.com']
  mount_point '/mnt/gluster/volume_name'
  action [:mount, :enable]
end

Parameters

gluster_volume_option

Use this resource to set or reset volume options:

gluster_volume_option 'volume_name/changelog.rollover-time' do
  value 5
  action :set
end
gluster_volume_option 'volume_name/changelog.rollover-time' do
  action :reset
end

Parameters

gluster_mountbroker_user

Use this resource to allow or disallow the given user access to the given volume:

gluster_mountbroker_user 'user/volume_name' do
  action :add
end
gluster_mountbroker_user 'user/volume_name' do
  action :remove
end

Parameters

Usage

On two or more identical systems, attach the desired number of dedicated disks to use for Gluster storage. Add the gluster::server recipe to the node's run list and add any appropriate attributes, such as volumes to the ['gluster']['server']['volumes'] attribute. If the cookbook will be used to manage disks, add the disks to the ['gluster']['server']['disks'] attribute; otherwise format the disks appropriately and add them to the ['gluster']['server']['volumes'][VOLUME_NAME]['disks'] attribute. Once all peers for a volume have configured their bricks, the 'master' peer (the first in the array) will create and start the volume.

For example, to create a replicated gluster volume named gv0 with 2 bricks on two nodes, add the following to your attributes/default.rb and include the gluster::server recipe:

default['gluster']['server']['brick_mount_path'] = "/data"
default['gluster']['server']['volumes'] = {
                'gv0' => {
                        'peers' => ['gluster1.example.com','gluster2.example.com'],
                        'replica_count' => 2,
                        'volume_type' => "replicated"
                }
}

To create a distributed-replicated volume with 4 bricks and a replica count of two:

default['gluster']['server']['brick_mount_path'] = "/data"
default['gluster']['server']['volumes'] = {
                'gv0' => {
                        'peers' => ['gluster1.example.com','gluster2.example.com','gluster3.example.com','gluster4.example.com'],
                        'replica_count' => 2,
                        'volume_type' => "distributed-replicated"
                }
}

To create a replicated volume with 4 bricks:

default['gluster']['server']['brick_mount_path'] = "/data"
default['gluster']['server']['volumes'] = {
                'gv0' => {
                        'peers' => ['gluster1.example.com','gluster2.example.com','gluster3.example.com','gluster4.example.com'],
                        'replica_count' => 4,
                        'volume_type' => "replicated"
                }
}

For clients, add the gluster::default or gluster::client recipe to the node's run list, and mount volumes using the gluster_mount LWRP. The Gluster volume will be mounted on the next chef-client run (provided the volume exists and is available) and added to /etc/fstab.

This cookbook cannot currently perform all the steps required for geo-replication but it can configure the mountbroker. The gluster::mountbroker recipe calls upon the gluster::geo_replication_install recipe to install the necessary package before configuring the mountbroker according to the ['gluster']['mountbroker'] attributes. User access can be defined via the attributes or you can use the gluster_mountbroker_user custom resource directly. Both the recipe and resource require Gluster 3.9 or later.

Testing

There is a kitchen file provided to allow testing of the various versions. Examples of tests are:

(Depending on your shell, you may or may not need the \ in the RegEx)

To test a replicated volume on Ubuntu 16.04: kitchen converge replicated[12]-ubuntu-1604 kitchen verify replicated2-ubuntu-1604

To test a distributed-replicated volume on CentOS 7.2: kitchen converge distributed-repl[1234]-centos-72 kitchen verify distributed-repl4-centos-72

To test a striped volume on CentOS 6.8: kitchen converge striped[12]-centos-68 kitchen verify striped2-centos-68

To test a fuse client on Ubuntu 14.04: kitchen converge client[12]-ubuntu-1404 kitchen verify client2-ubuntu-1404

Please note that at present the kitchen setup only supports Virtualbox