cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
1285
Views
0
Helpful
1
Replies

Cisco Modeling Labs 2 - cmlutils generate Ansible

sknock
Level 1
Level 1

I have an on premise CML-P 2.1 running.

Everything works fine and also briding with the external network via a custom bridge is not a problem.

 

But I try to use the "cmlutils" (https://developer.cisco.com/codeexchange/github/repo/CiscoDevNet/virlutils/) to generate an inventory file for Ansible (cml generate ansible). The result is each time empty. There is only the Ansible group "all:", but nothing else.

# virlutils generated ansible file for lab id: ffb2e4, title: topo.yaml
#
# the overall structure of the inventory follows best practices
# at http://docs.ansible.com/ansible/latest/intro_inventory.html

# we've rendered what we think is best if you disagree, override
# virl.generators.ansible_inventory_generator

# you can modify grouping behavior by adding a tag to your nodes:
# ansible_group=GROUP_NAME

all:

 

I tried a lot of things like configuring a Management IP address on the nodes but with no success.

The command "cml generate pyats" does work, but I want to use Ansible...

Can someone help me with this?

1 Reply 1

It might be helpful. Check out this note :

 

"NOTE: if the ansible_group tag is not specified for a node, that node will not be included during inventory generation. Additionally, CML needs to know each node's management IP address before it will be placed into the inventory file"

 

Update: successful generation of inventory requires two conditions:

  • at least one configured interface on the lab node with an IP address;
  • node tag: ansible_group=GROUP_NAME.

BUT! Cmlutils detects management IP address in very weird way. While there is an actual IPv4 address of the interface present in the column "L3 address" of the "cml nodes" command output, the ansible inventory generation is successful. The main issue is "L3 address" exists in that column only about 10min or so after the node status changed to "BOOTED" and then it disappears. Check the attached screenshot.