Chef検証(3) Chef Client セットアップ① ＠Cisco Nexus9000

## Cisco N9K Guest ShellにChef Clientを導入

- USBにRPMファイルを格納し、物理的にNexusに差しました。
    - サーバにRPMファイルを置いておきSCPしてもOKです。
- NexusからUSBが見えなくなったがフォーマットしたら認識しました。
    - ファイルが全削除されるのでバックアップ要。
- Chef Clientを[Ciscoのサイト](http://www.cisco.com/c/en/us/td/docs/switches/datacenter/nexus9000/sw/7-x/programmability/guide/b_Cisco_Nexus_9000_Series_NX-OS_Programmability_Guide_7x/b_Cisco_Nexus_9000_Series_NX-OS_Programmability_Guide_7x_chapter_01110.html)からダウンロードすると古いバージョンを入れさせられるようです。。。
- 新しいChef Clientは[Chefのサイト](https://downloads.chef.io/chef/stable/12.19.33#nexus)で入手しましょう。ただし、最新Ver(現時点で12.19.36)ではCisco NX-OSが提供されていません。。。


```
switch# format ?
  bootflash:  Format bootflash:
  usb1:       Format usb1:
  usb2:       Format usb2:

This command is going to erase the contents of your usb1:.
Do you want to continue? (yes/no)  [y] y
/etc/rc.d/include/probe_bootdev: line 106: /boot_dev: Permission denied
Formatting usb1:
Formatting completed
switch# switch# format usb1:2:
This command is going to erase the contents of your usb2:.
Do you want to continue? (yes/no)  [y] y
/etc/rc.d/include/probe_bootdev: line 106: /boot_dev: Permission denied
Formatting usb2:
Cannot format usb2: Make sure the drive is inserted.

switch# dir usswitch# dir us
usb1:  usb2:  

switch# switch# dir usb1:
   41373894    Feb 27 15:22:12 2017  chef-12.4.1.cisco+20150826000706-1.nexus5.x
86_64.rpm
   43783906    Mar 01 14:59:30 2017  chef-12.4.1.cisco+20150826204615-1.el7.x86_
64.rpm

Usage for usb1://sup-local
   85172224 bytes used
16256557056 bytes free
16341729280 bytes total

```
- USBに格納したrpmをbootflashにコピー。

```
switch# switch# copy usb1:///chef-12.4.1.cisco+20150826usb1:///chef-12.4.1.cisco+201508?
  usb1:///chef-12.4.1.cisco+20150826000706-1.nexus5.x86_64.rpm  
  usb1:///chef-12.4.1.cisco+20150826204615-1.el7.x86_64.rpm     

switch# copy usb1:///chef-12.4.1.cisco+20150826204615-1.el7.x86_64.rpm bootflash:

Copy progress 1% 442KBCopy progress 2% 884KBCopy progress 3% 1327KBCopy progress 4% 1753KBCopy progress 5% 2195KBCopy progress 6% 2637KBCopy progress 7% 3080KBCopy progress 8% 3506KBCopy progress 9% 3948KBCopy progress 10% 4390KBCopy progress 11% 4816KBCopy progress 12% 5259KBCopy progress 13% 5701KBCopy progress 14% 6144KBCopy progress 15% 6569KBCopy progress 16% 7012KBCopy progress 17% 7454KBCopy progress 18% 7897KBCopy progress 19% 8323KBCopy progress 20% 8765KBCopy progress 21% 9207KBCopy progress 22% 9633KBCopy progress 23% 10076KBCopy progress 24% 10518KBCopy progress 25% 10960KBCopy progress 26% 11386KBCopy progress 27% 11829KBCopy progress 28% 12271KBCopy progress 29% 12697KBCopy progress 30% 13139KBCopy progress 31% 13582KBCopy progress 32% 14024KBCopy progress 33% 14450KBCopy progress 34% 14893KBCopy progress 35% 15335KBCopy progress 36% 15777KBCopy progress 37% 16203KBCopy progress 38% 16646KBCopy progress 39% 17088KBCopy progress 40% 17514KBCopy progress 41% 17956KBCopy progress 42% 18399KBCopy progress 43% 18841KBCopy progress 44% 19267KBCopy progress 45% 19709KBCopy progress 46% 20152KBCopy progress 47% 20594KBCopy progress 48% 21020KBCopy progress 49% 21463KBCopy progress 50% 21905KBCopy progress 51% 22331KBCopy progress 52% 22773KBCopy progress 53% 23216KBCopy progress 54% 23658KBCopy progress 55% 24084KBCopy progress 56% 24526KBCopy progress 57% 24969KBCopy progress 58% 25395KBCopy progress 59% 25837KBCopy progress 60% 26279KBCopy progress 61% 26722KBCopy progress 62% 27148KBCopy progress 63% 27590KBCopy progress 64% 28033KBCopy progress 65% 28475KBCopy progress 66% 28901KBCopy progress 67% 29343KBCopy progress 68% 29786KBCopy progress 69% 30212KBCopy progress 70% 30654KBCopy progress 71% 31096KBCopy progress 72% 31539KBCopy progress 73% 31965KBCopy progress 74% 32407KBCopy progress 75% 32849KBCopy progress 76% 33275KBCopy progress 77% 33718KBCopy progress 78% 34160KBCopy progress 79% 34603KBCopy progress 80% 35028KBCopy progress 81% 35471KBCopy progress 82% 35913KBCopy progress 83% 36356KBCopy progress 84% 36782KBCopy progress 85% 37224KBCopy progress 86% 37666KBCopy progress 87% 38092KBCopy progress 88% 38535KBCopy progress 89% 38977KBCopy progress 90% 39419KBCopy progress 91% 39845KBCopy progress 92% 40288KBCopy progress 93% 40730KBCopy progress 94% 41172KBCopy progress 95% 41598KBCopy progress 96% 42041KBCopy progress 97% 42483KBCopy progress 98% 42909KBCopy progress 99% 43352KBCopy progress 100% 43783KB
Copy complete, now saving to disk (please wait)...
```

- guestshell コマンドにより N9K 内のLinuxにアクセス可能。

```
switch# guestshell
[guestshell@chefn9k ~]$
```

- Bootflashにrpmが見える。

```
[guestshell@chefn9k ~]$ dir /bootflash/
20170227_061436_poap_15827_init.log                lxc
CpuUsage.Log                                       mem_log.txt.old.gz
MemoryLog.65%_usage                                nxos.7.0.3.I4.5.bin
aci-n9000-dk9.11.3.1g.bin                          platform-sdk.cmd
aci-n9000-dk9.12.0.1m.bin                          scripts
auto-s                                             urib_api_log.txt
bios_bootup_scratch_not_cleared                    virt_strg_pool_bf_vdc_1
chef-12.4.1.cisco+20150826204615-1.el7.x86_64.rpm  virtual-instance
disk_log.txt                                       virtual-instance.conf
lost+found
```
- Bootflashからguestshell上のディレクトリにrpmファイルを移動。

```
[root@chefn9k ~]# mkdir /usr/tmp/repo/chef/Packages
[root@chefn9k ~]# cd /usr/tmp/repo/chef/Packages
[root@chefn9k Packages]# cp /bootflash// chef-12.4.1.cisco+20150826204615-1.el7.x8 6_64.rpm /usr/tmp/repo/chef/Packages/
[guestshell@chefn9k ~]$ ls -la /usr/tmp/repo/chef/Packages/
total 42760
drwxr-xr-x 2 root root       60 Mar  1 07:18 .
drwxr-xr-x 3 root root       60 Mar  1 07:18 ..
-rw-r--r-- 1 root root 43783906 Mar  1 07:18 chef-12.4.1.cisco+20150826204615-1.el7.x86_64.rpm

```

- インストール。

```
[root@chefn9k Packages]# rpm -ivh chef-12.4.1.cisco+20150826204615-1.el7.x86_64. rpm
Preparing...                                                            (100%)#                                 (100%)##                                (100%)###                               (100%)####                              (100%)#####                             (100%)######                            (100%)#######                           (100%)########                          (100%)#########                         (100%)##########                        (100%)###########                       (100%)############                      (100%)#############                     (100%)##############                    (100%)###############                   (100%)################                  (100%)#################                 (100%)##################                (100%)###################               (100%)####################              (100%)#####################             (100%)######################            (100%)#######################           (100%)########################          (100%)#########################         (100%)##########################        (100%)###########################       (100%)############################      (100%)#############################     (100%)##############################    (100%)###############################   (100%)################################  (100%)################################# (100%)################################# [100%]
Updating / installing...
   1:chef-12.4.1.cisco+20150826204615-                                  (  1%)#                                 (  4%)##                                (  7%)###                               ( 10%)####                              ( 13%)#####                             ( 16%)######                            ( 19%)#######                           ( 22%)########                          ( 25%)#########                         ( 28%)##########                        ( 31%)###########                       ( 34%)############                      ( 37%)#############                     ( 40%)##############                    ( 43%)###############                   ( 46%)################                  ( 49%)#################                 ( 51%)##################                ( 54%)###################               ( 57%)####################              ( 60%)#####################             ( 63%)######################            ( 66%)#######################           ( 69%)########################          ( 72%)#########################         ( 75%)##########################        ( 78%)###########################       ( 81%)############################      ( 84%)#############################     ( 87%)##############################    ( 90%)###############################   ( 93%)################################  ( 96%)################################# ( 99%)################################# [100%]
Thank you for installing Chef!
```