Practical examples

The Cumulux VX image comes completely unconfigured (save for the DHCP client configuration on the management port eth0). It has three switch ports, that is, swp1, swp2, and swp3. Let's query one of those interfaces to see whether there is any existing configuration. We can use a simple playbook called switch-query.yaml to query swp1:

---- name: query switch  hosts: mastery-switch1  tasks:  - name: query swp1 interface    nclu:      commands:        - show interface swp1    register: interface  - name: print interface status    debug:      var: interface

If we run this (exactly as we have run other playbooks), then we will see something like the following:

This confirms our initial statement about the VM imagewe can see that the switch port is not ...

Get Mastering Ansible - Third Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.