[PATCH lkp-tests] test/ansible_test: modify ansible code to output the module name

[Why] modify ansible code to output the name of the module for tasks execution. [How] print("{'action':'%s'}" % task_result.__dict__['_task_fields']['action']) {'action':'package'} Signed-off-by: Wang Chenglong <18509160991@163.com> --- tests/ansible_test | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/tests/ansible_test b/tests/ansible_test index 56926bbed..1c19c2b0f 100755 --- a/tests/ansible_test +++ b/tests/ansible_test @@ -58,7 +58,18 @@ ansible_playbook_run() EOF [ $? -eq 0 ] && { echo "Playbook has been generated!" - } + } + [ $(command -v ansible-playbook) ] || { + echo "ansible-playbook: command not found" + exit 1 + } + + sed -i "536a\ print\(\"{\'action\':\'%s\'}\" \% task_result.__dict__[\'_task_fields\'][\'action\']\)" \ + /usr/local/lib/python3.7/site-packages/ansible/plugins/strategy/__init__.py + + sed -i "550a\ print\(\"{\'action\':\'%s\'}\" \% task_result.__dict__[\'_task_fields\'][\'action\']\)" \ + /usr/local/lib/python3.7/site-packages/ansible/plugins/strategy/__init__.py + ansible-playbook "$ansible_path"/site.yml if [ $? -eq 0 ]; then -- 2.23.0

@@ -58,7 +58,18 @@ ansible_playbook_run() EOF [ $? -eq 0 ] && { echo "Playbook has been generated!" - } + } + [ $(command -v ansible-playbook) ] || { + echo "ansible-playbook: command not found" + exit 1 + } + + sed -i "536a\ print\(\"{\'action\':\'%s\'}\" \% task_result.__dict__[\'_task_fields\'][\'action\']\)" \ + /usr/local/lib/python3.7/site-packages/ansible/plugins/strategy/__init__.py + + sed -i "550a\ print\(\"{\'action\':\'%s\'}\" \% task_result.__dict__[\'_task_fields\'][\'action\']\)" \ + /usr/local/lib/python3.7/site-packages/ansible/plugins/strategy/__init__.py
if you want to insert line to the file, better insert the line with bigger line_number first. Thanks, Luan Shengde
+ ansible-playbook "$ansible_path"/site.yml
if [ $? -eq 0 ]; then -- 2.23.0
participants (2)
-
Luan Shengde
-
Wang Chenglong