Site icon Karneliuk

Role play games with Ansible for Nokia (Alcatel-Lucent) SR OS and Cisco IOS XR

Hello my friend,

Thanks to my friends I have a chance to take part in a project, where we are heavily using Ansible for various tasks in real network. When there are several people working on a joint project, some rules are needed in order playbooks are consistent. We have taken Ansible roles as rules. And I realized that I should have used them for my examples from the very beginning.

1
2
3
4
5
No part of this blogpost could be reproduced, stored in a<br>
retrieval system, or transmitted in any form or by any<br>
means, electronic, mechanical or photocopying, recording,<br>
or otherwise, for commercial purposes without the<br>
prior permission of the author.<br>

Brief description

What are roles? Frankly speaking, for me it was not clear from the very beginning, what it is. I was thanking, probably roles refer to a user type or something similar, like role of the user in configuration of the device based on the privilege level. Well, it was my network background speaking. In reality roles is just a decomposition of the playbook to certain pieces, and structuring them in different folders with certain name conventions. In the official documentations the following info is provided:

– If roles/x/tasks/main.yml exists, tasks listed therein will be added to the play.
– If roles/x/handlers/main.yml exists, handlers listed therein will be added to the play.
– If roles/x/vars/main.yml exists, variables listed therein will be added to the play.
– If roles/x/defaults/main.yml exists, variables listed therein will be added to the play.
– If roles/x/meta/main.yml exists, any role dependencies listed therein will be added to the list of roles (1.3 and later).
– Any copy, script, template or include tasks (in the role) can reference files in roles/x/{files,templates,tasks}/ (dir depends on task) without having to path them relatively or absolutely.

Let’s see how we can use this information to improve our automation scripts

What we are going to test?

We will rebuild the playbook from the article about Ansible as VNF-M to utilise role. If it is possible, some modifications will be done to make usage of those playbooks more usefull.

Software version

The following components are used for the current lab:

See the previous article to get details how to build the lab

Topology

There is no particular topology necessary for this lab, so we will use the same topology as we did in Ansible as VNF-M article:

As we are using Ansible to deploy virtual Nokia (Alcatel-Lucent) VSR and Cisco IOS XRv routers, there are no particular initial configuration files.

Utilizing roles to create playbook

Read the previous article about Ansible as VNF-M to get understanding, what the scope of the activities is.

What we are going to do in the present article is to combine in the single playbook possibility to deploy/undeploy both Nokia (Alcatel-Lucent) VSR and Cisco IOS XRv by adding corresponding keys. So the playbook is to be capable to understand keyword and act properly. Here we go:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
$ cat 108_lab.yml<br>
---<br>
- hosts
: linux<br>
connection
: local<br>
tags
: cisco_on<br>
roles:<br>
- { role
: linux/108_lab, var_vendor: cisco, var_operation: deploy }<br>
- hosts
: linux<br>
connection
: local<br>
tags
: nokia_on<br>
roles:<br>
- { role
: linux/108_lab, var_vendor: nokia, var_operation: deploy  }<br>
- hosts
: linux<br>
connection
: local<br>
tags
: cisco_off<br>
roles:<br>
- { role
: linux/108_lab, var_vendor: cisco, var_operation: undeploy }<br>
- hosts
: linux<br>
connection
: local<br>
tags
: nokia_off<br>
roles:<br>
- { role
: linux/108_lab, var_vendor: nokia, var_operation: undeploy }<br>
...<br>

We have in this playbook four roles, which performs the following operations:

If you don’t mention keyword by the launch, all the tasks will be performed sequentially resulting in zero result, as all VMs are deployed and undeployed. To make use of this playbook, we launch it with certain tag:

1
$ ansible-playbook 108_lab.yml --tags nokia_on

Then it matched against tag field, within each entry and will launch only corresponding entry. You see, our role is located in folder “linux/108_lab”, which is located in “roles”. Besides launching the playbook, we also push some variables to it (var_vendor, var_operation), which are used further for launching proper tasks and opening proper files.

