[Why] Output needs to be displayed in the stats.json file, so this output need to processed as a key-value pair.
[input] PLAY RECAP ********************************************************************* localhost : ok=2 changed=0 unreachable=0 failed=1 skipped=0 rescued=0 ignored=0
playbook_run_on_fail: 1
[output] ansible_test.total.nr_ok: 2 ansible_test.total.nr_changed: 0 ansible_test.total.nr_failed: 1 ansible_test.total.nr_skipped: 0 ansible_test.total.nr_rescued: 0 ansible_test.total.nr_ignored: 0 playbook_run_on_fail: 1
Signed-off-by: Zhang Yale ylzhangah@qq.com --- stats/ansible_test | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100755 stats/ansible_test
diff --git a/stats/ansible_test b/stats/ansible_test new file mode 100755 index 00000000..4c7d07b3 --- /dev/null +++ b/stats/ansible_test @@ -0,0 +1,15 @@ +#!/usr/bin/env ruby + +while (line = STDIN.gets) + case line.chomp! + when /ok=(\d+)\s+changed=(\d+)\s+unreachable=(\d+)\s+failed=(\d+)\s+skipped=(\d+)\s+rescued=(\d+)\s+ignored=(\d+)/ + puts "ansible_test.total.nr_ok: #{$1}" + puts "ansible_test.total.nr_changed: #{$2}" + puts "ansible_test.total.nr_failed: #{$4}" + puts "ansible_test.total.nr_skipped: #{$5}" + puts "ansible_test.total.nr_rescued: #{$6}" + puts "ansible_test.total.nr_ignored: #{$7}" + when /playbook_run_on_fail/ + puts line + end +end
On Thu, Jan 14, 2021 at 03:19:41PM +0800, Zhang Yale wrote:
[Why] Output needs to be displayed in the stats.json file, so this output need to processed as a key-value pair.
[input] PLAY RECAP ********************************************************************* localhost : ok=2 changed=0 unreachable=0 failed=1 skipped=0 rescued=0 ignored=0
playbook_run_on_fail: 1
[output] ansible_test.total.nr_ok: 2 ansible_test.total.nr_changed: 0 ansible_test.total.nr_failed: 1 ansible_test.total.nr_skipped: 0 ansible_test.total.nr_rescued: 0 ansible_test.total.nr_ignored: 0 playbook_run_on_fail: 1
playbook_run_on_fail: 1 => ansible_test.playbook_run_on_fail: 1 ?
Thanks, Weitao
On Thu, Jan 14, 2021 at 03:25:59PM +0800, Lu Weitao wrote:
On Thu, Jan 14, 2021 at 03:19:41PM +0800, Zhang Yale wrote:
[Why] Output needs to be displayed in the stats.json file, so this output need to processed as a key-value pair.
[input] PLAY RECAP ********************************************************************* localhost : ok=2 changed=0 unreachable=0 failed=1 skipped=0 rescued=0 ignored=0
playbook_run_on_fail: 1
[output] ansible_test.total.nr_ok: 2 ansible_test.total.nr_changed: 0 ansible_test.total.nr_failed: 1 ansible_test.total.nr_skipped: 0 ansible_test.total.nr_rescued: 0 ansible_test.total.nr_ignored: 0 playbook_run_on_fail: 1
playbook_run_on_fail: 1 => ansible_test.playbook_run_on_fail: 1 ?
Thanks, Weitao
This can be ok.
Thanks, Yale
On Thu, Jan 14, 2021 at 03:19:41PM +0800, Zhang Yale wrote:
[Why] Output needs to be displayed in the stats.json file, so this output need to processed as a key-value pair.
[input] PLAY RECAP ********************************************************************* localhost : ok=2 changed=0 unreachable=0 failed=1 skipped=0 rescued=0 ignored=0
playbook_run_on_fail: 1
[output] ansible_test.total.nr_ok: 2
"total" looks not necessary. "nr_" already means counting. "ansible_test" is also not necessary. LKP framework will auto add the prefix. You may check other stats scripts for example.
ansible_test.total.nr_changed: 0 ansible_test.total.nr_failed: 1 ansible_test.total.nr_skipped: 0 ansible_test.total.nr_rescued: 0 ansible_test.total.nr_ignored: 0
playbook_run_on_fail: 1
=> playbook.run.fail: 1
btw, why the fixed "playbook" prefix?
Where is your test script? If it echo playbook_run_on_fail based on ansible's exit code, why not just return ansible's exit code?
Thanks, Fengguang
Signed-off-by: Zhang Yale ylzhangah@qq.com
stats/ansible_test | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100755 stats/ansible_test
diff --git a/stats/ansible_test b/stats/ansible_test new file mode 100755 index 00000000..4c7d07b3 --- /dev/null +++ b/stats/ansible_test @@ -0,0 +1,15 @@ +#!/usr/bin/env ruby
+while (line = STDIN.gets)
- case line.chomp!
- when /ok=(\d+)\s+changed=(\d+)\s+unreachable=(\d+)\s+failed=(\d+)\s+skipped=(\d+)\s+rescued=(\d+)\s+ignored=(\d+)/
- puts "ansible_test.total.nr_ok: #{$1}"
- puts "ansible_test.total.nr_changed: #{$2}"
- puts "ansible_test.total.nr_failed: #{$4}"
- puts "ansible_test.total.nr_skipped: #{$5}"
- puts "ansible_test.total.nr_rescued: #{$6}"
- puts "ansible_test.total.nr_ignored: #{$7}"
- when /playbook_run_on_fail/
- puts line
- end
+end
2.23.0
On Thu, Jan 14, 2021 at 04:43:25PM +0800, Wu Fengguang wrote:
On Thu, Jan 14, 2021 at 03:19:41PM +0800, Zhang Yale wrote:
[Why] Output needs to be displayed in the stats.json file, so this output need to processed as a key-value pair.
[input] PLAY RECAP ********************************************************************* localhost : ok=2 changed=0 unreachable=0 failed=1 skipped=0 rescued=0 ignored=0
playbook_run_on_fail: 1
[output] ansible_test.total.nr_ok: 2
"total" looks not necessary. "nr_" already means counting.
Ok, I got it.
"ansible_test" is also not necessary. LKP framework will auto add the prefix. You may check other stats scripts for example.
OK, I'll check other stats scripts and fix it.
ansible_test.total.nr_changed: 0 ansible_test.total.nr_failed: 1 ansible_test.total.nr_skipped: 0 ansible_test.total.nr_rescued: 0 ansible_test.total.nr_ignored: 0
playbook_run_on_fail: 1
=> playbook.run.fail: 1
OK
btw, why the fixed "playbook" prefix?
In my test script echo "playbook_run_on_fail: 1" when playbook executed failed. I just want to use es-job tool.
Where is your test script? If it echo playbook_run_on_fail based on ansible's exit code, why not just return ansible's exit code?
ansible_test script has not been patched. Ok, I'll changed in next patch. Thanks for your review.
Thanks, Yale
Thanks, Fengguang
Signed-off-by: Zhang Yale ylzhangah@qq.com
stats/ansible_test | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100755 stats/ansible_test
diff --git a/stats/ansible_test b/stats/ansible_test new file mode 100755 index 00000000..4c7d07b3 --- /dev/null +++ b/stats/ansible_test @@ -0,0 +1,15 @@ +#!/usr/bin/env ruby
+while (line = STDIN.gets)
- case line.chomp!
- when /ok=(\d+)\s+changed=(\d+)\s+unreachable=(\d+)\s+failed=(\d+)\s+skipped=(\d+)\s+rescued=(\d+)\s+ignored=(\d+)/
- puts "ansible_test.total.nr_ok: #{$1}"
- puts "ansible_test.total.nr_changed: #{$2}"
- puts "ansible_test.total.nr_failed: #{$4}"
- puts "ansible_test.total.nr_skipped: #{$5}"
- puts "ansible_test.total.nr_rescued: #{$6}"
- puts "ansible_test.total.nr_ignored: #{$7}"
- when /playbook_run_on_fail/
- puts line
- end
+end
2.23.0