|
|
|
@ -38,27 +38,33 @@ options:
|
|
|
|
use started/stopped to control it's availability.
|
|
|
|
use started/stopped to control it's availability.
|
|
|
|
cluster:
|
|
|
|
cluster:
|
|
|
|
required: false
|
|
|
|
required: false
|
|
|
|
|
|
|
|
default: null
|
|
|
|
description:
|
|
|
|
description:
|
|
|
|
- List of hosts to use for probing and brick setup
|
|
|
|
- List of hosts to use for probing and brick setup
|
|
|
|
host:
|
|
|
|
host:
|
|
|
|
required: false
|
|
|
|
required: false
|
|
|
|
|
|
|
|
default: null
|
|
|
|
description:
|
|
|
|
description:
|
|
|
|
- Override local hostname (for peer probing purposes)
|
|
|
|
- Override local hostname (for peer probing purposes)
|
|
|
|
replicas:
|
|
|
|
replicas:
|
|
|
|
required: false
|
|
|
|
required: false
|
|
|
|
|
|
|
|
default: null
|
|
|
|
description:
|
|
|
|
description:
|
|
|
|
- Replica count for volume
|
|
|
|
- Replica count for volume
|
|
|
|
stripes:
|
|
|
|
stripes:
|
|
|
|
required: false
|
|
|
|
required: false
|
|
|
|
|
|
|
|
default: null
|
|
|
|
description:
|
|
|
|
description:
|
|
|
|
- Stripe count for volume
|
|
|
|
- Stripe count for volume
|
|
|
|
transport:
|
|
|
|
transport:
|
|
|
|
required: false
|
|
|
|
required: false
|
|
|
|
choices: [ 'tcp', 'rdma', 'tcp,rdma' ]
|
|
|
|
choices: [ 'tcp', 'rdma', 'tcp,rdma' ]
|
|
|
|
|
|
|
|
default: 'tcp'
|
|
|
|
description:
|
|
|
|
description:
|
|
|
|
- Transport type for volume
|
|
|
|
- Transport type for volume
|
|
|
|
brick:
|
|
|
|
brick:
|
|
|
|
required: false
|
|
|
|
required: false
|
|
|
|
|
|
|
|
default: null
|
|
|
|
description:
|
|
|
|
description:
|
|
|
|
- Brick path on servers
|
|
|
|
- Brick path on servers
|
|
|
|
start_on_create:
|
|
|
|
start_on_create:
|
|
|
|
@ -69,22 +75,27 @@ options:
|
|
|
|
rebalance:
|
|
|
|
rebalance:
|
|
|
|
choices: [ 'yes', 'no']
|
|
|
|
choices: [ 'yes', 'no']
|
|
|
|
required: false
|
|
|
|
required: false
|
|
|
|
|
|
|
|
default: 'no'
|
|
|
|
description:
|
|
|
|
description:
|
|
|
|
- Controls whether the cluster is rebalanced after changes
|
|
|
|
- Controls whether the cluster is rebalanced after changes
|
|
|
|
directory:
|
|
|
|
directory:
|
|
|
|
required: false
|
|
|
|
required: false
|
|
|
|
|
|
|
|
default: null
|
|
|
|
description:
|
|
|
|
description:
|
|
|
|
- Directory for limit-usage
|
|
|
|
- Directory for limit-usage
|
|
|
|
options:
|
|
|
|
options:
|
|
|
|
required: false
|
|
|
|
required: false
|
|
|
|
|
|
|
|
default: null
|
|
|
|
description:
|
|
|
|
description:
|
|
|
|
- A dictionary/hash with options/settings for the volume
|
|
|
|
- A dictionary/hash with options/settings for the volume
|
|
|
|
quota:
|
|
|
|
quota:
|
|
|
|
required: false
|
|
|
|
required: false
|
|
|
|
|
|
|
|
default: null
|
|
|
|
description:
|
|
|
|
description:
|
|
|
|
- Quota value for limit-usage (be sure to use 10.0MB instead of 10MB, see quota list)
|
|
|
|
- Quota value for limit-usage (be sure to use 10.0MB instead of 10MB, see quota list)
|
|
|
|
force:
|
|
|
|
force:
|
|
|
|
required: false
|
|
|
|
required: false
|
|
|
|
|
|
|
|
default: null
|
|
|
|
description:
|
|
|
|
description:
|
|
|
|
- If brick is being created in the root partition, module will fail.
|
|
|
|
- If brick is being created in the root partition, module will fail.
|
|
|
|
Set force to true to override this behaviour
|
|
|
|
Set force to true to override this behaviour
|
|
|
|
@ -119,15 +130,16 @@ import shutil
|
|
|
|
import time
|
|
|
|
import time
|
|
|
|
import socket
|
|
|
|
import socket
|
|
|
|
|
|
|
|
|
|
|
|
def main():
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def run_gluster(gargs, **kwargs):
|
|
|
|
def run_gluster(gargs, **kwargs):
|
|
|
|
args = [glusterbin]
|
|
|
|
args = [glusterbin]
|
|
|
|
args.extend(gargs)
|
|
|
|
args.extend(gargs)
|
|
|
|
|
|
|
|
try:
|
|
|
|
rc, out, err = module.run_command(args, **kwargs)
|
|
|
|
rc, out, err = module.run_command(args, **kwargs)
|
|
|
|
if rc != 0:
|
|
|
|
if rc != 0:
|
|
|
|
module.fail_json(msg='error running gluster (%s) command (rc=%d): %s' % (' '.join(args), rc, out if out != '' else err))
|
|
|
|
module.fail_json(msg='error running gluster (%s) command (rc=%d): %s' % (' '.join(args), rc, out if out != '' else err))
|
|
|
|
|
|
|
|
except Exception, e:
|
|
|
|
|
|
|
|
module.fail_json(msg='error running gluster (%s) command: %s' % (' '.join(args), str(e))
|
|
|
|
return out
|
|
|
|
return out
|
|
|
|
|
|
|
|
|
|
|
|
def run_gluster_nofail(gargs, **kwargs):
|
|
|
|
def run_gluster_nofail(gargs, **kwargs):
|
|
|
|
@ -268,7 +280,7 @@ def main():
|
|
|
|
args.append('force')
|
|
|
|
args.append('force')
|
|
|
|
run_gluster(args)
|
|
|
|
run_gluster(args)
|
|
|
|
|
|
|
|
|
|
|
|
def rebalance(name):
|
|
|
|
def do_rebalance(name):
|
|
|
|
run_gluster(['volume', 'rebalance', name, 'start'])
|
|
|
|
run_gluster(['volume', 'rebalance', name, 'start'])
|
|
|
|
|
|
|
|
|
|
|
|
def enable_quota(name):
|
|
|
|
def enable_quota(name):
|
|
|
|
@ -278,6 +290,7 @@ def main():
|
|
|
|
run_gluster([ 'volume', 'quota', name, 'limit-usage', directory, value ])
|
|
|
|
run_gluster([ 'volume', 'quota', name, 'limit-usage', directory, value ])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def main():
|
|
|
|
### MAIN ###
|
|
|
|
### MAIN ###
|
|
|
|
|
|
|
|
|
|
|
|
module = AnsibleModule(
|
|
|
|
module = AnsibleModule(
|
|
|
|
@ -403,7 +416,7 @@ def main():
|
|
|
|
if changed:
|
|
|
|
if changed:
|
|
|
|
volumes = get_volumes()
|
|
|
|
volumes = get_volumes()
|
|
|
|
if rebalance:
|
|
|
|
if rebalance:
|
|
|
|
rebalance(volume_name)
|
|
|
|
do_rebalance(volume_name)
|
|
|
|
|
|
|
|
|
|
|
|
facts = {}
|
|
|
|
facts = {}
|
|
|
|
facts['glusterfs'] = { 'peers': peers, 'volumes': volumes, 'quotas': quotas }
|
|
|
|
facts['glusterfs'] = { 'peers': peers, 'volumes': volumes, 'quotas': quotas }
|
|
|
|
|