LINUX.ORG.RU
ФорумAdmin

Форматирование вывода ansible роли

 


0

1

Всем привет! есть некая ansible роль которая проверяет последние бекапы баз данных (Elasticsearch, Cassandra) Хочется вот с этого вывода


ansible-playbook other/check_backup_status.yml -i hosts/mvd/prod/hosts.yml

PLAY [check backup] ***************************************************************************************************************************************************************************************************************

TASK [check_backup : check backups for cluster elasticsearch-bishkek] ***************************************************************************************************************************************************************************
skipping: [elasticsearch-bishkek-02]
skipping: [elasticsearch-bishkek-03]
skipping: [elasticsearch-kabul1]
skipping: [elasticsearch-kabul2]
skipping: [elasticsearch-kabul3]
skipping: [elasticsearch-kabul4]
skipping: [elasticsearch-kabul5]
skipping: [elasticsearch-kabul6]
skipping: [cassandra-bishkek01]
skipping: [cassandra-bishkek02]
skipping: [cassandra-bishkek03]
[WARNING]: Consider using the get_url or uri module rather than running 'curl'.  If you need to use command because get_url or uri is insufficient you can add 'warn: false' to this command task or set 'command_warnings=False'
in ansible.cfg to get rid of this message.
changed: [elasticsearch-bishkek-01]

TASK [check_backup : Show last 10 backups for elasticsearch bishkek cluster] ***********************************************************************************************************************************************************
ok: [elasticsearch-bishkek-01] => {
    "msg": [
        "snapshot-2021-01-02-14:20:01 SUCCESS 1609575601  08:20:01   1609575655 08:20:55    54.2s     106               364             0          364",
        "snapshot-2021-01-02-20:20:01 SUCCESS 1609597201  14:20:01   1609597260 14:21:00    58.7s     106               364             0          364",
        "snapshot-2021-01-03-09:20:01 SUCCESS 1609644002  03:20:02   1609644092 03:21:32     1.4m     106               364             0          364",
        "snapshot-2021-01-03-14:20:01 SUCCESS 1609662001  08:20:01   1609662173 08:22:53     2.8m     106               364             0          364",
        "snapshot-2021-01-03-20:20:01 SUCCESS 1609683602  14:20:02   1609683671 14:21:11     1.1m     106               364             0          364",
        "snapshot-2021-01-04-09:20:01 SUCCESS 1609730401  03:20:01   1609730467 03:21:07       1m     106               364             0          364",
        "snapshot-2021-01-04-14:20:01 SUCCESS 1609748402  08:20:02   1609748460 08:21:00    57.8s     106               364             0          364",
        "snapshot-2021-01-04-20:20:01 SUCCESS 1609770001  14:20:01   1609770064 14:21:04       1m     106               364             0          364",
        "snapshot-2021-01-05-09:20:01 SUCCESS 1609816801  03:20:01   1609816856 03:20:56    54.5s     106               364             0          364",
        "snapshot-2021-01-05-14:20:01 SUCCESS 1609834802  08:20:02   1609835018 08:23:38     3.5m     107               365             0          365"
    ]
}
skipping: [elasticsearch-bishkek-02]
skipping: [elasticsearch-bishkek-03]
skipping: [elasticsearch-kabul1]
skipping: [elasticsearch-kabul2]
skipping: [elasticsearch-kabul3]
skipping: [elasticsearch-kabul4]
skipping: [elasticsearch-kabul5]
skipping: [elasticsearch-kabul6]
skipping: [cassandra-bishkek01]
skipping: [cassandra-bishkek02]
skipping: [cassandra-bishkek03]

TASK [check_backup : check backups for elasticsearch kabul cluster] ******************************************************************************************************************************************************************************
skipping: [elasticsearch-bishkek-01]
skipping: [elasticsearch-bishkek-02]
skipping: [elasticsearch-bishkek-03]
skipping: [elasticsearch-kabul2]
skipping: [elasticsearch-kabul3]
skipping: [elasticsearch-kabul4]
skipping: [elasticsearch-kabul5]
skipping: [elasticsearch-kabul6]
skipping: [cassandra-bishkek01]
skipping: [cassandra-bishkek02]
skipping: [cassandra-bishkek03]
changed: [elasticsearch-kabul1]


