mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-27 23:21:22 -07:00
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.
|
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 }
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue