mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Support newer 'riak admin' sub-command beside legacy 'riak-admin' command (#8211)
* Support newer 'riak admin' sub-command * Added changelog for riak admin sub-command * Added blank line * Apply suggestions from code review Co-authored-by: Felix Fontein <felix@fontein.de> * replaced string commands with lists added white space removed white space removed parenthesis * Update changelogs/fragments/8211-riak-admin-sub-command-support.yml Co-authored-by: Don Naro <dnaro@redhat.com> --------- Co-authored-by: Felix Fontein <felix@fontein.de> Co-authored-by: Don Naro <dnaro@redhat.com>
This commit is contained in:
parent
6c8f949ba9
commit
bafad8ecd4
2 changed files with 10 additions and 7 deletions
|
@ -0,0 +1,2 @@
|
||||||
|
bugfixes:
|
||||||
|
- "riak - support ``riak admin`` sub-command in newer Riak KV versions beside the legacy ``riak-admin`` main command (https://github.com/ansible-collections/community.general/pull/8211)."
|
|
@ -93,7 +93,7 @@ from ansible.module_utils.urls import fetch_url
|
||||||
|
|
||||||
|
|
||||||
def ring_check(module, riak_admin_bin):
|
def ring_check(module, riak_admin_bin):
|
||||||
cmd = '%s ringready' % riak_admin_bin
|
cmd = riak_admin_bin + ['ringready']
|
||||||
rc, out, err = module.run_command(cmd)
|
rc, out, err = module.run_command(cmd)
|
||||||
if rc == 0 and 'TRUE All nodes agree on the ring' in out:
|
if rc == 0 and 'TRUE All nodes agree on the ring' in out:
|
||||||
return True
|
return True
|
||||||
|
@ -127,6 +127,7 @@ def main():
|
||||||
# make sure riak commands are on the path
|
# make sure riak commands are on the path
|
||||||
riak_bin = module.get_bin_path('riak')
|
riak_bin = module.get_bin_path('riak')
|
||||||
riak_admin_bin = module.get_bin_path('riak-admin')
|
riak_admin_bin = module.get_bin_path('riak-admin')
|
||||||
|
riak_admin_bin = [riak_admin_bin] if riak_admin_bin is not None else [riak_bin, 'admin']
|
||||||
|
|
||||||
timeout = time.time() + 120
|
timeout = time.time() + 120
|
||||||
while True:
|
while True:
|
||||||
|
@ -164,7 +165,7 @@ def main():
|
||||||
module.fail_json(msg=out)
|
module.fail_json(msg=out)
|
||||||
|
|
||||||
elif command == 'kv_test':
|
elif command == 'kv_test':
|
||||||
cmd = '%s test' % riak_admin_bin
|
cmd = riak_admin_bin + ['test']
|
||||||
rc, out, err = module.run_command(cmd)
|
rc, out, err = module.run_command(cmd)
|
||||||
if rc == 0:
|
if rc == 0:
|
||||||
result['kv_test'] = out
|
result['kv_test'] = out
|
||||||
|
@ -175,7 +176,7 @@ def main():
|
||||||
if nodes.count(node_name) == 1 and len(nodes) > 1:
|
if nodes.count(node_name) == 1 and len(nodes) > 1:
|
||||||
result['join'] = 'Node is already in cluster or staged to be in cluster.'
|
result['join'] = 'Node is already in cluster or staged to be in cluster.'
|
||||||
else:
|
else:
|
||||||
cmd = '%s cluster join %s' % (riak_admin_bin, target_node)
|
cmd = riak_admin_bin + ['cluster', 'join', target_node]
|
||||||
rc, out, err = module.run_command(cmd)
|
rc, out, err = module.run_command(cmd)
|
||||||
if rc == 0:
|
if rc == 0:
|
||||||
result['join'] = out
|
result['join'] = out
|
||||||
|
@ -184,7 +185,7 @@ def main():
|
||||||
module.fail_json(msg=out)
|
module.fail_json(msg=out)
|
||||||
|
|
||||||
elif command == 'plan':
|
elif command == 'plan':
|
||||||
cmd = '%s cluster plan' % riak_admin_bin
|
cmd = riak_admin_bin + ['cluster', 'plan']
|
||||||
rc, out, err = module.run_command(cmd)
|
rc, out, err = module.run_command(cmd)
|
||||||
if rc == 0:
|
if rc == 0:
|
||||||
result['plan'] = out
|
result['plan'] = out
|
||||||
|
@ -194,7 +195,7 @@ def main():
|
||||||
module.fail_json(msg=out)
|
module.fail_json(msg=out)
|
||||||
|
|
||||||
elif command == 'commit':
|
elif command == 'commit':
|
||||||
cmd = '%s cluster commit' % riak_admin_bin
|
cmd = riak_admin_bin + ['cluster', 'commit']
|
||||||
rc, out, err = module.run_command(cmd)
|
rc, out, err = module.run_command(cmd)
|
||||||
if rc == 0:
|
if rc == 0:
|
||||||
result['commit'] = out
|
result['commit'] = out
|
||||||
|
@ -206,7 +207,7 @@ def main():
|
||||||
if wait_for_handoffs:
|
if wait_for_handoffs:
|
||||||
timeout = time.time() + wait_for_handoffs
|
timeout = time.time() + wait_for_handoffs
|
||||||
while True:
|
while True:
|
||||||
cmd = '%s transfers' % riak_admin_bin
|
cmd = riak_admin_bin + ['transfers']
|
||||||
rc, out, err = module.run_command(cmd)
|
rc, out, err = module.run_command(cmd)
|
||||||
if 'No transfers active' in out:
|
if 'No transfers active' in out:
|
||||||
result['handoffs'] = 'No transfers active.'
|
result['handoffs'] = 'No transfers active.'
|
||||||
|
@ -216,7 +217,7 @@ def main():
|
||||||
module.fail_json(msg='Timeout waiting for handoffs.')
|
module.fail_json(msg='Timeout waiting for handoffs.')
|
||||||
|
|
||||||
if wait_for_service:
|
if wait_for_service:
|
||||||
cmd = [riak_admin_bin, 'wait_for_service', 'riak_%s' % wait_for_service, node_name]
|
cmd = riak_admin_bin + ['wait_for_service', 'riak_%s' % wait_for_service, node_name]
|
||||||
rc, out, err = module.run_command(cmd)
|
rc, out, err = module.run_command(cmd)
|
||||||
result['service'] = out
|
result['service'] = out
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue