[AIX] AIX サーバーをPowerVC で デプロイした後のcloud-init 停止, OS設定確認を ksh で実行

#### はじめに


AIX サーバーをPowerVC でデプロイした後、OS の cloud-init の停止と OS の設定状況を確認するスクリプトを作成、実行しました。
ご参考まで。


RHEL 版は以下で確認しています。

https://qiita.com/c_u/items/c1867b9c3777d2cd0535

---

#### 環境


・PowerVC 2.0.2.1
・デプロイする AIX サーバー (AIX 7.3TL0SP1, ホスト名 testaix73)


---

#### 実行スクリプト

スクリプトでは　[PowerVC 2.0 導入、運用ガイド](https://ibm.ent.box.com/s/tb34vtxrgg14ty6xxrg4hza5o4p6f23y) の p57 にあるcloud-init のリンク削除ととAIXの基本設定確認しています。



```aix_deploycheck.ksh
#!/bin/ksh

export FILE1="./deploycheck_`hostname`.txt"

touch $FILE1

##################### 1. oslevel ######################

echo "----------- oslevel --------------"  >> $FILE1
echo " "  >> $FILE1
oslevel -s >> $FILE1
echo " "  >> $FILE1

##################### 2. hostname #####################

echo "----------- hostname --------------"  >> $FILE1
echo " "  >> $FILE1
hostname >> $FILE1

echo " "  >> $FILE1

##################### 3. network #####################

echo "----------- netstat -in --------------"  >> $FILE1
echo " "  >> $FILE1
netstat -in >> $FILE1

echo " "  >> $FILE1
echo " "  >> $FILE1

echo "----------- ifconfig --------------"  >> $FILE1
echo " "  >> $FILE1
ifconfig -a >> $FILE1

echo " "  >> $FILE1
echo " "  >> $FILE1

echo "----------- netstat -rn  --------------"  >> $FILE1
echo " "  >> $FILE1
netstat -rn >> $FILE1

echo " "  >> $FILE1
echo " "  >> $FILE1


##################### 4. lparstat #####################

echo "----------- lparstat  --------------"  >> $FILE1
echo " "  >> $FILE1
lparstat -i  >> $FILE1

echo " "  >> $FILE1
echo " "  >> $FILE1

####################### 5. path #######################

echo "----------- lspath  --------------"  >> $FILE1
echo " "  >> $FILE1
lspath  >> $FILE1
echo " "  >> $FILE1
echo " "  >> $FILE1

echo "----------- fcs check  --------------"  >> $FILE1
echo " "  >> $FILE1

export myfcslist=`cd /proc/sys/adapter/fc ; ls -d fcs*`
for i in $myfcslist
do
echo $i
cat /proc/sys/adapter/fc/$i/hostinfo
echo
done >> $FILE1
echo " "  >> $FILE1

##################### 6. ethernet #####################

echo "----------- ethernet  --------------"  >> $FILE1
echo " "  >> $FILE1
lsdev | grep ent | grep Ethernet  >> $FILE1

echo " "  >> $FILE1

lscfg -vl ent0  >> $FILE1

echo " "  >> $FILE1

lscfg -vl ent1  >> $FILE1

echo " "  >> $FILE1

lscfg -vl ent2  >> $FILE1

echo " "  >> $FILE1
echo " "  >> $FILE1

################## 7. clouddev, ghostdev ###############


echo "----------- ghostdev  --------------"  >> $FILE1
echo " "  >> $FILE1
lsattr -El sys0 | grep dev  >> $FILE1
lsattr -El sys0 -a ghostdev  >> $FILE1

echo " "  >> $FILE1

chdev -l sys0 -a clouddev=0 >> /dev/null
chdev -l sys0 -a ghostdev=0 >> /dev/null

echo " "  >> $FILE1

echo "--- after ---" >> $FILE1

lsattr -El sys0 | grep dev  >> $FILE1
lsattr -El sys0 -a ghostdev  >> $FILE1

echo " "  >> $FILE1
echo " "  >> $FILE1


###################### 8. prtconf ######################

echo "----------- prtconf  --------------"  >> $FILE1
echo " "  >> $FILE1
prtconf  >> $FILE1

echo " "  >> $FILE1
echo " "  >> $FILE1

################## 9. cloud-init link ##################


echo "----------- remove cloud-init link  --------------"  >> $FILE1

echo "--- before remove ---" >> $FILE1
echo " "  >> $FILE1
ls -l /etc/rc.d/rc2.d/ >> $FILE1

echo " "  >> $FILE1

rm /etc/rc.d/rc2.d/S01cloud-init-local >> $FILE1 
rm /etc/rc.d/rc2.d/S02cloud-init >> $FILE1
rm /etc/rc.d/rc2.d/S03cloud-config >> $FILE1
rm /etc/rc.d/rc2.d/S04cloud-final >> $FILE1

echo " "  >> $FILE1

echo "--- after remove ---" >> $FILE1
echo " "  >> $FILE1
ls -l /etc/rc.d/rc2.d/ >> $FILE1


echo " "  >> $FILE1
##########################################################
```


---
#### 実行・確認

サーバーにスクリプトを配置

```
# chmod 755 ./aix_deploycheck.ksh
# ls -l ./aix_deploycheck.ksh
-rwxr-xr-x    1 root     system         3187 Oct 27 23:50 ./aix_deploycheck.ksh
```

実行

```
# time ./aix_deploycheck.ksh

real    0m2.27s
user    0m0.08s
sys     0m0.09s
#
```

数秒で完了しました。


実行結果を記載した "deploycheck_testaix73.txt" というファイルが作成されています。

```
# ls -l deploy*
-rw-r--r--    1 root     system        20068 Oct 28 00:01 deploycheck_testaix73.txt
#
```


確認

```
# cat deploycheck_testaix73.txt
----------- oslevel --------------

7300-00-01-2148

----------- hostname --------------

testaix73

----------- netstat -in --------------

Name   Mtu   Network     Address                 Ipkts     Ierrs        Opkts     Oerrs  Coll
en0    9000  link#2      fa.49.65.4f.85.20             1055     0             1730     0     0
en0    9000  192.168.168 192.168.168.xx               1055     0             1730     0     0
en1    9000  link#3      fa.49.65.4f.85.21               82     0                4     0     0
en1    9000  172.16.100  172.16.100.xxx                 82     0                4     0     0
en2    1500  link#4      aa.e8.a.d0.57.e3              204     0              249     0     0
en2    1500  0           0.0.0.0                       204     0              249     0     0
en2    1500  fe80::a8e8:aff:fed0:57e3                  204     0              249     0     0
sit0   1480  link#5      0.0.0.0                         0     0                0     0     0
sit0   1480  ::                                          0     0                0     0     0
lo0    16896 link#1                                    302     0              302     0     0
lo0    16896 127         127.0.0.1                     302     0              302     0     0
lo0    16896 ::1%1                                     302     0              302     0     0


----------- ifconfig --------------

en0: flags=1e084863,81cc0<UP,BROADCAST,NOTRAILERS,RUNNING,SIMPLEX,MULTICAST,GROUPRT,64BIT,CHECKSUM_OFFLOAD(ACTIVE),LARGESEND,CHAIN>
        inet 192.168.168.xx netmask 0xfffffff8 broadcast 192.168.168.39
         tcp_sendspace 262144 tcp_recvspace 262144 rfc1323 1
en1: flags=1e084863,81cc0<UP,BROADCAST,NOTRAILERS,RUNNING,SIMPLEX,MULTICAST,GROUPRT,64BIT,CHECKSUM_OFFLOAD(ACTIVE),LARGESEND,CHAIN>
        inet 172.16.100.xxx netmask 0xffffff00 broadcast 172.16.100.255
         tcp_sendspace 262144 tcp_recvspace 262144 rfc1323 1
en2: flags=1e084863,81cc0<UP,BROADCAST,NOTRAILERS,RUNNING,SIMPLEX,MULTICAST,GROUPRT,64BIT,CHECKSUM_OFFLOAD(ACTIVE),LARGESEND,CHAIN>
        inet6 fe80::a8e8:aff:fed0:57e3/64
         tcp_sendspace 262144 tcp_recvspace 262144 rfc1323 1
sit0: flags=8100041<UP,RUNNING,LINK0>
        inet6 ::/96
lo0: flags=e08084b,c0<UP,BROADCAST,LOOPBACK,RUNNING,SIMPLEX,MULTICAST,GROUPRT,64BIT,LARGESEND,CHAIN>
        inet 127.0.0.1 netmask 0xff000000 broadcast 127.255.255.255
        inet6 ::1%1/128
         tcp_sendspace 131072 tcp_recvspace 131072 rfc1323 1


----------- netstat -rn  --------------

Routing tables
Destination        Gateway           Flags   Refs     Use  If   Exp  Groups

Route tree for Protocol Family 2 (Internet):
default            192.168.168.yy    UG        4      1725 en0      -      -
127/8              127.0.0.1         U         4       260 lo0      -      -
172.16.100.0       172.16.100.xxx    UHSb      0         0 en1      -      -   =>
172.16.100/24      172.16.100.xxx    U         0         0 en1      -      -
172.16.100.xxx     127.0.0.1         UGHS      0         0 lo0      -      -
172.16.100.255     172.16.100.xxx    UHSb      0         0 en1      -      -
192.168.168.32     192.168.168.xx    UHSb      0         0 en0      -      -   =>
192.168.168.32/29  192.168.168.xx    U         0         0 en0      -      -
192.168.168.xx     127.0.0.1         UGHS      0         0 lo0      -      -
192.168.168.39     192.168.168.xx    UHSb      0         0 en0      -      -

Route tree for Protocol Family 24 (Internet v6):
::/96              0.0.0.0           UC        0         0 sit0     -      -   =>
default            link#4            UC        0         0 en2      -      -
::1%1              ::1%1             UH        1        21 lo0      -      -
fe80::/64          link#4            UCX       0         0 en2      -      -
fe80::4405:7bff:fe9e:4809 46:5:7b:9e:48:9   UHXLW     0       130 en2      -      -
fe80::a8e8:aff:fed0:57e3                   UHXLWl    0         0 lo0      -      -
ff01::%1/16        ::1               U         0         0 lo0      -      -
ff02::/16          fe80::a8e8:aff:fed0:57e3 U         0        30 en2      -      -
ff02::16%1         link#4            UHLW      0         2 en2      -      -
ff11::%1/16        ::1               U         0         0 lo0      -      -
ff12::/16          fe80::a8e8:aff:fed0:57e3 U         0         0 en2      -      -


----------- lparstat  --------------

Node Name                                  : testaix73
Partition Name                             : testAIX73-40297f9f-0000d69f
Partition Number                           : 21
Type                                       : Shared-SMT-8
Mode                                       : Uncapped
Entitled Capacity                          : 0.25
Partition Group-ID                         : 32789
Shared Pool ID                             : 0
Online Virtual CPUs                        : 1
Maximum Virtual CPUs                       : 5
Minimum Virtual CPUs                       : 1
Online Memory                              : 2048 MB
Maximum Memory                             : 16384 MB
Minimum Memory                             : 2048 MB
Variable Capacity Weight                   : 128
Minimum Capacity                           : 0.25
Maximum Capacity                           : 2.00
Capacity Increment                         : 0.01
Maximum Physical CPUs in system            : 20
Active Physical CPUs in system             : 20
Active CPUs in Pool                        : 20
Shared Physical CPUs in system             : 20
Maximum Capacity of Pool                   : 2000
Entitled Capacity of Pool                  : 1500
Unallocated Capacity                       : 0.00
Physical CPU Percentage                    : 25.00%
Unallocated Weight                         : 0
Memory Mode                                : Dedicated
Total I/O Memory Entitlement               : -
Variable Memory Capacity Weight            : -
Memory Pool ID                             : -
Physical Memory in the Pool                : -
Hypervisor Page Size                       : -
Unallocated Variable Memory Capacity Weight: -
Unallocated I/O Memory entitlement         : -
Memory Group ID of LPAR                    : -
Desired Virtual CPUs                       : 1
Desired Memory                             : 2048 MB
Desired Variable Capacity Weight           : 128
Desired Capacity                           : 0.25
Target Memory Expansion Factor             : -
Target Memory Expansion Size               : -
Power Saving Mode                          : Dynamic Power Savings (Favor Performance)
Sub Processor Mode                         : -


----------- lspath  --------------

Enabled hdisk0 fscsi0
Enabled hdisk0 fscsi0
Enabled hdisk0 fscsi1
Enabled hdisk0 fscsi1
Enabled hdisk0 fscsi2
Enabled hdisk0 fscsi2
Enabled hdisk0 fscsi3
Enabled hdisk0 fscsi3


----------- fcs check  --------------

fcs0
VFC client adapter name                   : fcs0
Host partition name  (VIOS)               : VIOS1
VFC host adapter name                     : vfchost0
VFC host adapter location code            : U9009.22A.78XXXXX-V21-C5-T1
FC adapter name on VIOS                   : fcs3
FC adapter location code  on VIOS         : Uxxx.001.xxxxxxx-P2-C2-T1

fcs1
VFC client adapter name                   : fcs1
Host partition name  (VIOS)               : VIOS2
VFC host adapter name                     : vfchost0
VFC host adapter location code            : U9009.22A.78XXXXX-V21-C7-T1
FC adapter name on VIOS                   : fcs1
FC adapter location code  on VIOS         : Uxxx.001.xxxxxxx-P2-C5-T1

fcs2
VFC client adapter name                   : fcs2
Host partition name  (VIOS)               : VIOS1
VFC host adapter name                     : vfchost1
VFC host adapter location code            : U9009.22A.78XXXXX-V21-C8-T1
FC adapter name on VIOS                   : fcs1
FC adapter location code  on VIOS         : Uxxx.001.xxxxxxx-P1-C2-T1

fcs3
VFC client adapter name                   : fcs3
Host partition name  (VIOS)               : VIOS2
VFC host adapter name                     : vfchost1
VFC host adapter location code            : U9009.22A.78XXXXX-V21-C9-T1
FC adapter name on VIOS                   : fcs3
FC adapter location code  on VIOS         : Uxxx.001.xxxxxxx-P1-C2-T1


----------- ethernet  --------------

ent0       Available             Virtual I/O Ethernet Adapter (l-lan)
ent1       Available             Virtual I/O Ethernet Adapter (l-lan)
ent2       Available             Virtual I/O Ethernet Adapter (l-lan)

  ent0             U9009.22A.78XXXXX-V21-C2-T1  Virtual I/O Ethernet Adapter (l-lan)

        Network Address.............FA49654F8520
        Displayable Message.........Virtual I/O Ethernet Adapter (l-lan)
        Hardware Location Code......U9009.22A.78XXXXX-V21-C2-T1


  ent1             U9009.22A.78XXXXX-V21-C3-T1  Virtual I/O Ethernet Adapter (l-lan)

        Network Address.............FA49654F8521
        Displayable Message.........Virtual I/O Ethernet Adapter (l-lan)
        Hardware Location Code......U9009.22A.78XXXXX-V21-C3-T1


  ent2             U9009.22A.78XXXXX-V21-C4-T1  Virtual I/O Ethernet Adapter (l-lan)

        Network Address.............AAE80AD057E3
        Displayable Message.........Virtual I/O Ethernet Adapter (l-lan)
        Hardware Location Code......U9009.22A.78XXXXX-V21-C4-T1



----------- ghostdev  --------------

clouddev        1                                    Recreate ODM devices on next boot                   True
ghostdev        0                                    Recreate ODM devices on system change / modify PVID True
ghostdev 0 Recreate ODM devices on system change / modify PVID True


--- after ---
clouddev        0                                    Recreate ODM devices on next boot                   True
ghostdev        0                                    Recreate ODM devices on system change / modify PVID True
ghostdev 0 Recreate ODM devices on system change / modify PVID True


----------- prtconf  --------------

System Model: IBM,9009-22A
Machine Serial Number: 78XXXXX
Processor Type: PowerPC_POWER9
Processor Implementation Mode: POWER 9
Processor Version: PV_9_Compat
Number Of Processors: 1
Processor Clock Speed: 2500 MHz
CPU Type: 64-bit
Kernel Type: 64-bit
LPAR Info: 21 testAIX73-40297f9f-0000d69f
Memory Size: 2048 MB
Good Memory Size: 2048 MB
Platform Firmware level: VL950_099
Firmware Version: IBM,FW950.40 (VL950_099)
Console Login: enable
Auto Restart: true
Full Core: false
NX Crypto Acceleration: Capable and Enabled
In-Core Crypto Acceleration: Capable, but not Enabled

Network Information
        Host Name: testaix73
        IP Address: 192.168.168.xx
        Sub Netmask: 255.255.255.248
        Gateway: 192.168.168.yy
        Name Server:
        Domain Name:

Paging Space Information
        Total Paging Space: 512MB
        Percent Used: 2%

Volume Groups Information
==============================================================================
Active VGs
==============================================================================
rootvg:
PV_NAME           PV STATE          TOTAL PPs   FREE PPs    FREE DISTRIBUTION
hdisk0            active            639         202         126..69..00..00..07
==============================================================================

INSTALLED RESOURCE LIST

The following resources are installed on the machine.
+/- = Added or deleted from Resource List.
*   = Diagnostic support not available.

  Model Architecture: chrp
  Model Implementation: Multiple Processor, PCI bus

+ sys0                                                               System Object
+ sysplanar0                                                         System Planar
* vio0                                                               Virtual I/O Bus
* vscsi0           U9009.22A.78XXXXX-V21-C6-T1                       Virtual SCSI Client Adapter
* cd0              U9009.22A.78XXXXX-V21-C6-T1-L8100000000000000     Virtual SCSI Optical Served by VIO Server
* ent2             U9009.22A.78XXXXX-V21-C4-T1                       Virtual I/O Ethernet Adapter (l-lan)
* ent1             U9009.22A.78XXXXX-V21-C3-T1                       Virtual I/O Ethernet Adapter (l-lan)
* ent0             U9009.22A.78XXXXX-V21-C2-T1                       Virtual I/O Ethernet Adapter (l-lan)
* vsa0             U9009.22A.78XXXXX-V21-C0                          LPAR Virtual Serial Adapter
* vty0             U9009.22A.78XXXXX-V21-C0-L0                       Asynchronous Terminal
+ fcs0             U9009.22A.78XXXXX-V21-C5-T1                       Virtual Fibre Channel Client Adapter
* fscsi0           U9009.22A.78XXXXX-V21-C5-T1                       FC SCSI I/O Controller Protocol Device
* hdisk0           U9009.22A.78XXXXX-V21-C5-T1-W50050768101357B5-L0  MPIO IBM 2076 FC Disk
* sfwcomm0         U9009.22A.78XXXXX-V21-C5-T1-W0-L0                 Fibre Channel Storage Framework Comm
+ fcs1             U9009.22A.78XXXXX-V21-C7-T1                       Virtual Fibre Channel Client Adapter
* fscsi1           U9009.22A.78XXXXX-V21-C7-T1                       FC SCSI I/O Controller Protocol Device
* sfwcomm1         U9009.22A.78XXXXX-V21-C7-T1-W0-L0                 Fibre Channel Storage Framework Comm
+ fcs2             U9009.22A.78XXXXX-V21-C8-T1                       Virtual Fibre Channel Client Adapter
* fscsi2           U9009.22A.78XXXXX-V21-C8-T1                       FC SCSI I/O Controller Protocol Device
* sfwcomm2         U9009.22A.78XXXXX-V21-C8-T1-W0-L0                 Fibre Channel Storage Framework Comm
+ fcs3             U9009.22A.78XXXXX-V21-C9-T1                       Virtual Fibre Channel Client Adapter
* fscsi3           U9009.22A.78XXXXX-V21-C9-T1                       FC SCSI I/O Controller Protocol Device
* sfwcomm3         U9009.22A.78XXXXX-V21-C9-T1-W0-L0                 Fibre Channel Storage Framework Comm
+ L2cache0   
+ 

```



---


便宜上スクリプトで作成していました。
Ansible化はスクリプトの内容をshellモジュールで記載することで可能です。



以上です。