ansible-community / ara

ARA Records Ansible and makes it easier to understand and troubleshoot.
https://ara.recordsansible.org
GNU General Public License v3.0
1.85k stars 171 forks source link

'Run completed with changes' status on overview #264

Open Thulium-Drake opened 3 years ago

Thulium-Drake commented 3 years ago

What is the idea ?

With the new UI (I love it! :-) ) I feel it would be very useful to have an icon that indicates if a run was successful with changes as well.

In my usecase for Ansible I don't really care about runs that did not change anything, but the ones that did are interesting to me. And I'd really like to be able to differentiate between them with glancing at the overview page.

With regards to the visual representation, I'm not sure, as of the current situation is:

First thing that comes to my mind:

dmsimard commented 3 years ago

o/

I want to say this was asked somewhere else and wanted to refer to it but I can't find it right now.

Currently the API is not aware if a playbook has resulted in changes, only if it is still running, if it has completed or if it has failed. This is because the task statistics (like ok, changed, failed and so on) are not stored at the playbook level but rather at the host level -- as in, each host stores it's own statistics provided by Ansible for that playbook.

In addition, we also have individual result statuses per task for each host but these are not summarized into a singular number like what ansible does at the end of a playbook.

I could be mistaken but without even starting to think about what kind of changes we could implement to bubble this data up to the playbooks, I believe the WIP host index page would meet your needs.

In essence, you could search for hosts with changed results a bit like how you would with the CLI:

> ara host list --with-changed --resolve
+------+-----------+-----------------------------------------------------------+---------+--------+----+---------+-------------+-----------------------------+
|   id | name      | playbook                                                  | changed | failed | ok | skipped | unreachable | updated                     |
+------+-----------+-----------------------------------------------------------+---------+--------+----+---------+-------------+-----------------------------+
| 9009 | localhost | (2937) ...antsibull/playbooks/build-single-release.yaml   |       9 |      0 | 24 |       1 |           0 | 2021-03-10T15:30:24.995087Z |
| 9002 | localhost | (2933) ...recordsansible/ara/tests/integration/hosts.yaml |       1 |      0 |  2 |       0 |           0 | 2021-02-25T17:02:24.903437Z |
| 9004 | host2     | (2933) ...recordsansible/ara/tests/integration/hosts.yaml |       1 |      0 |  3 |       1 |           0 | 2021-02-25T17:02:24.638437Z |
| 8999 | localhost | (2931) ...recordsansible/ara/tests/integration/smoke.yaml |      10 |      0 | 36 |       1 |           0 | 2021-02-25T17:01:27.748905Z |
| 8992 | localhost | (2927) ...recordsansible/ara/tests/integration/hosts.yaml |       1 |      0 |  2 |       0 |           0 | 2021-02-25T14:26:19.601029Z |
| 8993 | host2     | (2927) ...recordsansible/ara/tests/integration/hosts.yaml |       1 |      0 |  3 |       1 |           0 | 2021-02-25T14:26:19.465421Z |
| 8989 | localhost | (2925) ...recordsansible/ara/tests/integration/smoke.yaml |      10 |      0 | 36 |       1 |           0 | 2021-02-25T14:25:45.674627Z |
| 8982 | localhost | (2921) ...recordsansible/ara/tests/integration/hosts.yaml |       1 |      0 |  2 |       0 |           0 | 2021-02-25T05:19:08.563291Z |
| 8984 | host2     | (2921) ...recordsansible/ara/tests/integration/hosts.yaml |       1 |      0 |  3 |       1 |           0 | 2021-02-25T05:19:08.385058Z |
| 8979 | localhost | (2919) ...recordsansible/ara/tests/integration/smoke.yaml |      10 |      0 | 36 |       1 |           0 | 2021-02-25T05:18:29.357318Z |
| 8972 | localhost | (2915) ...recordsansible/ara/tests/integration/hosts.yaml |       1 |      0 |  2 |       0 |           0 | 2021-02-25T04:28:19.163653Z |
| 8975 | host2     | (2915) ...recordsansible/ara/tests/integration/hosts.yaml |       1 |      0 |  3 |       1 |           0 | 2021-02-25T04:28:19.027294Z |
| 8969 | localhost | (2913) ...recordsansible/ara/tests/integration/smoke.yaml |      10 |      0 | 36 |       1 |           0 | 2021-02-25T04:27:44.978289Z |
| 8968 | localhost | (2912) ...antsibull/playbooks/build-single-release.yaml   |       8 |      0 | 24 |       1 |           0 | 2021-02-17T14:03:09.478484Z |
| 8961 | localhost | (2908) ...recordsansible/ara/tests/integration/hosts.yaml |       1 |      0 |  2 |       0 |           0 | 2021-02-16T20:59:39.449017Z |
| 8963 | host2     | (2908) ...recordsansible/ara/tests/integration/hosts.yaml |       1 |      0 |  3 |       1 |           0 | 2021-02-16T20:59:39.260880Z |
| 8958 | localhost | (2906) ...recordsansible/ara/tests/integration/smoke.yaml |      10 |      0 | 36 |       1 |           0 | 2021-02-16T20:58:56.260691Z |
| 8957 | localhost | (2905) ...antsibull/playbooks/build-single-release.yaml   |       7 |      0 | 24 |       1 |           0 | 2021-02-02T19:53:30.357401Z |
| 8955 | localhost | (2903) ...antsibull/playbooks/build-single-release.yaml   |       1 |      1 |  4 |       0 |           0 | 2021-02-02T19:45:14.298692Z |
| 8954 | localhost | (2902) ...antsibull/playbooks/build-single-release.yaml   |       1 |      1 |  4 |       0 |           0 | 2021-02-02T19:39:09.348007Z |
| 8953 | localhost | (2901) ...antsibull/playbooks/build-single-release.yaml   |       2 |      1 |  4 |       0 |           0 | 2021-02-02T19:32:41.469530Z |
| 8952 | localhost | (2900) ...antsibull/playbooks/build-single-release.yaml   |       5 |      0 | 23 |       1 |           0 | 2021-02-02T02:50:13.430775Z |
| 8951 | localhost | (2899) ...antsibull/playbooks/build-single-release.yaml   |       2 |      1 |  7 |       1 |           0 | 2021-02-02T02:45:41.462376Z |
| 8950 | localhost | (2898) ...antsibull/playbooks/build-single-release.yaml   |       4 |      1 |  7 |       1 |           0 | 2021-02-02T02:44:23.339466Z |
| 8949 | localhost | (2897) ...antsibull/playbooks/build-single-release.yaml   |       5 |      0 | 21 |       1 |           0 | 2021-01-31T03:37:03.091368Z |
+------+-----------+-----------------------------------------------------------+---------+--------+----+---------+-------------+-----------------------------+

