minor fixes to gluster: - removed functions from main scope - renamed rebalance function to disambiguate from variable - updated docs with defaults - added exception handling to command execution
This commit is contained in:
parent
2ff3a8d35f
commit
bb418095a3
1 changed files with 149 additions and 136 deletions
|
@ -38,27 +38,33 @@ options:
|
|||
use started/stopped to control it's availability.
|
||||
cluster:
|
||||
required: false
|
||||
default: null
|
||||
description:
|
||||
- List of hosts to use for probing and brick setup
|
||||
host:
|
||||
required: false
|
||||
default: null
|
||||
description:
|
||||
- Override local hostname (for peer probing purposes)
|
||||
replicas:
|
||||
required: false
|
||||
default: null
|
||||
description:
|
||||
- Replica count for volume
|
||||
stripes:
|
||||
required: false
|
||||
default: null
|
||||
description:
|
||||
- Stripe count for volume
|
||||
transport:
|
||||
required: false
|
||||
choices: [ 'tcp', 'rdma', 'tcp,rdma' ]
|
||||
default: 'tcp'
|
||||
description:
|
||||
- Transport type for volume
|
||||
brick:
|
||||
required: false
|
||||
default: null
|
||||
description:
|
||||
- Brick path on servers
|
||||
start_on_create:
|
||||
|
@ -69,22 +75,27 @@ options:
|
|||
rebalance:
|
||||
choices: [ 'yes', 'no']
|
||||
required: false
|
||||
default: 'no'
|
||||
description:
|
||||
- Controls whether the cluster is rebalanced after changes
|
||||
directory:
|
||||
required: false
|
||||
default: null
|
||||
description:
|
||||
- Directory for limit-usage
|
||||
options:
|
||||
required: false
|
||||
default: null
|
||||
description:
|
||||
- A dictionary/hash with options/settings for the volume
|
||||
quota:
|
||||
required: false
|
||||
default: null
|
||||
description:
|
||||
- Quota value for limit-usage (be sure to use 10.0MB instead of 10MB, see quota list)
|
||||
force:
|
||||
required: false
|
||||
default: null
|
||||
description:
|
||||
- If brick is being created in the root partition, module will fail.
|
||||
Set force to true to override this behaviour
|
||||
|
@ -119,15 +130,16 @@ import shutil
|
|||
import time
|
||||
import socket
|
||||
|
||||
def main():
|
||||
|
||||
|
||||
def run_gluster(gargs, **kwargs):
|
||||
args = [glusterbin]
|
||||
args.extend(gargs)
|
||||
try:
|
||||
rc, out, err = module.run_command(args, **kwargs)
|
||||
if rc != 0:
|
||||
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
|
||||
|
||||
def run_gluster_nofail(gargs, **kwargs):
|
||||
|
@ -268,7 +280,7 @@ def main():
|
|||
args.append('force')
|
||||
run_gluster(args)
|
||||
|
||||
def rebalance(name):
|
||||
def do_rebalance(name):
|
||||
run_gluster(['volume', 'rebalance', name, 'start'])
|
||||
|
||||
def enable_quota(name):
|
||||
|
@ -278,6 +290,7 @@ def main():
|
|||
run_gluster([ 'volume', 'quota', name, 'limit-usage', directory, value ])
|
||||
|
||||
|
||||
def main():
|
||||
### MAIN ###
|
||||
|
||||
module = AnsibleModule(
|
||||
|
@ -403,7 +416,7 @@ def main():
|
|||
if changed:
|
||||
volumes = get_volumes()
|
||||
if rebalance:
|
||||
rebalance(volume_name)
|
||||
do_rebalance(volume_name)
|
||||
|
||||
facts = {}
|
||||
facts['glusterfs'] = { 'peers': peers, 'volumes': volumes, 'quotas': quotas }
|
||||
|
|
Loading…
Reference in a new issue