ansible sanity for k8s_cp (#183)

This commit is contained in:
abikouo
2021-07-27 06:00:24 +02:00
committed by GitHub
parent c330c7ec65
commit f98469e5ef
6 changed files with 29 additions and 2 deletions

View File

@@ -67,7 +67,7 @@ def execute_module(module):
content = ""
count = 0
while len(content) < size:
content += f"This file has been generated using ansible: {count}\n"
content += "This file has been generated using ansible: {0}\n".format(count)
count += 1
with open(path, write_mode) as f:

View File

@@ -166,7 +166,9 @@ def execute_module(module):
pod_rc, pod_out, pod_err = kubectl_run_from_pod(module)
rc, out, err = module.run_command([module.params.get('local_path')] + args)
if rc == pod_rc and out == pod_out:
module.exit_json(msg=f"{local_path} and {namespace}/{pod}:{file} are same.", rc=rc, stderr=err, stdout=out)
module.exit_json(msg="{0} and {1}/{2}:{3} are same.".format(
local_path, namespace, pod, file
), rc=rc, stderr=err, stdout=out)
result = dict(local=dict(rc=rc, out=out, err=err), remote=dict(rc=pod_rc, out=pod_out, err=pod_err))
module.fail_json(msg=f"{local_path} and {namespace}/{pod}:{file} are same.", **result)
else: