mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
[PR #8211/bafad8ec backport][stable-8] Support newer 'riak admin' sub-command beside legacy 'riak-admin' command (#8232)
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>
(cherry picked from commit bafad8ecd4
)
Co-authored-by: tobixx <tobixx@directbox.com>
This commit is contained in:
parent
f312d2af5e
commit
6b81091de6
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):
|
||||
cmd = '%s ringready' % riak_admin_bin
|
||||
cmd = riak_admin_bin + ['ringready']
|
||||
rc, out, err = module.run_command(cmd)
|
||||
if rc == 0 and 'TRUE All nodes agree on the ring' in out:
|
||||
return True
|
||||
|
@ -127,6 +127,7 @@ def main():
|
|||
# make sure riak commands are on the path
|
||||
riak_bin = module.get_bin_path('riak')
|
||||
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
|
||||
while True:
|
||||
|
@ -164,7 +165,7 @@ def main():
|
|||
module.fail_json(msg=out)
|
||||
|
||||
elif command == 'kv_test':
|
||||
cmd = '%s test' % riak_admin_bin
|
||||
cmd = riak_admin_bin + ['test']
|
||||
rc, out, err = module.run_command(cmd)
|
||||
if rc == 0:
|
||||
result['kv_test'] = out
|
||||
|
@ -175,7 +176,7 @@ def main():
|
|||
if nodes.count(node_name) == 1 and len(nodes) > 1:
|
||||
result['join'] = 'Node is already in cluster or staged to be in cluster.'
|
||||
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)
|
||||
if rc == 0:
|
||||
result['join'] = out
|
||||
|
@ -184,7 +185,7 @@ def main():
|
|||
module.fail_json(msg=out)
|
||||
|
||||
elif command == 'plan':
|
||||
cmd = '%s cluster plan' % riak_admin_bin
|
||||
cmd = riak_admin_bin + ['cluster', 'plan']
|
||||
rc, out, err = module.run_command(cmd)
|
||||
if rc == 0:
|
||||
result['plan'] = out
|
||||
|
@ -194,7 +195,7 @@ def main():
|
|||
module.fail_json(msg=out)
|
||||
|
||||
elif command == 'commit':
|
||||
cmd = '%s cluster commit' % riak_admin_bin
|
||||
cmd = riak_admin_bin + ['cluster', 'commit']
|
||||
rc, out, err = module.run_command(cmd)
|
||||
if rc == 0:
|
||||
result['commit'] = out
|
||||
|
@ -206,7 +207,7 @@ def main():
|
|||
if wait_for_handoffs:
|
||||
timeout = time.time() + wait_for_handoffs
|
||||
while True:
|
||||
cmd = '%s transfers' % riak_admin_bin
|
||||
cmd = riak_admin_bin + ['transfers']
|
||||
rc, out, err = module.run_command(cmd)
|
||||
if 'No transfers active' in out:
|
||||
result['handoffs'] = 'No transfers active.'
|
||||
|
@ -216,7 +217,7 @@ def main():
|
|||
module.fail_json(msg='Timeout waiting for handoffs.')
|
||||
|
||||
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)
|
||||
result['service'] = out
|
||||
|
||||
|
|
Loading…
Reference in a new issue