Let’s review the structure of the folders:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
<br>
$ ls -lR roles/linux/108_lab/<br>
roles/linux/108_lab/:<br>
total 0<br>
drwxrwxr-x. 2 aaa aaa 27 Mar 11 18:31 files<br>
drwxrwxr-x. 2 aaa aaa 51 Mar 12 07:58 tasks<br>
drwxrwxr-x. 2 aaa aaa 80 Mar 11 15:13 templates<br>
drwxrwxr-x. 2 aaa aaa 56 Mar 11 18:25 vars<br>
roles/linux/108_lab/files:<br>
total 4<br>
-rwxr-xr-x. 1 aaa aaa 178 Mar 11 18:31 magic_wand.py<br>
roles/linux/108_lab/tasks:<br>
total 12<br>
-rw-rw-r--. 1 aaa aaa 301 Mar 12 07:58 main.yml<br>
-rw-rw-r--. 1 aaa aaa 912 Mar 11 22:14 off.yml<br>
-rw-rw-r--. 1 aaa aaa 2758 Mar 11 22:14 on.yml<br>
roles/linux/108_lab/templates:<br>
total 8<br>
-rwxrwxrwx. 1 aaa aaa 2949 Mar 11 15:12 template-cisco-iosxr-6.1.2.j2<br>
-rwxrwxrwx. 1 aaa aaa 2640 Mar 11 15:13 template-nokia-sros-15.0R7.j2<br>
roles/linux/108_lab/vars:<br>
total 8<br>
-rwxrwxrwx. 1 aaa aaa 1087 Mar 11 18:20 new_vnf_cisco.yml<br>
-rwxrwxrwx. 1 aaa aaa 1399 Mar 11 15:18 new_vnf_nokia.ym<br>

Following guidelines form official Ansible documentation (link), we create 4 folders in our role folder:

Let’s review them!

#1. Tasks

Let’s start straight with the task file, which are loaded by default, which is “main.yml”:

1
2
3
4
5
6
7
8
9
10
11
12
<br>
$ cat roles/linux/108_lab/tasks/main.yml<br>
- name
: READING VNF DATA // {{ var_vendor }}<br>
include_vars:<br>
file
: new_vnf_{{ var_vendor }}.yml<br>
name
: VM1<br>
- name
: PERFORMING ONBOARDING<br>
include_tasks
: on.yml<br>
when
: var_operation == "deploy"<br>
- name
: PERFORMING UNDEPLOYING<br>
include_tasks
: off.yml<br>
when
: var_operation == "undeploy"<br>

The first activity in the tasks imports vendor-dependent variables, by calling file that contains value of “{{ var_vendor }}” value, which is usual operation for parametrisation.

Point out, you don’t need to include absolute or relative path to file. That works for files with variables from “vars” folder in case of roles.

Then depending on operation type, whether we want to deploy or undeploy VM with Nokia (Alcatel-Lucent) VSR or Cisco ISO XRv, we add appropriate tasks. Those files are modifications of “transformer_on.yml” and “transformer_off,yml” we had previously.

