Skip to content

Latest commit

 

History

History

lab04-cv-configlets

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 

LAB 04 - Manage Configlet on Cloudvision

About

Create, Update and Delete configlets on CloudVision

Execute lab

1. Review configlet vars

# Go to lab04 directory
$ cd ../lab04-cv-configlets

# Check variables
$ cat group_vars/CVP.yml
---
CVP_CONFIGLETS:
  01TRAINING-alias: "alias a{{ 999 | random }} show version"
  01TRAINING-01: "alias a{{ 999 | random }} show version"

2. Create a new configlet on CloudVision server using the CVP collection for Ansible

Create a new configlet

# Create a new configlet by editing group_vars/CVP.yml
$ vi group_vars/CVP.yml
---
CVP_CONFIGLETS:
  01TRAINING-alias: "alias a{{ 999 | random }} show version"
  01TRAINING-01: "alias a{{ 999 | random }} show version"
  01TRAINING-02: "alias a{{ 999 | random }} show version"
# Run playbook to create configlets on CVP
$ ansible-playbook playbook.configlet.yml

Check on CVP that the configlet has been imported: https://{{cvp_address}}/cv/provisioning/configlet

3. Optional: Add a new configlet from file

Configlets can be read from files using the ansible lookup plugin.

# Check [configlet.txt](configlet.txt) file content that will used for the new configlet 01TRAINING-03
$ cat configlet.txt

# Edit [CVP.yml](group_vars/CVP.yml) file
$ vi group_vars/CVP.yml

# And update content with
---
CVP_CONFIGLETS:
  01TRAINING-alias: "alias a{{ 999 | random }} show version"
  01TRAINING-01: "alias a{{ 999 | random }} show version"
  01TRAINING-02: "alias sib show interface brief"
  01TRAINING-03: "{{lookup('file', './configlet.txt')}}"
# Run playbook to create the new configlet on CVP
$ ansible-playbook playbook.configlet.yml

Check on CloudVision: https://{{cvp_address}}/cv/provisioning/configlet

4. Remove configlet 01TRAINING-01 to -03 from CloudVision

Remove configlets 01TRAINING-01, 01TRAINING-02 and 01TRAINING-03

# Edit [CVP.yml](group_vars/CVP.yml) file
$ vi group_vars/CVP.yml

# And update content with
---
CVP_CONFIGLETS:
  01TRAINING-alias: "alias a{{ 999 | random }} show version"
# Check the configlet filter used in the playboook playbook.configlet.yml
$ cat playbook.configlet.yml
        configlet_filter: ["TRAINING"]
# Run playbook to create the new configlet on CVP
$ ansible-playbook playbook.configlet.yml

Check on CloudVision: https://{{cvp_address}}/cv/provisioning/configlet

5. Remove all TRAINING configlets created in this lab

  • Edit playbook
  • Set state to absent
  • Run playbook
# Set the state to absent instead of present in the playbook
$ vi playbook.configlet.yml
        state: absent
# Run playbook to remove the TRAINING configlet on CVP
$ ansible-playbook playbook.configlet.yml

Check on CloudVision: https://{{cvp_address}}/cv/provisioning/configlet