TASK [check_backup : Show last 10 backups for elasticsearch-kabul] **************************************************************************************************************************************************************************
skipping: [elasticsearch-bishkek-01]
skipping: [elasticsearch-bishkek-02]
skipping: [elasticsearch-bishkek-03]
ok: [elasticsearch-kabul1] => {
    "msg": [
        "snapshot-2020-12-27-06:00:01 SUCCESS 1609027201  00:00:01   1609030938 01:02:18       1h      47               131             0          131",
        "snapshot-2020-12-28-06:00:01 SUCCESS 1609113602  00:00:02   1609114922 00:22:02    21.9m      50               140             0          140",
        "snapshot-2020-12-29-06:00:01 SUCCESS 1609200002  00:00:02   1609201779 00:29:39    29.6m      52               146             0          146",
        "snapshot-2020-12-30-06:00:01 SUCCESS 1609286402  00:00:02   1609290726 01:12:06     1.2h      30                76             0           76",
        "snapshot-2020-12-31-06:00:01 SUCCESS 1609372802  00:00:02   1609375122 00:38:42    38.6m      31                79             0           79",
        "snapshot-2021-01-01-06:00:01 SUCCESS 1609459202  00:00:02   1609461236 00:33:56    33.8m      33                85             0           85",
        "snapshot-2021-01-02-06:00:01 SUCCESS 1609545602  00:00:02   1609546580 00:16:20    16.3m      36                94             0           94",
        "snapshot-2021-01-03-06:00:01 SUCCESS 1609632003  00:00:03   1609633134 00:18:54    18.8m      37                97             0           97",
        "snapshot-2021-01-04-06:00:01 SUCCESS 1609718402  00:00:02   1609719266 00:14:26    14.4m      40               106             0          106",
        "snapshot-2021-01-05-06:00:01 SUCCESS 1609804802  00:00:02   1609805812 00:16:52    16.8m      41               109             0          109"
    ]
}
skipping: [elasticsearch-kabul2]
skipping: [elasticsearch-kabul3]
skipping: [elasticsearch-kabul4]
skipping: [elasticsearch-kabul5]
skipping: [elasticsearch-kabul6]
skipping: [cassandra-bishkek01]
skipping: [cassandra-bishkek02]
skipping: [cassandra-bishkek03]


TASK [check_backup : check backups for Cassandra cluster] *************************************************************************************************************************************************************************
skipping: [elasticsearch-bishkek-01]
skipping: [elasticsearch-bishkek-02]
skipping: [elasticsearch-bishkek-03]
skipping: [elasticsearch-kabul1]
skipping: [elasticsearch-kabul2]
skipping: [elasticsearch-kabul3]
skipping: [elasticsearch-kabul4]
skipping: [elasticsearch-kabul5]
skipping: [elasticsearch-kabul6]
skipping: [cassandra-bishkek02]
skipping: [cassandra-bishkek03]
changed: [cassandra-bishkek01]

TASK [check_backup : show last backups for Cassandra cluster] *********************************************************************************************************************************************************
skipping: [elasticsearch-bishkek-01]
skipping: [elasticsearch-bishkek-02]
skipping: [elasticsearch-bishkek-03]
skipping: [elasticsearch-kabul1]
skipping: [elasticsearch-kabul2]
skipping: [elasticsearch-kabul3]
skipping: [elasticsearch-kabul4]
skipping: [elasticsearch-kabul5]
skipping: [elasticsearch-kabul6]
ok: [cassandra-bishkek01] => {
    "msg": [
        "2021-01-03__09:20:01 (started: 2021-01-03 09:20:02, finished: 2021-01-03 09:21:16)",
        "2021-01-03__14:20:01 (started: 2021-01-03 14:20:02, finished: 2021-01-03 14:20:58)",
        "2021-01-03__20:20:01 (started: 2021-01-03 20:20:02, finished: 2021-01-03 20:21:01)",
        "2021-01-04__09:20:01 (started: 2021-01-04 09:20:02, finished: 2021-01-04 09:21:36)",
        "2021-01-04__14:20:01 (started: 2021-01-04 14:20:02, finished: 2021-01-04 14:20:59)",
        "2021-01-04__20:20:01 (started: 2021-01-04 20:20:02, finished: 2021-01-04 20:21:02)",
        "2021-01-05__09:20:01 (started: 2021-01-05 09:20:02, finished: 2021-01-05 09:21:25)",
        "2021-01-05__14:20:01 (started: 2021-01-05 14:20:02, finished: 2021-01-05 14:21:13)",
        "",
        "Incomplete backups found. You can run \"medusa status --backup-name <name>\" for more details"
    ]
}
skipping: [cassandra-bishkek02]
skipping: [cassandra-bishkek03]

