| 1 | --- |
| 2 | title: Overview of ANTA's Command-Line Interface (CLI) |
| 3 | hide: |
| 4 | - tags |
| 5 | tags: |
| 6 | - CLI |
| 7 | --- |
| 8 | |
| 9 | <!-- |
| 10 | ~ Copyright (c) 2023-2026 Arista Networks, Inc. |
| 11 | ~ Use of this source code is governed by the Apache License 2.0 |
| 12 | ~ that can be found in the LICENSE file. |
| 13 | --> |
| 14 | |
| 15 | ANTA provides a powerful Command-Line Interface (CLI) to perform a wide range of operations. This document provides a comprehensive overview of ANTA CLI usage and its commands. |
| 16 | |
| 17 | ANTA can also be used as a Python library, allowing you to build your own tools based on it. Visit this [page](../advanced_usages/as-python-lib.md) for more details. |
| 18 | |
| 19 | To start using the ANTA CLI, open your terminal and type `anta`. |
| 20 | |
| 21 | ## Invoking ANTA CLI |
| 22 | |
| 23 | ```bash |
| 24 | --8<-- "anta_help.txt" |
| 25 | ``` |
| 26 | |
| 27 | ## ANTA environment variables |
| 28 | |
| 29 | Certain parameters are required and can be either passed to the ANTA CLI or set as an environment variable (ENV VAR). |
| 30 | |
| 31 | To pass the parameters via the CLI: |
| 32 | |
| 33 | ```bash |
| 34 | anta nrfu -u admin -p arista123 -i inventory.yaml -c tests.yaml |
| 35 | ``` |
| 36 | |
| 37 | To set them as environment variables: |
| 38 | |
| 39 | ```bash |
| 40 | export ANTA_USERNAME=admin |
| 41 | export ANTA_PASSWORD=arista123 |
| 42 | export ANTA_INVENTORY=inventory.yml |
| 43 | export ANTA_CATALOG=tests.yml |
| 44 | ``` |
| 45 | |
| 46 | Then, run the CLI without options: |
| 47 | |
| 48 | ```bash |
| 49 | anta nrfu |
| 50 | ``` |
| 51 | |
| 52 | !!! note |
| 53 | All environment variables may not be needed for every command. |
| 54 | |
| 55 | Refer to `<command> --help` for a comprehensive list of environment variables. |
| 56 | |
| 57 | Below are the environment variables usable with the `anta nrfu` command: |
| 58 | |
| 59 | | Variable Name | Purpose | Required | Default | |
| 60 | | ------------- | ------- | -------- | ------- | |
| 61 | | ANTA_USERNAME | The username to use in the inventory to connect to devices. | Yes | - | |
| 62 | | ANTA_PASSWORD | The password to use in the inventory to connect to devices. | Yes | - | |
| 63 | | ANTA_INVENTORY | The path to the inventory file. | Yes | - | |
| 64 | | ANTA_CATALOG | The path to the catalog file. | Yes | - | |
| 65 | | ANTA_ENABLE_PASSWORD | The optional enable password, when this variable is set, ANTA_ENABLE or `--enable` is required. | No | - | |
| 66 | | ANTA_ENABLE | Whether it is necessary to go to enable mode on devices. | No | False | |
| 67 | | ANTA_PROMPT | Prompt for passwords if they are not provided. | No | False | |
| 68 | | ANTA_TIMEOUT | The global timeout value for API calls. | No | 30.0 | |
| 69 | | ANTA_INSECURE | Whether or not to use insecure mode when connecting to the EOS devices HTTP API. | No | False | |
| 70 | | ANTA_DISABLE_CACHE | A variable to disable caching for all ANTA tests (enabled by default). | No | False | |
| 71 | | ANTA_USE_SESSION_AUTH | Enable or disable session-based authentication globally. When set to `true`, forces session auth on for all capable devices. When set to `false`, forces it off. When unset, defers to the per-device inventory value. | No | - | |
| 72 | | ANTA_INVENTORY_FORMAT | Format of the inventory file. `json` or `yaml`. | No | `yaml` | |
| 73 | | ANTA_CATALOG_FORMAT | Format of the catalog file. `json` or `yaml`. | No | `yaml` | |
| 74 | | ANTA_TAGS | A list of tags to filter which tests to run on which devices. | No | - | |
| 75 | | ANTA_NRFU_IGNORE_STATUS | Exit code will always be 0. | No | False | |
| 76 | | ANTA_NRFU_IGNORE_ERROR | Exit code will be 0 if all tests succeeded or 1 if any test failed. | No | False | |
| 77 | | ANTA_NRFU_DRY_RUN | Run `anta nrfu` command but stop before running the tests. | No | False | |
| 78 | | ANTA_DISCONNECT_INVENTORY | Disconnect inventory devices once the test run is complete. | No | True | |
| 79 | |
| 80 | !!! note |
| 81 | Caching can be disabled with the global parameter `--disable-cache`. For more details about how caching is implemented in ANTA, please refer to [Caching in ANTA](../advanced_usages/caching.md). |
| 82 | |
| 83 | ## ANTA Exit Codes |
| 84 | |
| 85 | ANTA CLI utilizes the following exit codes: |
| 86 | |
| 87 | - `Exit code 0` - All tests passed successfully. |
| 88 | - `Exit code 1` - An internal error occurred while executing ANTA. |
| 89 | - `Exit code 2` - A usage error was raised. |
| 90 | - `Exit code 3` - Tests were run, but at least one test returned an error. |
| 91 | - `Exit code 4` - Tests were run, but at least one test returned a failure. |
| 92 | |
| 93 | To ignore the test status, use `anta nrfu --ignore-status`, and the exit code will always be 0. |
| 94 | |
| 95 | To ignore errors, use `anta nrfu --ignore-error`, and the exit code will be 0 if all tests succeeded or 1 if any test failed. |
| 96 | |
| 97 | ## Shell Completion |
| 98 | |
| 99 | You can enable shell completion for the ANTA CLI: |
| 100 | |
| 101 | === "ZSH" |
| 102 | |
| 103 | If you use ZSH shell, add the following line in your `~/.zshrc`: |
| 104 | |
| 105 | ```bash |
| 106 | eval "$(_ANTA_COMPLETE=zsh_source anta)" > /dev/null |
| 107 | ``` |
| 108 | |
| 109 | === "BASH" |
| 110 | |
| 111 | With bash, add the following line in your `~/.bashrc`: |
| 112 | |
| 113 | ```bash |
| 114 | eval "$(_ANTA_COMPLETE=bash_source anta)" > /dev/null |
| 115 | ``` |