Would that make sense ?

Thulium-Drake commented 3 years ago

I also tried looking for an existing issue, but wasn't able to find it either :smile:

That is a brilliant thing to have as well! As this is mainly the information (at least I am) you're actually looking for :-)

I still feel it would also provide value on the a play-by-play basis as well, but this will definitely do in the mean time.

I'm trying to make up a nice report, this is the oneliner I've cooked up to try and make some reports with :-)

ara host list --server http://localhost:8000 --client http --with-changed -c playbook -c id -f value | awk '{ printf "https://ara.example.nl/playbooks/%s.html?host=%s&changed=true#results\n", $2, $1 }'
Thulium-Drake commented 3 years ago

For those that use MediaWiki, this might help you ;-)

#!/bin/bash
# Generate wiki page with all changed hosts
# Copyright (c) 2021 Jeffrey van Pelt
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)

. /opt/ara/api/virtualenv/bin/activate

LIMIT=20
ARA_SERVER="https://ara.example.nl"
ARA_OPTS="--server http://localhost:8000 --client http"

cat <<EOF >/tmp/REP:Ansible_changed_systems.wiki
 WARNING: This page is generated automatically!

The following list are the most recent $LIMIT systems that have had changes in their Ansible runs

{| class="wikitable" 
! Date !! Hostname !! Link to report
EOF
ara host list $ARA_OPTS --with-changed -c name -c playbook -c id -c updated --limit $LIMIT -f value |
awk -v ara="$ARA_SERVER" '{ printf("|- \n| %s || %s || [%s/playbooks/%s.html?host=%s&changed=true#results ARA]\n", $4, $2, ara, $1, $3) }' >> /tmp/REP:Ansible_changed_systems.wiki

echo '|}' >> /tmp/REP:Ansible_changed_systems.wiki

After running this script, make sure to get the resulting file (/tmp/REP:Ansible_changed_systems.wiki) automatically imported in your Wiki

dmsimard commented 3 years ago

Clever script and exactly what the CLI is intended to help with including the different formats, thanks for sharing :)

dmsimard commented 3 years ago

I could be mistaken but without even starting to think about what kind of changes we could implement to bubble this data up to the playbooks, I believe the WIP host index page would meet your needs.

Hi @Thulium-Drake o/

I wanted to circle back to this issue because the first iteration of the new host index page I mentioned will be landing in 1.5.7 soon and allows you to search hosts reports by status (including "changed") across all of their playbook runs: Peek 2021-07-24 20-39

Do you think it helps with what you were looking for ?

Thulium-Drake commented 3 years ago

Hi @dmsimard

Nice one! This is basically what I made with my script that will generate a Mediawiki page with links to runs.

So yes, this will help a lot! :smile: