|
|
@ -83,6 +83,11 @@ options:
|
|
|
|
required: false
|
|
|
|
required: false
|
|
|
|
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:
|
|
|
|
|
|
|
|
required: false
|
|
|
|
|
|
|
|
description:
|
|
|
|
|
|
|
|
- If brick is being created in the root partition, module will fail.
|
|
|
|
|
|
|
|
Set force to true to override this behaviour
|
|
|
|
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"
|
|
|
@ -91,7 +96,7 @@ author: Taneli Leppä
|
|
|
|
|
|
|
|
|
|
|
|
EXAMPLES = """
|
|
|
|
EXAMPLES = """
|
|
|
|
- name: create gluster volume
|
|
|
|
- name: create gluster volume
|
|
|
|
gluster_volume: state=present name=test1 brick=/bricks/brick1/g1 rebalance=yes hosts:"{{ play_hosts }}"
|
|
|
|
gluster_volume: state=present name=test1 brick=/bricks/brick1/g1 rebalance=yes cluster:"{{ play_hosts }}"
|
|
|
|
run_once: true
|
|
|
|
run_once: true
|
|
|
|
|
|
|
|
|
|
|
|
- name: tune
|
|
|
|
- name: tune
|
|
|
@ -231,7 +236,7 @@ def main():
|
|
|
|
if myhostname != host:
|
|
|
|
if myhostname != host:
|
|
|
|
probe(host)
|
|
|
|
probe(host)
|
|
|
|
|
|
|
|
|
|
|
|
def create_volume(name, stripe, replica, transport, hosts, brick):
|
|
|
|
def create_volume(name, stripe, replica, transport, hosts, brick, force):
|
|
|
|
args = [ 'volume', 'create' ]
|
|
|
|
args = [ 'volume', 'create' ]
|
|
|
|
args.append(name)
|
|
|
|
args.append(name)
|
|
|
|
if stripe:
|
|
|
|
if stripe:
|
|
|
@ -244,6 +249,8 @@ def main():
|
|
|
|
args.append(transport)
|
|
|
|
args.append(transport)
|
|
|
|
for host in hosts:
|
|
|
|
for host in hosts:
|
|
|
|
args.append(('%s:%s' % (host, brick)))
|
|
|
|
args.append(('%s:%s' % (host, brick)))
|
|
|
|
|
|
|
|
if force:
|
|
|
|
|
|
|
|
args.append('force')
|
|
|
|
run_gluster(args)
|
|
|
|
run_gluster(args)
|
|
|
|
|
|
|
|
|
|
|
|
def start_volume(name):
|
|
|
|
def start_volume(name):
|
|
|
@ -255,8 +262,11 @@ def main():
|
|
|
|
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 ])
|
|
|
|
|
|
|
|
|
|
|
|
def add_brick(name, brick):
|
|
|
|
def add_brick(name, brick, force):
|
|
|
|
run_gluster([ 'volume', 'add-brick', name, brick ])
|
|
|
|
args = [ 'volume', 'add-brick', name, brick ]
|
|
|
|
|
|
|
|
if force:
|
|
|
|
|
|
|
|
args.append('force')
|
|
|
|
|
|
|
|
run_gluster(args)
|
|
|
|
|
|
|
|
|
|
|
|
def rebalance(name):
|
|
|
|
def rebalance(name):
|
|
|
|
run_gluster(['volume', 'rebalance', name, 'start'])
|
|
|
|
run_gluster(['volume', 'rebalance', name, 'start'])
|
|
|
@ -281,10 +291,11 @@ def main():
|
|
|
|
transport=dict(required=False, default='tcp', choices=[ 'tcp', 'rdma', 'tcp,rdma' ]),
|
|
|
|
transport=dict(required=False, default='tcp', choices=[ 'tcp', 'rdma', 'tcp,rdma' ]),
|
|
|
|
brick=dict(required=False, default=None),
|
|
|
|
brick=dict(required=False, default=None),
|
|
|
|
start_on_create=dict(required=False, default=True, type='bool'),
|
|
|
|
start_on_create=dict(required=False, default=True, type='bool'),
|
|
|
|
rebalance=dict(required=False, default=False, taype='bool'),
|
|
|
|
rebalance=dict(required=False, default=False, type='bool'),
|
|
|
|
options=dict(required=False, default=None, type='dict'),
|
|
|
|
options=dict(required=False, default={}, type='dict'),
|
|
|
|
quota=dict(required=False),
|
|
|
|
quota=dict(required=False),
|
|
|
|
directory=dict(required=False, default=None),
|
|
|
|
directory=dict(required=False, default=None),
|
|
|
|
|
|
|
|
force=dict(required=False, default=False, type='bool'),
|
|
|
|
)
|
|
|
|
)
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
@ -300,8 +311,9 @@ def main():
|
|
|
|
replicas = module.params['replicas']
|
|
|
|
replicas = module.params['replicas']
|
|
|
|
transport = module.params['transport']
|
|
|
|
transport = module.params['transport']
|
|
|
|
myhostname = module.params['host']
|
|
|
|
myhostname = module.params['host']
|
|
|
|
start_volume = module.boolean(module.params['start_on_create'])
|
|
|
|
start_on_create = module.boolean(module.params['start_on_create'])
|
|
|
|
rebalance = module.boolean(module.params['rebalance'])
|
|
|
|
rebalance = module.boolean(module.params['rebalance'])
|
|
|
|
|
|
|
|
force = module.boolean(module.params['force'])
|
|
|
|
|
|
|
|
|
|
|
|
if not myhostname:
|
|
|
|
if not myhostname:
|
|
|
|
myhostname = socket.gethostname()
|
|
|
|
myhostname = socket.gethostname()
|
|
|
@ -329,11 +341,12 @@ def main():
|
|
|
|
|
|
|
|
|
|
|
|
# create if it doesn't exist
|
|
|
|
# create if it doesn't exist
|
|
|
|
if volume_name not in volumes:
|
|
|
|
if volume_name not in volumes:
|
|
|
|
create_volume(volume_name, stripes, replicas, transport, cluster, brick_path)
|
|
|
|
create_volume(volume_name, stripes, replicas, transport, cluster, brick_path, force)
|
|
|
|
|
|
|
|
volumes = get_volumes()
|
|
|
|
changed = True
|
|
|
|
changed = True
|
|
|
|
|
|
|
|
|
|
|
|
if volume_name in volumes:
|
|
|
|
if volume_name in volumes:
|
|
|
|
if volumes[volume_name]['status'].lower() != 'started' and start_volume:
|
|
|
|
if volumes[volume_name]['status'].lower() != 'started' and start_on_create:
|
|
|
|
start_volume(volume_name)
|
|
|
|
start_volume(volume_name)
|
|
|
|
changed = True
|
|
|
|
changed = True
|
|
|
|
|
|
|
|
|
|
|
@ -353,7 +366,7 @@ def main():
|
|
|
|
removed_bricks.append(brick)
|
|
|
|
removed_bricks.append(brick)
|
|
|
|
|
|
|
|
|
|
|
|
for brick in new_bricks:
|
|
|
|
for brick in new_bricks:
|
|
|
|
add_brick(volume_name, brick)
|
|
|
|
add_brick(volume_name, brick, force)
|
|
|
|
changed = True
|
|
|
|
changed = True
|
|
|
|
|
|
|
|
|
|
|
|
# handle quotas
|
|
|
|
# handle quotas
|
|
|
|