ansible-nfvis
An Ansible Role for automating Cisco NFVIS
This is a hybrid role that contains the following modules:
- nfvis_system
- nfvis_bridge
- nfvis_network
- nfvis_vlan
- nfvis_depoloyment
- nfvis_package
To use this role, clone it into your roles
directory:
git clone https://github.com/ciscops/ansible-nfvis.git
To load the modules for use in your playbook:
- hosts: nfvis
connection: local
gather_facts: no
roles:
- ansible-nfvis
tasks:
- name: Build Bridges
nfvis_bridge:
host: 1.2.3.4
user: admin
password: cisco
name: service
state: present
Tasks
In addition to the modules, the role can be called to help create packages:
Build Packages
The build-package
task can be called to build the packages that can be uploaded to the NFVIS host with the nfvis_package
module.
- name: Build packages
include_role:
name: ansible-nfvis
tasks_from: build-package
vars:
package_name: asav
package_version: 9.10.1
package_image: asav9101.qcow2
package_template: centos.image_properties.xml.j2
package_name
: The name of the package as referecned in deploymentspackage_version
: The version of the packagepackage_image
: The image with which to build the packagepackage_template
: The template from which the image_properties is derived. This uses the default Ansible search behavior for templates. Sock templates are located inansible-nfvis/tempaltes
.
The build-package
task looks for the image files used to build the packages in the directory specified by nfvis_package_dir
(Default: "{{ playbook_dir }}/packages"
).
It builds the packages in the directory specified by nfvis_temp_dir
(Default: /tmp/nfvis_packages) and stores the packages
in the directory specified in nfvis_package_dir
(Default: "{{ playbook_dir }}/packages"
).
The default values for nfvis_package_dir
, nfvis_temp_dir
, and nfvis_package_dir
are found in ansible-nfvis/defaults/main.yml
.
Note: Since nfvis_deployment inject the config into the deployments, this task does not include any configuration.
Modules
All modules require authentication information for the NFVIS host:
host
: The address of the NFVIS device in which the API can be reacheduser
: The username with which to authenticate to the NFVIS APIpassword
: The password with which to authenticate to the NFVIS API
Get System Facts:
- name: Configure system
nfvis_facts:
host: 1.2.3.4
user: admin
password: cisco
Returns:
- System settings
- CPU usage
- VLANs
- Bridges
- Networks
- Deployments
Configure System Settings:
- name: Configure system
nfvis_system:
host: 1.2.3.4
user: admin
password: cisco
mgmt: 2.3.4.5/24
gateway_ip: 2.3.4.1
hostname: "{{ inventory_hostname }}"
trusted_source:
- 0.0.0.0/0
hostname
: The hostname of the NFVIS host (required)mgmt
: The management IP of the NFVIS host in CIDR notation ordhcp
for DHCP (required)gateway_ip
: The IP address of the gateway of the NFVIS hosttrusted_source
: A list of trusted sources in CIDR notation
Configure VLANs:
The nfvis_vlan
module maintains vlans on the switch:
- nfvis_vlan:
host: 1.2.3.4
user: admin
password: cisco
state: present
vlan_id: 100
vlan_id
: The VLAN ID to add to the NFVIS hoststate
: The state of the VLAN. Can bepresent
to add the VLAN orabsent
to delete the VLAN. (default:present
)
Note: This requires that the NFVIS device contain an embedded switch (e.g. ENCS)
Configure Bridges:
- nfvis_bridge:
host: 1.2.3.4
user: admin
password: cisco
name: service-br
state: present
name
: Name of the bridge (required)state
: The state of the bridge ('present' or 'absent')ports
: List of ports to which the bridge is attachedip
: IP address and netmask of the bridgevlan
: VLAN tagdhcp
: Flag to specify DHCP configuration
Configure Networks:
- nfvis_network:
host: 1.2.3.4
user: admin
password: cisco
name: new-network
bridge: net-bridge
trunk: no
vlan: 100
state: present
-
name
: Name of the network (required) -
state
: The state if the network ('present' or 'absent') -
bridge
: The bridge to which the network is associated -
trunk
: Set network to trunk mode -
sriov
: SR-IOV supported on the network -
native_tagged
: Specifies if the netowrk is tagged or not -
native_vlan
: Specifies a native VLAN. It sets the native characteristics when the interface is in trunk mode. If you do not configure a native VLAN, the default VLAN 1 is used as the native VLAN -
vlan
: Specifies the VLAN ID when the network is in access mode (i.e NOT a trunk)
Deploy VNF:
- nfvis_deployment:
host: 1.2.3.4
user: admin
password: cisco
name: isrv1
state: present
image: isrv
flavor: isrv-small
interfaces:
- network: int-mgmt-net
- network: wan-net
- network: lan-net
bootup_time: 600
port_forwarding:
- proxy_port: 20001
source_bridge: 'wan-br'
config_data:
- dst: iosxe_config.txt
data: "{{ lookup('template', 'iosxe_config.txt.j2') }}"
name
: Name of the deployment (required)state
: The state of the VLAN. Can bepresent
to add the VLAN orabsent
to delete the deployment. (default:present
)image
: The name of the image to use for the deployment (required)flavor
: The name of the flavor to use for the deployment (required)interfaces
: A list of dictionaries specifying the interfaces to create for the VNFnetwork
: The name of the network to attach the interface (required)nicid
: The nic id of the interface. (Default: the index of that element in the list)model
: The model of the deriver to use (defaultvitio
)
bootup_time
: The time to allow the VNF to boot before starting monitoringport_forwarding
: A list of dictionaries specifying which ports to proxy to the VNF (Note: monitoring must be enabled)proxy_port
: The port on the NFVIS device to be proxied to the VNF (required)vnf_port
: The destination port on the VNF (Default: 22)source_bridge
: The bridge on the NFVIS device to attach the proxy (Default: MGMT)protocol
: The protocol of the port to be proxied (defaulttcp
)type
: The type of proxy (defaultssh
)
config_data
: A list of dictionaries defining the configuration data to feed to the deployment via cloud-init:dst
: The name of the file to place in the config drivedata
Upload Packages
- name: Package
nfvis_package:
host: 1.2.3.4
user: admin
password: cisco
file: asav.tar.gz
name: asav
state: present
name
: The name of the packagefile
: The file name of the packagestate
: The state of the VLAN. Can bepresent
to add package orabsent
to delete the package. (default:present
)
License
CISCO SAMPLE CODE LICENSE