For onboarding of VNFs the additional file looks like:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
<br>
$ cat roles/linux/108_lab/tasks/on.yml<br>
- name
: COPYING VM IMAGE TO PROPER DIRECTORY<br>
copy:<br>
src
: "{{ VM1.nfvo.vnfd.vdu.image_path.source }}/default-image-{{ VM1.nfvo.vnfd.vendor }}-{{ VM1.nfvo.vnfd.os }}-{{ VM1.nfvo.vnfd.version }}.qcow2"<br>
dest
: "{{ VM1.nfvo.vnfd.vdu.image_path.destination }}/{{ VM1.nfvo.vnfd.vdu.image_name }}"<br>
become
: yes<br>
- name
: DEFINE VM IN KVM // {{ var_vendor }}<br>
virt:<br>
name
: "{{ VM1.nfvo.vnfd.hostname }}"<br>
command
: define<br>
xml
: "{{ lookup('template', 'template-cisco-iosxr-6.1.2.j2') }}"<br>
become
: yes<br>
when
: var_vendor == "cisco"<br>
- name
: DEFINE VM IN KVM // {{ var_vendor }}<br>
virt:<br>
name
: "{{ VM1.nfvo.vnfd.hostname }}"<br>
command
: define<br>
xml
: "{{ lookup('template', 'template-nokia-sros-15.0R7.j2') }}"<br>
become
: yes<br>
when
: var_vendor == "nokia"<br>
- name
: LAUNCHING {{ VM1.nfvo.vnfd.hostname }} ON KVM<br>
virt:<br>
name
: "{{ VM1.nfvo.vnfd.hostname }}"<br>
state
: running<br>
become
: yes<br>
- name
: UPDATING ANSIBLE HOSTS FOR {{ VM1.nfvo.vnfd.hostname }}<br>
lineinfile:<br>
path
: /etc/ansible/hosts<br>
regexp
: '{{ VM1.nfvo.vnfd.hostname }}'<br>
line
: '{{ VM1.nfvo.vnfd.hostname }}'<br>
insertafter
: '^\[{{ VM1.nfvo.vnfd.vendor }}\]'<br>
become
: yes<br>
- name
: UPDATING LINUX HOSTS FOR {{ VM1.nfvo.vnfd.hostname }}<br>
lineinfile:<br>
path
: /etc/hosts<br>
regexp
: '{% for iface in VM1.nfvo.vnfd.vdu.interfaces %}{% if iface.connection_point == "br0" %}{{ iface.address }}{% endif %}{% endfor %}'<br>
line
: '{% for iface in VM1.nfvo.vnfd.vdu.interfaces %}{% if iface.connection_point == "br0" %}{{ iface.address }}{% endif %}{% endfor %} {{ VM1.nfvo.vnfd.hostname }}'<br>
become
: yes<br>
- name
: WAITING FOR {{ VM1.nfvo.vnfd.hostname }} TO BOOT<br>
pause:<br>
seconds
: "{{ VM1.nfvo.vnfd.vdu.bootup_time }}"<br>
- name
: ONLY FOR {{ VM1.nfvo.vnfd.vendor }} // MAKING ROUTER REACHABLE ON CLI<br>
script
: magic_wand.py<br>
when
: ( VM1.nfvo.vnfd.vendor == "cisco" and VM1.nfvo.vnfd.os == "iosxr" )<br>
- name
: ONLY FOR {{ VM1.nfvo.vnfd.vendor }} // CONFIGURING OOB INTERFACE<br>
telnet:<br>
host
: "{{ VM1.nfvo.vnfd.vdu.console.address }}"<br>
port
: 3517<br>
user
: cisco<br>
password
: cisco<br>
pause
: 1<br>
login_prompt
: "Username: "<br>
prompts:<br>
- "[&gt;|#]"<br>
command:<br>
- configure terminal<br>
- ssh server v2<br>
- ssh server vrf MGMT<br>
- ssh server netconf vrf MGMT<br>
- netconf-yang agent<br>
- ssh<br>
- vrf MGMT<br>
- address-family ipv4 unicast<br>
- interface MgmtEth0/0/CPU0/0<br>
- ipv4 address {% for iface in VM1.nfvo.vnfd.vdu.interfaces %}{% if iface.connection_point == "br0" %}{{ iface.address }}/{{ iface.netmask }}{% endif %}{% endfor %}<br>
- no shutdown<br>
- vrf MGMT<br>
- control-plane<br>
- management-plane<br>
- out-of-band<br>
- vrf MGMT<br>
- interface MgmtEth0/0/CPU0/0<br>
- allow SSH<br>
- allow NETCONF<br>
- commit<br>
- clear<br>
- exit<br>
when
: ( VM1.nfvo.vnfd.vendor == "cisco" and VM1.nfvo.vnfd.os == "iosxr" )<br>

Comparing to previous version, we utilize template for VNF definition in much more elegant way without converting it to YAML. We do it on a cost of creation of two tasks for defining VNF, which compare “var_vendor” value coming from initial call.

One additional change you might spot in the last task (and in the task for updating hosts), where management IPv4 address of VNF is defined through more complex construction than it was previously. In the next sub chapter you will see the difference in variables. The rest of the playbook is the same

