Using Chef for Configuring Cisco IOS XR
Chef is an open-source IT automation tool that you can use to install, configure, and deploy various applications natively on Cisco IOS XR.
To use Chef, you need the following components:
-
Chef Client RPM Version 12.5, or later for Cisco IOS XR 6.0
-
Chef Server Version 12.4, or higher
-
Applications that are compatible with the Wind River Linux 7 environment of IOS XR
-
Package Resource
-
File Resource
-
Service Resource
Topic |
Link |
Chef Software, Inc. |
|
Chef Overview |
|
Package Resource Reference |
|
File Resource Reference |
|
Service Resource Reference |
|
Chef Server Reference |
|
Chef Client for Native XR Environment |
Installing and Configuring the Chef Client
This section describes the procedure for installing the Chef Client on IOS XR.
Prerequisites
Ensure that the following requirements are met before you proceed with installation:
-
Your workstation is set up with the Chef repository and the Chef Development Kit.
-
Chef Server Version 12.4, or higher is installed and accessible from your Linux box.
-
The Chef Server identification files are available.
-
You have the right name server and domain name entries configured in the Linux environment (
/etc/resolv.conf
). -
The router is using a valid NTP server.
Configuration Procedure
To install and configure the Chef Client on IOS XR, follow these steps:
-
From your Linux box, access the IOS XR console through SSH, and log in.
cisco@host:~$ ssh root@192.168.122.188 root@192.168.122.188's password: RP/0/RP0/CPU0:ios#
You have entered the IOS XR prompt.
-
Enter the third-party network namespace or global VRF, depending on the version of Cisco IOS XR you are using in your network.
You can verify whether you are in the namespace by viewing the interfaces, as shown here:
/* If you are using Cisco IOS XR Version 6.0.0, run the following command */ RP/0/RP0/CPU0:ios# run ip netns exec tpnns bash /* If you are using Cisco IOS XR Version 6.0.2 or higher, run the following command */ RP/0/RP0/CPU0:ios# bash [xr-vm_node0_RP0_CPU0:~]$ ifconfig Gi0_0_0_0 Link encap:Ethernet HWaddr 52:46:04:87:19:3c inet addr:192.164.168.10 Mask:255.255.255.0 inet6 addr: fe80::5046:4ff:fe87:193c/64 Scope:Link UP RUNNING NOARP MULTICAST MTU:1514 Metric:1 RX packets:0 errors:0 dropped:0 overruns:0 frame:0 TX packets:3 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:0 (0.0 B) TX bytes:210 (210.0 B) Mg0_RP0_CPU0_0 Link encap:Ethernet HWaddr 52:46:12:7a:88:41 inet addr:192.168.122.197 Mask:255.255.255.0 inet6 addr: fe80::5046:12ff:fe7a:8841/64 Scope:Link UP RUNNING NOARP MULTICAST MTU:1514 Metric:1 RX packets:0 errors:0 dropped:0 overruns:0 frame:0 TX packets:3 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:0 (0.0 B) TX bytes:210 (210.0 B) fwd_ew Link encap:Ethernet HWaddr 00:00:00:00:00:0b inet6 addr: fe80::200:ff:fe00:b/64 Scope:Link UP RUNNING NOARP MULTICAST MTU:1500 Metric:1 RX packets:0 errors:0 dropped:0 overruns:0 frame:0 TX packets:2 errors:0 dropped:1 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:0 (0.0 B) TX bytes:140 (140.0 B) fwdintf Link encap:Ethernet HWaddr 00:00:00:00:00:0a inet6 addr: fe80::200:ff:fe00:a/64 Scope:Link UP RUNNING NOARP MULTICAST MTU:1482 Metric:1 RX packets:0 errors:0 dropped:0 overruns:0 frame:0 TX packets:2 errors:0 dropped:1 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:0 (0.0 B) TX bytes:140 (140.0 B) lo Link encap:Local Loopback inet addr:127.0.0.1 Mask:255.0.0.0 inet6 addr: ::1/128 Scope:Host UP LOOPBACK RUNNING MTU:1500 Metric:1 RX packets:0 errors:0 dropped:0 overruns:0 frame:0 TX packets:0 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:0 (0.0 B) TX bytes:0 (0.0 B) lo:0 Link encap:Local Loopback inet addr:1.1.1.1 Mask:255.255.255.255 UP LOOPBACK RUNNING MTU:1500 Metric:1
-
(Optional) Configure a proxy server (
http_proxy
,https_proxy
) as needed.http_proxy=http://proxy.youtube.com:8080 https_proxy=https://proxy.youtube.com:8080
-
Install the Chef Client.
[xr-vm_node0_RP0_CPU0:~]$ yum install https://chef.io/chef/install.sh
The Chef install.sh script automatically determines the latest version of the Chef Client RPM for installation.
-
Copy the
validation.pem
file from the Chef server to/etc/chef/validation.pem
-
Edit the Chef Client configuration file at
/etc/chef/client.rb
with Chef Server identification and Client settings.validation_client_name 'chef-validator' chef_server_url 'https://my_chef_server.youtube.com/organizations/chef' node_name 'n3k.youtube.com' # "This" client device. cookbook_sync_threads 5 # necessary for small memory switches (4G or less) interval 30 # client-run interval; remove for "never"
-
Run the Chef Client.
[xr-vm_node0_RP0_CPU0:~]$ chef-client
Note
To run the Client once, use the chef-client --once command. For more information, see the Chef documentation at https://docs.chef.io/chef_client.html
The Chef Client is successfully installed on IOS XR.
Creating a Chef Cookbook with Recipes
A Chef cookbook, loaded with Chef recipes, can be created on your Linux workstation, and copied to the Chef server. After you install the Chef client on IOS XR, the cookbook with recipes can be downloaded from the Chef server, and used while running the client.
Prerequisites
Ensure the following requirements are met before you proceed:
-
You have access to the application package compatible with the native IOS XR environment.
-
Target application package is hosted on an accessible repository or downloaded to a boot flash.
Configuration Procedure
Use the following
procedure to create a Chef recipe that starts the
bootlogd
service, and installs iPerf on IOS XR:
-
Create a cookbook on your Linux workstation by using the corresponding knife command.
knife cookbook create cisco-network-chef-cookbook
-
Create the Chef recipe file to install iPerf, and add it to the cookbook.
The Chef recipe must be created in the
cisco-network-chef-cookbook/recipes/
directory. For it to be loaded automatically by the Chef Client, the Chef recipe must be named asdefault.rb
.# # Recipe:: demo_default_providers # # Copyright (c) 2015 The Authors, All Rights Reserved. package = 'iperf-2.0.5-r0.0.core2_64.rpm' service = 'bootlogd' remote_file "/#{package}" do source "http://10.105.247.73/wrl7_yum_repo/#{package}" action :create end yum_package "#{package}" do source "/#{package}" action :install end service "#{service}" do action :start end
-
Access the Chef Server from your Linux workstation and upload the cookbook to the server.
-
Log into the IOS XR shell, and run the Chef Client to load and execute the cookbook.
[xr-vm_node0_RP0_CPU0:~]$chef-client
The iperf RPM is installed on IOS XR.
For additional details on the Chef Client, refer to https://docs.chef.io/chef_client.html