mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
parent
81caa837a4
commit
0c9c0c59f2
1 changed files with 42 additions and 78 deletions
|
@ -18,105 +18,79 @@ module: gluster_volume
|
||||||
short_description: Manage GlusterFS volumes
|
short_description: Manage GlusterFS volumes
|
||||||
description:
|
description:
|
||||||
- Create, remove, start, stop and tune GlusterFS volumes
|
- Create, remove, start, stop and tune GlusterFS volumes
|
||||||
version_added: "1.9"
|
version_added: '1.9'
|
||||||
options:
|
options:
|
||||||
name:
|
name:
|
||||||
required: true
|
|
||||||
description:
|
description:
|
||||||
- The volume name
|
- The volume name
|
||||||
|
required: true
|
||||||
state:
|
state:
|
||||||
|
description:
|
||||||
|
- Use present/absent ensure if a volume exists or not.
|
||||||
|
Use started/stopped to control its availability.
|
||||||
required: true
|
required: true
|
||||||
choices: ['present', 'absent', 'started', 'stopped']
|
choices: ['present', 'absent', 'started', 'stopped']
|
||||||
description:
|
|
||||||
- Use present/absent ensure if a volume exists or not,
|
|
||||||
use started/stopped to control it's availability.
|
|
||||||
cluster:
|
cluster:
|
||||||
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
|
|
||||||
default: null
|
|
||||||
description:
|
description:
|
||||||
- Override local hostname (for peer probing purposes)
|
- Override local hostname (for peer probing purposes)
|
||||||
replicas:
|
replicas:
|
||||||
required: false
|
|
||||||
default: null
|
|
||||||
description:
|
description:
|
||||||
- Replica count for volume
|
- Replica count for volume
|
||||||
arbiter:
|
arbiter:
|
||||||
required: false
|
|
||||||
default: null
|
|
||||||
description:
|
description:
|
||||||
- Arbiter count for volume
|
- Arbiter count for volume
|
||||||
version_added: "2.3"
|
version_added: '2.3'
|
||||||
stripes:
|
stripes:
|
||||||
required: false
|
|
||||||
default: null
|
|
||||||
description:
|
description:
|
||||||
- Stripe count for volume
|
- Stripe count for volume
|
||||||
disperses:
|
disperses:
|
||||||
required: false
|
|
||||||
default: null
|
|
||||||
description:
|
description:
|
||||||
- Disperse count for volume
|
- Disperse count for volume
|
||||||
version_added: "2.2"
|
version_added: '2.2'
|
||||||
redundancies:
|
redundancies:
|
||||||
required: false
|
|
||||||
default: null
|
|
||||||
description:
|
description:
|
||||||
- Redundancy count for volume
|
- Redundancy count for volume
|
||||||
version_added: "2.2"
|
version_added: '2.2'
|
||||||
transport:
|
transport:
|
||||||
required: false
|
|
||||||
choices: [ 'tcp', 'rdma', 'tcp,rdma' ]
|
|
||||||
default: 'tcp'
|
|
||||||
description:
|
description:
|
||||||
- Transport type for volume
|
- Transport type for volume
|
||||||
|
default: 'tcp'
|
||||||
|
choices: ['tcp', 'rdma', 'tcp,rdma']
|
||||||
bricks:
|
bricks:
|
||||||
required: false
|
|
||||||
default: null
|
|
||||||
description:
|
description:
|
||||||
- Brick paths on servers. Multiple brick paths can be separated by commas
|
- Brick paths on servers. Multiple brick paths can be separated by commas.
|
||||||
aliases: ['brick']
|
aliases: ['brick']
|
||||||
start_on_create:
|
start_on_create:
|
||||||
choices: [ 'yes', 'no']
|
|
||||||
required: false
|
|
||||||
default: 'yes'
|
|
||||||
description:
|
description:
|
||||||
- Controls whether the volume is started after creation or not, defaults to yes
|
- Controls whether the volume is started after creation or not
|
||||||
|
default: 'yes'
|
||||||
|
type: bool
|
||||||
rebalance:
|
rebalance:
|
||||||
choices: [ 'yes', 'no']
|
|
||||||
required: false
|
|
||||||
default: 'no'
|
|
||||||
description:
|
description:
|
||||||
- Controls whether the cluster is rebalanced after changes
|
- Controls whether the cluster is rebalanced after changes
|
||||||
|
default: 'no'
|
||||||
|
type: bool
|
||||||
directory:
|
directory:
|
||||||
required: false
|
|
||||||
default: null
|
|
||||||
description:
|
description:
|
||||||
- Directory for limit-usage
|
- Directory for limit-usage
|
||||||
options:
|
options:
|
||||||
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
|
|
||||||
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
|
|
||||||
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.
|
||||||
|
type: bool
|
||||||
notes:
|
notes:
|
||||||
- "Requires cli tools for GlusterFS on servers"
|
- Requires cli tools for GlusterFS on servers
|
||||||
- "Will add new bricks, but not remove them"
|
- Will add new bricks, but not remove them
|
||||||
author: "Taneli Leppä (@rosmo)"
|
author: Taneli Leppä (@rosmo)
|
||||||
"""
|
"""
|
||||||
|
|
||||||
EXAMPLES = """
|
EXAMPLES = """
|
||||||
|
@ -186,7 +160,7 @@ glusterbin = ''
|
||||||
def run_gluster(gargs, **kwargs):
|
def run_gluster(gargs, **kwargs):
|
||||||
global glusterbin
|
global glusterbin
|
||||||
global module
|
global module
|
||||||
args = [glusterbin]
|
args = [glusterbin, '--mode=script']
|
||||||
args.extend(gargs)
|
args.extend(gargs)
|
||||||
try:
|
try:
|
||||||
rc, out, err = module.run_command(args, **kwargs)
|
rc, out, err = module.run_command(args, **kwargs)
|
||||||
|
@ -208,16 +182,6 @@ def run_gluster_nofail(gargs, **kwargs):
|
||||||
return None
|
return None
|
||||||
return out
|
return out
|
||||||
|
|
||||||
def run_gluster_yes(gargs):
|
|
||||||
global glusterbin
|
|
||||||
global module
|
|
||||||
args = [glusterbin]
|
|
||||||
args.extend(gargs)
|
|
||||||
rc, out, err = module.run_command(args, data='y\n')
|
|
||||||
if rc != 0:
|
|
||||||
module.fail_json(msg='error running gluster (%s) command (rc=%d): %s' % (' '.join(args), rc, out or err))
|
|
||||||
return out
|
|
||||||
|
|
||||||
def get_peers():
|
def get_peers():
|
||||||
out = run_gluster([ 'peer', 'status'])
|
out = run_gluster([ 'peer', 'status'])
|
||||||
peers = {}
|
peers = {}
|
||||||
|
@ -350,7 +314,7 @@ def start_volume(name):
|
||||||
run_gluster([ 'volume', 'start', name ])
|
run_gluster([ 'volume', 'start', name ])
|
||||||
|
|
||||||
def stop_volume(name):
|
def stop_volume(name):
|
||||||
run_gluster_yes([ 'volume', 'stop', name ])
|
run_gluster([ 'volume', 'stop', name ])
|
||||||
|
|
||||||
def set_volume_option(name, option, parameter):
|
def set_volume_option(name, option, parameter):
|
||||||
run_gluster([ 'volume', 'set', name, option, parameter ])
|
run_gluster([ 'volume', 'set', name, option, parameter ])
|
||||||
|
@ -384,23 +348,23 @@ def main():
|
||||||
global module
|
global module
|
||||||
module = AnsibleModule(
|
module = AnsibleModule(
|
||||||
argument_spec=dict(
|
argument_spec=dict(
|
||||||
name=dict(required=True, default=None, aliases=['volume']),
|
name=dict(required=True, aliases=['volume']),
|
||||||
state=dict(required=True, choices=[ 'present', 'absent', 'started', 'stopped', 'rebalanced' ]),
|
state=dict(required=True, choices=['present', 'absent', 'started', 'stopped']),
|
||||||
cluster=dict(required=False, default=None, type='list'),
|
cluster=dict(default=None, type='list'),
|
||||||
host=dict(required=False, default=None),
|
host=dict(default=None),
|
||||||
stripes=dict(required=False, default=None, type='int'),
|
stripes=dict(default=None, type='int'),
|
||||||
replicas=dict(required=False, default=None, type='int'),
|
replicas=dict(default=None, type='int'),
|
||||||
arbiters=dict(required=False, default=None, type='int'),
|
arbiters=dict(default=None, type='int'),
|
||||||
disperses=dict(required=False, default=None, type='int'),
|
disperses=dict(default=None, type='int'),
|
||||||
redundancies=dict(required=False, default=None, type='int'),
|
redundancies=dict(default=None, type='int'),
|
||||||
transport=dict(required=False, default='tcp', choices=[ 'tcp', 'rdma', 'tcp,rdma' ]),
|
transport=dict(default='tcp', choices=['tcp', 'rdma', 'tcp,rdma']),
|
||||||
bricks=dict(required=False, default=None, aliases=['brick']),
|
bricks=dict(default=None, aliases=['brick']),
|
||||||
start_on_create=dict(required=False, default=True, type='bool'),
|
start_on_create=dict(default=True, type='bool'),
|
||||||
rebalance=dict(required=False, default=False, type='bool'),
|
rebalance=dict(default=False, type='bool'),
|
||||||
options=dict(required=False, default={}, type='dict'),
|
options=dict(default={}, type='dict'),
|
||||||
quota=dict(required=False),
|
quota=dict(),
|
||||||
directory=dict(required=False, default=None),
|
directory=dict(default=None),
|
||||||
force=dict(required=False, default=False, type='bool'),
|
force=dict(default=False, type='bool'),
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -457,7 +421,7 @@ def main():
|
||||||
if volume_name in volumes:
|
if volume_name in volumes:
|
||||||
if volumes[volume_name]['status'].lower() != 'stopped':
|
if volumes[volume_name]['status'].lower() != 'stopped':
|
||||||
stop_volume(volume_name)
|
stop_volume(volume_name)
|
||||||
run_gluster_yes([ 'volume', 'delete', volume_name ])
|
run_gluster([ 'volume', 'delete', volume_name ])
|
||||||
changed = True
|
changed = True
|
||||||
|
|
||||||
if action == 'present':
|
if action == 'present':
|
||||||
|
|
Loading…
Reference in a new issue