Skip to content

Commit

Permalink
doc fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
hellt committed Feb 22, 2022
1 parent c105101 commit bae4bca
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 10 deletions.
22 changes: 13 additions & 9 deletions docs/manual/inventory.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,18 +46,20 @@ Lab nodes are grouped under their kinds in the inventory so that the users can s
ansible_host: <mgmt-ipv4-address>
```

If you want to use the [Ansible Docker connection](https://docs.ansible.com/ansible/latest/collections/community/docker/docker_connection.html) plugin, you can set the `ansible-no-host-var` label on a node to not generate the `ansible_host` variable in the inventory. This is useful as the connection plugin will now use the `inventory_hostname` when executing via Docker.
## Removing `ansible_host` var
If you want to use a plugin[^1] that doesn't play well with the `ansible_host` variable injected by containerlab in the inventory file, you can leverage the `ansible-no-host-var` label. The label can be set on per-node, kind, or default levels; if set, containerlab will not generate the `ansible_host` variable in the inventory for the nodes with that label.
Note that without the `ansible_host` variable, the connection plugin will use the `inventory_hostname` and resolve the name accordingly if network reachability is needed.

=== "topology file"
```yaml
name: ansible
topology:
defaults:
labels:
ansible-no-host-var: "true"
nodes:
node1:
node2:
topology:
defaults:
labels:
ansible-no-host-var: "true"
nodes:
node1:
node2:
```
=== "generated ansible inventory"
```yaml
Expand Down Expand Up @@ -114,4 +116,6 @@ As a result of this configuration, the generated inventory will look like this:
hosts:
clab-custom-groups-node1:
ansible_host: 172.100.100.11
```
```

[^1]: For example [Ansible Docker connection](https://docs.ansible.com/ansible/latest/collections/community/docker/docker_connection.html) plugin.
3 changes: 2 additions & 1 deletion mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,8 @@ markdown_extensions:
- pymdownx.snippets:
check_paths: true
- pymdownx.superfences
- pymdownx.tabbed
- pymdownx.tabbed:
alternate_style: true
- pymdownx.tasklist:
custom_checkbox: true
- pymdownx.tilde

0 comments on commit bae4bca

Please sign in to comment.