Debian Codegraph @

docs/cli/inv-from-ansible.md

raw symbols SCIP
1 ---
2 title: Create an Inventory from Ansible inventory
3 hide:
4 - tags
5 tags:
6 - CLI
7 - Inventory
8 ---
9
10 <!--
11 ~ Copyright (c) 2023-2026 Arista Networks, Inc.
12 ~ Use of this source code is governed by the Apache License 2.0
13 ~ that can be found in the LICENSE file.
14 -->
15
16 In large setups, it might be beneficial to construct your inventory based on your Ansible inventory. The `from-ansible` entrypoint of the `get` command enables the user to create an ANTA inventory from Ansible.
17
18 ## Command overview
19
20 ```bash
21 --8<-- "anta_get_fromansible_help.txt"
22 ```
23
24 !!! warning
25
26 - `anta get from-ansible` does not support inline vaulted variables, comment them out to generate your inventory.
27
28 - If the vaulted variable is necessary to build the inventory (e.g. `ansible_host`), it needs to be unvaulted for `from-ansible` command to work.
29
30 - The current implementation only considers devices directly attached to a specific Ansible group and does not support inheritance when using the `--ansible-group` option.
31
32 By default, if user does not provide `--output` file, anta will save output to configured anta inventory (`anta --inventory`). If the output file has content, anta will ask user to overwrite when running in interactive console. This mechanism can be controlled by triggers in case of CI usage: `--overwrite` to force anta to overwrite file. If not set, anta will exit
33
34 ## Command output
35
36 `host` value is coming from the `ansible_host` key in your inventory while `name` is the name you defined for your host. Below is an ansible inventory example used to generate previous inventory:
37
38 ```yaml
39 ---
40 all:
41 children:
42 endpoints:
43 hosts:
44 srv-pod01:
45 ansible_httpapi_port: 9023
46 ansible_port: 9023
47 ansible_host: 10.73.252.41
48 type: endpoint
49 srv-pod02:
50 ansible_httpapi_port: 9024
51 ansible_port: 9024
52 ansible_host: 10.73.252.42
53 type: endpoint
54 srv-pod03:
55 ansible_httpapi_port: 9025
56 ansible_port: 9025
57 ansible_host: 10.73.252.43
58 type: endpoint
59 ```
60
61 The output is an inventory where the name of the container is added as a tag for each host:
62
63 ```yaml
64 anta_inventory:
65 hosts:
66 - host: 10.73.252.41
67 name: srv-pod01
68 - host: 10.73.252.42
69 name: srv-pod02
70 - host: 10.73.252.43
71 name: srv-pod03
72 ```