Alternatively we can make comparison against “VM1.nfvo.vnfd.vendor” variable.

For dismantling the VNFs we have:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
<br>
$ cat roles/linux/108_lab/tasks/off.yml<br>
- name
: DESTROYING {{ VM1.nfvo.vnfd.hostname }} IN KVM<br>
virt:<br>
name
: "{{ VM1.nfvo.vnfd.hostname }}"<br>
command
: destroy<br>
become
: yes<br>
- name
: UNDEFINING {{ VM1.nfvo.vnfd.hostname }} IN KVM<br>
virt:<br>
name
: "{{ VM1.nfvo.vnfd.hostname }}"<br>
command
: undefine<br>
become
: yes<br>
- name
: DELETING {{ VM1.nfvo.vnfd.hostname }} IMAGE FROM LIBRARY<br>
file:<br>
path
: "{{ VM1.nfvo.vnfd.vdu.image_path.destination }}/{{ VM1.nfvo.vnfd.vdu.image_name }}"<br>
state
: absent<br>
become
: yes<br>
- name
: REMOVING {{ VM1.nfvo.vnfd.hostname }} FROM ANSIBLE HOSTS<br>
lineinfile:<br>
path
: /etc/ansible/hosts<br>
regexp
: '{{ VM1.nfvo.vnfd.hostname }}'<br>
state
: absent<br>
become
: yes<br>
- name
: REMOVING {{ VM1.nfvo.vnfd.hostname }} FROM LINUX HOSTS<br>
lineinfile:<br>
path
: /etc/hosts<br>
regexp
: '{% for iface in VM1.nfvo.vnfd.vdu.interfaces %}{% if iface.connection_point == "br0" %}{{ iface.address }}{% endif %}{% endfor %} {{ VM1.nfvo.vnfd.hostname }}'<br>
state
: absent<br>
become
: yes<br>

There is no changes at all comparing to initial Ansible-playbook, besides changes in the hosts file update.

#2. Vars

As you see in the output of the folder listing previously, we have here our VNF description files, which are used for VNF definition. Here is the output of Nokia (Alcatel-Lucent) VSR definition:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
<br>
$ cat roles/linux/108_lab/vars/new_vnf_nokia.yml<br>
---<br>
nfvo:<br>
vnfd:<br>
hostname
: VSR7<br>
vendor
: nokia<br>
os
: sros<br>
version
: 15.0R7<br>
vdu:<br>
vcpus
: 4<br>
memory_b
: 4194304<br>
disk_size_gb
: 1<br>
image_name
: VSR7-nokia-sros-15.0R7.qcow2<br>
image_path:<br>
source
: ~/temp<br>
destination
: /var/lib/libvirt/images<br>
bootup_time
: 180<br>
license:<br>
file
: sros15.lic<br>
path
: 192.168.1.1<br>
username
: nokia<br>
password
: nokianokia<br>
chassis:<br>
type
: VSR-I<br>
slot:<br>
id
: 0<br>
type
: A<br>
card:<br>
id
: 0<br>
type
: cpm-v<br>
mda1:<br>
id
: 1<br>
type
: m20-v<br>
mda2:<br>
id
: 2<br>
type
: isa-tunnel-v<br>
interfaces:<br>
- id
: 0<br>
physical_interface
: vnet0<br>
network_name
: Management<br>
connection_point
: br0<br>
mac
: 00:A1:00:15:07:00<br>
address
: 192.168.1.107<br>
netmask
: 24<br>
vnic_type
: virtio<br>
- id
: 1<br>
physical_interface
: vnet1<br>
network_name
: Data1<br>
connection_point
: br1<br>
mac
: 00:A1:00:15:07:01<br>
vnic_type
: virtio<br>
- id
: 2<br>
physical_interface
: vnet2<br>
network_name
: Data2<br>
connection_point
: br2<br>
mac
: 00:A1:00:15:07:02<br>
vnic_type
: virtio<br>
console:<br>
address
: 0.0.0.0<br>
port
: 2517<br>

