cv_server_provision - Provision server port by applying or removing template configuration to an Arista CloudVision Portal configlet that is applied to a switch.

New in version 2.4.

Synopsis

  • This module allows a server team to provision server network ports for new servers without having to access Arista CVP or asking the network team to do it for them. Provide the information for connecting to CVP, switch rack, port the new server is connected to, optional vlan, and an action and the module will apply the configuration to the switch port via CVP. Actions are add (applies template config to port), remove (defaults the interface config) and show (returns the current port config).

Requirements (on host that executes module)

  • Jinja2
  • cvprac >= 0.7.0

Options

parameter required default choices comments
action
no show
  • show
  • add
  • remove
The action for the module to take. The actions are add, which applies the specified template config to port, remove, which defaults the specified interface configuration, and show, which will return the current port configuration with no changes.
auto_run
no
  • yes
  • no
Flag that determines whether or not the module will execute the CVP task spawned as a result of changes to a switch configlet. When an add or remove action is taken which results in a change to a switch configlet, CVP will spawn a task that needs to be executed for the configuration to be applied to the switch. If this option is True then the module will determined the task number created by the configuration change, execute it and wait for the task to complete. If the option is False then the task will remain in the Pending state in CVP for a network administrator to review and execute.
host
yes
The hostname or IP address of the CVP node being connected to.
password
yes
The password of the user that will be used to connect to CVP for API calls.
port
no None
The port number to use when making API calls to the CVP node. This will default to the default port for the specified protocol. Port 80 for http and port 443 for https.
port_vlan
no None
The vlan that should be applied to the port for this server. This parameter is dependent on a proper template that supports single vlan provisioning with it. If a port vlan is specified by the template specified does not support this the module will exit out with no changes. If a template is specified that requires a port vlan but no port vlan is specified the module will exit out with no changes.
protocol
no https
  • https
  • http
The protocol to use when making API calls to CVP. CVP defaults to https and newer versions of CVP no longer support http.
server_name
yes
The hostname or identifier for the server that is having it's switch port provisioned.
switch_name
yes
The hostname of the switch is being configured for the server being provisioned.
switch_port
yes
The physical port number on the switch that the new server is connected to.
template
yes
A path to a Jinja formatted template file that contains the configuration block that will be applied to the specified switch port. This template will have variable fields replaced by the module before being applied to the switch configuration.
username
yes
The user that will be used to connect to CVP for making API calls.

Examples

- name: Get current configuration for interface Ethernet2
  cv_server_provision:
    host: cvp_node
    username: cvp_user
    password: cvp_pass
    protocol: https
    server_name: new_server
    switch_name: eos_switch_1
    switch_port: 2
    template: template_file.j2
    action: show

- name: Remove existing configuration from interface Ethernet2. Run task.
  cv_server_provision:
    host: cvp_node
    username: cvp_user
    password: cvp_pass
    protocol: https
    server_name: new_server
    switch_name: eos_switch_1
    switch_port: 2
    template: template_file.j2
    action: remove
    auto_run: True

- name: Add template configuration to interface Ethernet2. No VLAN. Run task.
  cv_server_provision:
    host: cvp_node
    username: cvp_user
    password: cvp_pass
    protocol: https
    server_name: new_server
    switch_name: eos_switch_1
    switch_port: 2
    template: single_attached_trunk.j2
    action: add
    auto_run: True

- name: Add template with VLAN configuration to interface Ethernet2. Run task.
  cv_server_provision:
    host: cvp_node
    username: cvp_user
    password: cvp_pass
    protocol: https
    server_name: new_server
    switch_name: eos_switch_1
    switch_port: 2
    port_vlan: 22
    template: single_attached_vlan.j2
    action: add
    auto_run: True

Return Values

Common return values are documented here Return Values, the following are the fields unique to this module:

name description returned type sample
changed
Signifies if a change was made to the configlet
success bool True
currentConfigBlock
The current config block for the user specified interface
when action = show string interface Ethernet4 !
fullConfig
The full config of the configlet after being updated
when action = add or remove string ! interface Ethernet3 ! interface Ethernet4 !
newConfigBlock
The new config block for the user specified interface
when action = add or remove string interface Ethernet3 description example no switchport !
oldConfigBlock
The current config block for the user specified interface before any changes are made
when action = add or remove string interface Ethernet3 !
portConfigurable
Signifies if the user specified port has an entry in the configlet that Ansible has access to
success bool True
switchConfigurable
Signifies if the user specified switch has a configlet applied to it that CVP is allowed to edit
success bool True
switchInfo
Information from CVP describing the switch being configured
success dictionary {'memTotal': 1893460, 'internalVersion': '4.17.1F-11111.4171F', 'ztpMode': 'false', 'systemMacAddress': '00:50:56:5d:e5:e0', 'tempAction': None, 'deviceStatus': 'Registered', 'taskIdList': [], 'hardwareRevision': '', 'key': '00:50:56:5d:e5:e0', 'internalBuildId': '12-12', 'lastSyncUp': 1496432895799, 'modelName': 'vEOS', 'unAuthorized': False, 'ipAddress': '192.168.1.20', 'serialNumber': '', 'fqdn': 'veos1', 'bootupTimeStamp': 1491264298.21, 'isMLAGEnabled': 'no', 'complianceCode': '0000', 'memFree': 472976, 'version': '4.17.1F', 'architecture': 'i386', 'deviceInfo': 'Registered', 'complianceIndication': 'NONE', 'type': 'netelement', 'isDANZEnabled': 'no', 'parentContainerId': 'container_13_5776759195930'}
taskCompleted
Signifies if the task created and executed has completed successfully
when action = add or remove, and auto_run = true, and configuration changes bool True
taskCreated
Signifies if a task was created due to configlet changes
when action = add or remove, and auto_run = true or false, and configuration changes bool True
taskExecuted
Signifies if the automation executed the spawned task
when action = add or remove, and auto_run = true, and configuration changes bool True
taskId
The task ID created by CVP because of changes to configlet
when action = add or remove, and auto_run = true or false, and configuration changes string 500
updateConfigletResponse
Response returned from CVP when configlet update is triggered
when action = add or remove and configuration changes string Configlet veos1-server successfully updated and task initiated.

Status

This module is flagged as preview which means that it is not guaranteed to have a backwards compatible interface.

For help in developing on modules, should you be so inclined, please read Community Information & Contributing, Testing Ansible and Developing Modules.

© 2012–2018 Michael DeHaan
© 2018–2019 Red Hat, Inc.
Licensed under the GNU General Public License version 3.
https://docs.ansible.com/ansible/2.4/cv_server_provision_module.html