PLAY RECAP ************************************************************************************************************************************************************************************************************************
elasticsearch-kabul1                     : ok=2    changed=1    unreachable=0    failed=0    skipped=6    rescued=0    ignored=0
elasticsearch-kabul2                     : ok=0    changed=0    unreachable=0    failed=0    skipped=8    rescued=0    ignored=0
elasticsearch-kabul3                     : ok=0    changed=0    unreachable=0    failed=0    skipped=8    rescued=0    ignored=0
elasticsearch-kabul4                     : ok=0    changed=0    unreachable=0    failed=0    skipped=8    rescued=0    ignored=0
elasticsearch-kabul5                     : ok=0    changed=0    unreachable=0    failed=0    skipped=8    rescued=0    ignored=0
elasticsearch-kabul6                     : ok=0    changed=0    unreachable=0    failed=0    skipped=8    rescued=0    ignored=0
elasticsearch-bishkek-01        : ok=2    changed=1    unreachable=0    failed=0    skipped=6    rescued=0    ignored=0
elasticsearch-bishkek-02        : ok=0    changed=0    unreachable=0    failed=0    skipped=8    rescued=0    ignored=0
elasticsearch-bishkek-03        : ok=0    changed=0    unreachable=0    failed=0    skipped=8    rescued=0    ignored=0
cassandra-bishkek01           : ok=2    changed=1    unreachable=0    failed=0    skipped=6    rescued=0    ignored=0
cassandra-bishkek02           : ok=0    changed=0    unreachable=0    failed=0    skipped=8    rescued=0    ignored=0
cassandra-bishkek03           : ok=0    changed=0    unreachable=0    failed=0    skipped=8    rescued=0    ignored=0

получить что то читабельное типа

show last backups for Cassandra cluster
ok: [cassandra-bishkek01] => {
    "msg": [
        "2021-01-03__09:20:01 (started: 2021-01-03 09:20:02, finished: 2021-01-03 09:21:16)",
        "2021-01-03__14:20:01 (started: 2021-01-03 14:20:02, finished: 2021-01-03 14:20:58)",
        "2021-01-03__20:20:01 (started: 2021-01-03 20:20:02, finished: 2021-01-03 20:21:01)",
        "2021-01-04__09:20:01 (started: 2021-01-04 09:20:02, finished: 2021-01-04 09:21:36)",
        "2021-01-04__14:20:01 (started: 2021-01-04 14:20:02, finished: 2021-01-04 14:20:59)",
        "2021-01-04__20:20:01 (started: 2021-01-04 20:20:02, finished: 2021-01-04 20:21:02)",
        "2021-01-05__09:20:01 (started: 2021-01-05 09:20:02, finished: 2021-01-05 09:21:25)",
        "2021-01-05__14:20:01 (started: 2021-01-05 14:20:02, finished: 2021-01-05 14:21:13)",
        "",
        "Incomplete backups found. You can run \"medusa status --backup-name <name>\" for more details"

и так для каждого таска там где в name стоит show last backups

можете помочь плиз вырезать все эти skipping

можете помочь плиз вырезать все эти skipping

ANSIBLE_DISPLAY_SKIPPED_HOSTS=false ansible-playbook …

bass ★★★★★
()

A) [WARNING] - заменой захардкоженного curl на предложенный модуль;

Б) skipping - например, завести в инвентори группу под серверы с БД, и включить туда только интересующие. И запускать с ключём вида --limit=dbsrvs.

В) С выводом тоже наверно можно поработать, при большом желании. Например: https://docs.ansible.com/ansible/latest/user_guide/playbooks_filters.html#sel...

NDfan
()
Вы не можете добавлять комментарии в эту тему. Тема перемещена в архив.