You see that description of interfaces looks different now. Such model is called dictionary in Ansible and is actively used for templates, where same set of fields have different values many times. Just in the next sub chapter will see the advantage of such model.

For Cisco, refer to the original article. The changes regarding interfaces are the same

#3. Templates

Here we have templates that are used for definition of VNFs. That’s actually the same XML files we created in the article about Ansible as VNF-M last time, with updates for interface creation part and IP address definition for BOF. Besides those changes we also have changed the extension from “.xml” to “.j2”:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
$ cat roles/linux/108_lab/templates/template-nokia-sros-15.0R7.j2<br>
&lt;domain type='kvm'&gt;<br>
&lt;name&gt;{{ VM1.nfvo.vnfd.hostname }}&lt;/name&gt;<br>
&lt;uuid&gt;&lt;/uuid&gt;<br>
&lt;memory&gt;{{ VM1.nfvo.vnfd.vdu.memory_b }}&lt;/memory&gt;<br>
&lt;currentMemory&gt;4194304&lt;/currentMemory&gt;<br>
&lt;cpu mode='custom' match='minimum'&gt;<br>
&lt;model&gt;SandyBridge&lt;/model&gt;<br>
&lt;vendor&gt;Intel&lt;/vendor&gt;<br>
&lt;feature policy='require' name='x2apic'/&gt;<br>
&lt;/cpu&gt;<br>
&lt;vcpu current='4'&gt;{{ VM1.nfvo.vnfd.vdu.vcpus }}&lt;/vcpu&gt;<br>
&lt;os&gt;<br>
&lt;type arch='x86_64' machine='rhel6.0.0'&gt;hvm&lt;/type&gt;<br>
&lt;smbios mode='sysinfo'/&gt;<br>
&lt;/os&gt;<br>
&lt;sysinfo type='smbios'&gt;<br>
&lt;system&gt;<br>
&lt;entry name='product'&gt;TIMOS:address={% for iface in VM1.nfvo.vnfd.vdu.interfaces %}{% if iface.connection_point == "br0" %}{{ iface.address }}/{{ iface.netmask }}{% endif %}{% endfor %}@active license-file=ftp://{{ VM1.nfvo.vnfd.vdu.license.username }}:{{ VM1.nfvo.vnfd.vdu.license.password }}@{{ VM1.nfvo.vnfd.vdu.license.path }}/{{ VM1.nfvo.vnfd.vdu.license.file }} slot={{ VM1.nfvo.vnfd.vdu.chassis.slot.type }} chassis={{ VM1.nfvo.vnfd.vdu.chassis.type }} card={{ VM1.nfvo.vnfd.vdu.chassis.slot.card.type }} mda/1={{ VM1.nfvo.vnfd.vdu.chassis.slot.card.mda1.type }} mda/2={{ VM1.nfvo.vnfd.vdu.chassis.slot.card.mda2.type }}&lt;/entry&gt;<br>
&lt;/system&gt;<br>
&lt;/sysinfo&gt;<br>
&lt;clock offset='utc'&gt;<br>
&lt;timer name='pit' tickpolicy='delay'/&gt;<br>
&lt;timer name='rtc' tickpolicy='delay'/&gt;<br>
&lt;/clock&gt;<br>
&lt;devices&gt;<br>
&lt;emulator&gt;/usr/libexec/qemu-kvm&lt;/emulator&gt;<br>
&lt;disk type='file' device='disk'&gt;<br>
&lt;driver name='qemu' type='qcow2' cache='none'/&gt;<br>
&lt;source file='{{ VM1.nfvo.vnfd.vdu.image_path.destination }}/{{ VM1.nfvo.vnfd.vdu.image_name }}'/&gt;<br>
&lt;target dev='hda' bus='virtio'/&gt;<br>
&lt;/disk&gt;<br>
{% for iface in VM1.nfvo.vnfd.vdu.interfaces %}<br>
&lt;interface type='bridge'&gt;<br>
&lt;mac address='{{ iface.mac}}'/&gt;<br>
&lt;source bridge='{{ iface.connection_point}}'/&gt;<br>
&lt;model type='{{ iface.vnic_type}}'/&gt;<br>
&lt;/interface&gt;<br>
{% endfor %}<br>
&lt;console type='tcp'&gt;<br>
&lt;source mode='bind' host='{{ VM1.nfvo.vnfd.vdu.console.address}}' service='{{ VM1.nfvo.vnfd.vdu.console.port}}'/&gt;<br>
&lt;protocol type='{{ VM1.nfvo.vnfd.vdu.console.protocol}}'/&gt;<br>
&lt;target type='virtio' port='0'/&gt;<br>
&lt;/console&gt;<br>
&lt;/devices&gt;<br>
&lt;/domain&gt;<br>

The construct for definition of the interfaces is the traditional “for” cycle from programming, which is very wide distributed for repetitive actions. So we do not need to define explicitly in template the number of interfaces, rather they will be automatically replicated to the number defined in VNF description module.

#4. Files

Here we have just one file, which is used to make Cisco IOS XRv router reachable on console.

Read article about Ansible as VNF-M.

Verification

As all our examples were about Nokia (Alcatel-Lucent) VSR, here we’ll provide example for Cisco IOS XRv. So we deploy it as follows:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
<br>
$ ansible-playbook 108_lab.yml --tags cisco_on<br>
PLAY [linux] ********************************************<br>
TASK [Gathering Facts] **********************************<br>
ok: [localhost]<br>
TASK [linux/108_lab : READING VNF DATA // cisco] ********<br>
ok: [localhost]<br>
TASK [linux/108_lab : PERFORMING ONBOARDING] ************<br>
included: /home/aaa/ansible/roles/linux/108_lab/tasks/on.yml for localhost<br>
TASK [linux/108_lab : COPYING VM IMAGE TO PROPER DIRECTORY] **************<br>
changed: [localhost]<br>
TASK [linux/108_lab : DEFINE VM IN KVM // cisco] ********<br>
changed: [localhost]<br>
TASK [linux/108_lab : DEFINE VM IN KVM // cisco] ********<br>
skipping: [localhost]<br>
TASK [linux/108_lab : LAUNCHING XR7 ON KVM] *************<br>
changed: [localhost]<br>
TASK [linux/108_lab : UPDATING ANSIBLE HOSTS FOR XR7] ***<br>
changed: [localhost]<br>
TASK [linux/108_lab : UPDATING LINUX HOSTS FOR XR7] *****<br>
changed: [localhost]<br>
TASK [linux/108_lab : WAITING FOR XR7 TO BOOT] **********<br>
Pausing for 330 seconds<br>
(ctrl+C then 'C' = continue early, ctrl+C then 'A' = abort)<br>
ok: [localhost]<br>
TASK [linux/108_lab : ONLY FOR cisco // MAKING ROUTER REACHABLE ON CLI] ***********<br>
changed: [localhost]<br>
TASK [linux/108_lab : ONLY FOR cisco // CONFIGURING OOB INTERFACE] *************<br>
changed: [localhost]<br>
TASK [linux/108_lab : PERFORMING UNDEPLOYING] ***********<br>
skipping: [localhost]<br>
PLAY [linux] ********************************************<br>
TASK [Gathering Facts] **********************************<br>
ok: [localhost]<br>
PLAY [linux] ********************************************<br>
TASK [Gathering Facts] **********************************<br>
ok: [localhost]<br>
PLAY [linux] ********************************************<br>
TASK [Gathering Facts] **********************************<br>
ok: [localhost]<br>
PLAY RECAP **********************************************<br>
localhost : ok=14 changed=7 unreachable=0 failed=0<br>

After this Ansible playbook is played we can connect to the newly deployed Cisco IOS XRv:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
<br>
$ ssh cisco@XR7<br>
.<br>
IMPORTANT: READ CAREFULLY<br>
Welcome to the Demo Version of Cisco IOS XRv (the "Software").<br>
The Software is subject to and governed by the terms and conditions<br>
of the End User License Agreement and the Supplemental End User<br>
License Agreement accompanying the product, made available at the<br>
time of your order, or posted on the Cisco website at<br>
www.cisco.com/go/terms (collectively, the "Agreement").<br>
As set forth more fully in the Agreement, use of the Software is<br>
strictly limited to internal use in a non-production environment<br>
solely for demonstration and evaluation purposes. Downloading,<br>
installing, or using the Software constitutes acceptance of the<br>
Agreement, and you are binding yourself and the business entity<br>
that you represent to the Agreement. If you do not agree to all<br>
of the terms of the Agreement, then Cisco is unwilling to license<br>
the Software to you and (a) you may not download, install or use the<br>
Software, and (b) you may return the Software as more fully set forth<br>
in the Agreement.<br>
.<br>
Please login with any configured user/password, or cisco/cisco<br>
.<br>
cisco@xr7's password:<br>
.<br>
RP/0/0/CPU0:ios#<br>

When we don’t need this VNF anymore, we just easily remove it.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
<br>
$ ansible-playbook 108_lab.yml --tags cisco_off<br>
PLAY [linux] ********************************************<br>
TASK [Gathering Facts] **********************************<br>
ok: [localhost]<br>
PLAY [linux] ********************************************<br>
TASK [Gathering Facts] **********************************<br>
ok: [localhost]<br>
PLAY [linux] ********************************************<br>
TASK [Gathering Facts] **********************************<br>
ok: [localhost]<br>
TASK [linux/108_lab : READING VNF DATA // cisco] ********<br>
ok: [localhost]<br>
TASK [linux/108_lab : PERFORMING ONBOARDING] ************<br>
skipping: [localhost]<br>
TASK [linux/108_lab : PERFORMING UNDEPLOYING] ***********<br>
included: /home/aaa/ansible/roles/linux/108_lab/tasks/off.yml for localhost<br>
TASK [linux/108_lab : DESTROYING XR7 IN KVM] ************<br>
ok: [localhost]<br>
TASK [linux/108_lab : UNDEFINING XR7 IN KVM] ************<br>
ok: [localhost]<br>
TASK [linux/108_lab : DELETING XR7 IMAGE FROM LIBRARY] **<br>
changed: [localhost]<br>
TASK [linux/108_lab : REMOVING XR7 FROM ANSIBLE HOSTS] **<br>
changed: [localhost]<br>
TASK [linux/108_lab : REMOVING XR7 FROM LINUX HOSTS] ****<br>
changed: [localhost]<br>
PLAY [linux] ********************************************<br>
TASK [Gathering Facts] **********************************<br>
ok: [localhost]<br>
PLAY RECAP **********************************************<br>
localhost : ok=11 changed=3 unreachable=0 failed=0<br>

That’s it! Now we have more convenient script.
Here are the corresponding Ansbile playbooks: 112_lab.tar

Lessons learned

Never step learning, improving your skills and growing further. Each new thing I’ve learned in Ansible helps to create the automation better, easier and therefore useful. Many thanks to @Nikola.Arnoldi for inviting me to the project, where we do cool stuff using Ansbile and I have possibility to master my skills.

And as previously, many thanks to @Nikita.Makaranka on consulting me for json_query and guiding to proper docs.

Guys, you rock!

Conclusion

Once I was asked by one of my colleagues, why do I use the Ansible automation. He tried to use my playbook, but it was not properly documented, so he needed some my assistance. Well, question is fair enough. Each automation is as good as you can use it, so it must be convenient, easy to understand and reliable. On top it must be good documents, so that someone else besides you (or me) can use it. Usage of roles and group_vars allows to create Ansible playbooks more friendly in terms of portability and therefore usability. Jinja2 templates add flexibility and allow the whole structure (VNF in my case) be defined solely by var files. So… Now I think, this VNF manager is more user friendly, but for sure, there is further room for the improvement. Take care and good bye!

P.S.

If you have further questions or you need help with your networks, I’m happy to assist you, just send me message (https://karneliuk.com/contact/). Also don’t forget to share the article on your social media, if you like it.

Support us





BR,

Anton Karneliuk

Exit mobile version