containerlab icon indicating copy to clipboard operation
containerlab copied to clipboard

propagate config vars to ansible inventory yaml file

Open hellt opened this issue 4 years ago • 3 comments

if a defaults/kinds/node section has a .config.vars section it makes sense to copy it to the ansible invenotory, so that ansible scripts could use those vars

/cc @jrokeach

hellt avatar Oct 12 '21 20:10 hellt

🙏 Number 1 use case in my mind for this is to provide a ansible_docker_host variable with the container name, to be used with the Ansible docker connection plugin

Actually if this is something that were automatically generated by containerlab, that'd be even better.

Thanks so much for the great tool!

tobbbles avatar Feb 21 '22 21:02 tobbbles

Hi @tobbbles If I understand the plugin purpose correctly (run commands inside containers) then I think you don't need this special variable set. The current inventory hostnames are the fully qualified container names, so you should be able to run docker commands with them

hellt avatar Feb 22 '22 06:02 hellt

Visiting that now, that's true, however for the hostname to work we actually need to remove the ansible_host var, as here https://github.com/srl-labs/containerlab/pulls?q=is%3Apr+ansible+#issuecomment-1047270956

Would we want something to extend this config section of a node to inform containerlab to not generate teh ansible host, and instead leave just the inventory_hostname to take precedent?

tobbbles avatar Feb 22 '22 08:02 tobbbles