Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Map tags to inventory devices and test catalog #44

Closed
gusmb opened this issue Jul 15, 2022 · 2 comments
Closed

Map tags to inventory devices and test catalog #44

gusmb opened this issue Jul 15, 2022 · 2 comments
Assignees
Labels
framework-enhancement New feature or request

Comments

@gusmb
Copy link

gusmb commented Jul 15, 2022

Increase flexibility by using tags on inventory devices and the test catalog, so that catalog tests can run on relevant devices only. For instance, in s typical EVPN scenario there.might be some tests that should run only in spines and some other tests only on leaf switches, having also some tests that run on all devices. Using tags or filters on tests and inventory devices could achieve this easily and add flexibility to the way tests execute. For inventory networks/ranges, tags would apply to the whole range/network...

@titom73 titom73 added the framework-enhancement New feature or request label Jul 30, 2022
@titom73 titom73 self-assigned this Sep 7, 2022
@titom73
Copy link
Collaborator

titom73 commented Sep 7, 2022

We are going to start tag implementation with the following approach:

  • Inventory file:
anta_inventory:
  hosts:
  - host: 192.168.0.10
     tags: []
  - host: 192.168.0.11
     tags: []
  networks:
  - network: 192.168.110.0/24
     tags: []
 ranges:
  - start: 10.0.0.9
     end: 10.0.0.11
     tags: []
  • Check devices script update
check-devices.py --inventory my_inventory.yml --catalog my_catalog.yml --tags tag1,tag2 --table

So it will run all tests in the catalog for devices with tags tag1 and tag2 only

ksator pushed a commit that referenced this issue Sep 8, 2022
* feat(inventory): Add initial support for tags

Add support for tags in inventory module as per issue #44

```yaml
anta_inventory:
  hosts:
  - host: 192.168.0.10
     tags: []
  - host: 192.168.0.11
     tags: []
  networks:
  - network: 192.168.110.0/24
     tags: []
 ranges:
  - start: 10.0.0.9
     end: 10.0.0.11
     tags: []
```

* doc: Fix typo in docstring

* feat(inventory): Add method to filter inventory per tags

- Update inventory module to support tag filtering in get_inventory
- Update check-devices.py to support tags

Inventory example:

```yaml
anta_inventory:
  hosts:
  - host: 192.168.0.10
    tags: ['test']
  - host: 192.168.0.11
    tags: ['dc1']
  - host: 192.168.0.12
    tags: ['dc1']
  - host: 192.168.0.13
    tags: ['dc2']
  - host: 192.168.0.14
  - host: 192.168.0.15
  - host: 10.73.252.11
    tags: ['dc1']
  ranges:
    - start: 10.73.252.12
      end: 10.73.252.50
      tags: ['clab']
```

Code execution

```bash
python scripts/check-devices.py -i .personal/avd-lab.yml -c .personal/ceos-catalog.yml --table --tags dc1
[08:07:43] INFO     Inventory .personal/avd-lab.yml loaded                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      check-devices.py
           INFO     starting running test on inventory ...                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      check-devices.p
[08:07:44] INFO     testing done !
                                                                                    All tests results
┏━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃ Device IP    ┃ Test Name                         ┃ Test Status ┃ Message(s)                                                                                                            ┃
┡━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┩
│ 10.73.252.11 │ verify_eos_version                │ failure     │ device is running version 4.27.2F-26069621.4272F (engineering build) not in expected versions: ['4.25.4M', '4.26.1F'] │
│ 10.73.252.11 │ verify_field_notice_44_resolution │ skipped     │ verify_field_notice_44_resolution test is not supported on cEOSLab.                                                   │
│ 10.73.252.11 │ verify_uptime                     │ success     │                                                                                                                       │
│ 10.73.252.11 │ verify_zerotouch                  │ success     │                                                                                                                       │
│ 10.73.252.11 │ verify_running_config_diffs       │ success     │                                                                                                                       │
│ 10.73.252.11 │ verify_mlag_status                │ success     │                                                                                                                       │
│ 10.73.252.11 │ verify_mlag_interfaces            │ success     │                                                                                                                       │
│ 10.73.252.11 │ verify_mlag_config_sanity         │ success     │                                                                                                                       │
│ 10.73.252.11 │ verify_routing_protocol_model     │ success     │                                                                                                                       │
└──────────────┴───────────────────────────────────┴─────────────┴───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
```

* doc: Update rwith tag support
@mtache
Copy link
Collaborator

mtache commented Apr 6, 2023

Closing this issue since the current tags implementation fits the use case:

  • Define multiple test catalogs, one per inventory tag
  • Run ANTA multiple times mapping the device tags with their test catalogs

@mtache mtache closed this as completed Apr 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
framework-enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants