はじめに
RHELサーバーをPowerVC でデプロイした後、OS の cloud-init の停止と OS の設定状況を確認するスクリプトを作成、実行しました。
ご参考まで。
環境
・PowerVC 2.0.2.1
・デプロイする RHEL サーバー (RHEL8.4, ppc64le, ホスト名 testVM)
実行スクリプト
shell モジュールでの実行が多めです。
after_deploy_check_rhel.yml
---
- hosts: testVM
gather_facts: no
become: yes
vars:
services:
- cloud-init
- cloud-init-local
- cloud-config
- cloud-final
tasks:
- name: 1. Stop cloud-init service
service:
name: "{{ service_name }}"
state: stopped
enabled: no
loop: "{{ services }}"
loop_control:
loop_var: service_name
- name: 2. Setting check
shell: |
export TMPFILE=/tmp/deployvm_check_output.txt
touch $TMPFILE
systemctl -t service | grep cloud >> $TMPFILE
echo "#---------cloud-init.service--------#" >> $TMPFILE
systemctl is-enabled cloud-init >> $TMPFILE
echo "#---------cloud-init-local.service--------#" >> $TMPFILE
systemctl is-enabled cloud-init-local >> $TMPFILE
echo "#---------cloud-config.service--------#" >> $TMPFILE
systemctl is-enabled cloud-config >> $TMPFILE
echo "#---------cloud-final.service--------#" >> $TMPFILE
systemctl is-enabled cloud-final >> $TMPFILE
echo "----------------os-release----------------" >> $TMPFILE
cat /etc/os-release >> $TMPFILE
echo "----------------ip address----------------" >> $TMPFILE
ip addr show >> $TMPFILE
echo "----------------hostname----------------" >> $TMPFILE
hostname >> $TMPFILE
echo "----------------route check----------------" >> $TMPFILE
ip route >> $TMPFILE
echo "----------------mpath check----------------" >> $TMPFILE
ls -l /dev/mappter/mpath* >> $TMPFILE
echo "----------------multipath check----------------" >> $TMPFILE
multipath -ll >> $TMPFILE
echo "----------------cpu check----------------" >> $TMPFILE
cat /proc/cpuinfo >> $TMPFILE
ppc64_cpu --info >> $TMPFILE
echo "----------------memory check----------------" >> $TMPFILE
cat /proc/meminfo >> $TMPFILE
echo "----------------service check----------------" >> $TMPFILE
systemctl -t services>> $TMPFILE
cat $TMPFILE
changed_when: false
register: setting_check
- debug:
var: setting_check.stdout_lines
- name: 3. Delete tmpfile
file:
path: /tmp/deployvm_check_output.txt
state: absent
register: tmpfile_check
- debug:
var: tmpfile_check
実行
$ ansible-playbook after_deploy_check_rhel.yml
PLAY [testVM] ************************************************************************************
TASK [1. Stop cloud-init service] ******************************************************************
ok: [testVM] => (item=cloud-init)
ok: [testVM] => (item=cloud-init-local)
ok: [testVM] => (item=cloud-config)
ok: [testVM] => (item=cloud-final)
TASK [2. Setting check] ****************************************************************************
ok: [testVM]
TASK [debug] ***************************************************************************************
ok: [testVM] => {
"setting_check.stdout_lines": [
"#---------cloud-init.service--------#",
"disabled",
"#---------cloud-init-local.service--------#",
"disabled",
"#---------cloud-config.service--------#",
"disabled",
"#---------cloud-final.service--------#",
"disabled",
"----------------os-release----------------",
"NAME=\"Red Hat Enterprise Linux\"",
"VERSION=\"8.4 (Ootpa)\"",
"ID=\"rhel\"",
"ID_LIKE=\"fedora\"",
"VERSION_ID=\"8.4\"",
"PLATFORM_ID=\"platform:el8\"",
"PRETTY_NAME=\"Red Hat Enterprise Linux 8.4 (Ootpa)\"",
"ANSI_COLOR=\"0;31\"",
"CPE_NAME=\"cpe:/o:redhat:enterprise_linux:8.4:GA\"",
"HOME_URL=\"https://www.redhat.com/\"",
"DOCUMENTATION_URL=\"https://access.redhat.com/documentation/red_hat_enterprise_linux/8/\"",
"BUG_REPORT_URL=\"https://bugzilla.redhat.com/\"",
"",
"REDHAT_BUGZILLA_PRODUCT=\"Red Hat Enterprise Linux 8\"",
"REDHAT_BUGZILLA_PRODUCT_VERSION=8.4",
"REDHAT_SUPPORT_PRODUCT=\"Red Hat Enterprise Linux\"",
"REDHAT_SUPPORT_PRODUCT_VERSION=\"8.4\"",
"----------------ip address----------------",
"1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000",
" link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00",
" inet 127.0.0.1/8 scope host lo",
" valid_lft forever preferred_lft forever",
" inet6 ::1/128 scope host ",
" valid_lft forever preferred_lft forever",
"2: env32: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UNKNOWN group default qlen 1000",
" link/ether fa:c3:d3:07:01:20 brd ff:ff:ff:ff:ff:ff",
" inet xxx.xx.x.xxx/16 brd xxx.xx..255.255 scope global noprefixroute env32",
" valid_lft forever preferred_lft forever",
" inet6 fe80::f8c3:d3ff:fe07:120/64 scope link ",
" valid_lft forever preferred_lft forever",
"3: env33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UNKNOWN group default qlen 1000",
" link/ether fa:c3:d3:07:01:21 brd ff:ff:ff:ff:ff:ff",
" inet xxx.xx.xxx.xxx/16 brd x.xxx.255.255 scope global noprefixroute env33",
" valid_lft forever preferred_lft forever",
" inet6 fe80::f8c3:d3ff:fe07:121/64 scope link ",
" valid_lft forever preferred_lft forever",
"----------------hostname----------------",
"testVM",
"----------------route check----------------",
"default via x.xxx.xxx.x dev env33 proto static metric 101 ",
"x.xxx.0.0/16 dev env33 proto kernel scope link src xxx.xx.xxx.xxx metric 101 ",
"xxx.xx.x.x/16 dev env32 proto kernel scope link src xxx.xx.x.xxx metric 100 ",
"xxx.xx.x.x/16 via xxx.xx..xx.x dev env32 proto static metric 100 ",
"----------------mpath check----------------",
"----------------multipath check----------------",
"mpathb (360050768028083dfd800000000000aec) dm-0 IBM,2145",
"size=50G features='1 queue_if_no_path' hwhandler='1 alua' wp=rw",
"|-+- policy='service-time 0' prio=50 status=active",
"| |- 1:0:0:0 sda 8:0 active ready running",
"| |- 2:0:1:0 sdd 8:48 active ready running",
"| |- 3:0:1:0 sdf 8:80 active ready running",
"| `- 4:0:0:0 sdg 8:96 active ready running",
"`-+- policy='service-time 0' prio=10 status=enabled",
" |- 1:0:1:0 sdb 8:16 active ready running",
" |- 2:0:0:0 sdc 8:32 active ready running",
" |- 3:0:0:0 sde 8:64 active ready running",
" `- 4:0:1:0 sdh 8:112 active ready running",
"----------------cpu check----------------",
"processor\t: 0",
"cpu\t\t: POWER8 (architected), altivec supported",
"clock\t\t: 3891.000000MHz",
"revision\t: 2.1 (pvr 004b 0201)",
"",
"processor\t: 1",
"cpu\t\t: POWER8 (architected), altivec supported",
"clock\t\t: 3891.000000MHz",
"revision\t: 2.1 (pvr 004b 0201)",
"",
"processor\t: 2",
"cpu\t\t: POWER8 (architected), altivec supported",
"clock\t\t: 3891.000000MHz",
"revision\t: 2.1 (pvr 004b 0201)",
"",
"processor\t: 3",
"cpu\t\t: POWER8 (architected), altivec supported",
"clock\t\t: 3891.000000MHz",
"revision\t: 2.1 (pvr 004b 0201)",
"",
"processor\t: 4",
"cpu\t\t: POWER8 (architected), altivec supported",
"clock\t\t: 3891.000000MHz",
"revision\t: 2.1 (pvr 004b 0201)",
"",
"processor\t: 5",
"cpu\t\t: POWER8 (architected), altivec supported",
"clock\t\t: 3891.000000MHz",
"revision\t: 2.1 (pvr 004b 0201)",
"",
"processor\t: 6",
"cpu\t\t: POWER8 (architected), altivec supported",
"clock\t\t: 3891.000000MHz",
"revision\t: 2.1 (pvr 004b 0201)",
"",
"processor\t: 7",
"cpu\t\t: POWER8 (architected), altivec supported",
"clock\t\t: 3891.000000MHz",
"revision\t: 2.1 (pvr 004b 0201)",
"",
"timebase\t: 512000000",
"platform\t: pSeries",
"model\t\t: IBM,8286-42A",
"machine\t\t: CHRP IBM,8286-42A",
"MMU\t\t: Hash",
"Core 0: 0* 1* 2* 3* 4* 5* 6* 7* ",
"----------------memory check----------------",
"MemTotal: 3611584 kB",
"MemFree: 2482112 kB",
"MemAvailable: 2452736 kB",
"Buffers: 14976 kB",
"Cached: 449920 kB",
"SwapCached: 0 kB",
"Active: 196672 kB",
"Inactive: 515264 kB",
"Active(anon): 9600 kB",
"Inactive(anon): 276864 kB",
"Active(file): 187072 kB",
"Inactive(file): 238400 kB",
"Unevictable: 32384 kB",
"Mlocked: 32384 kB",
"SwapTotal: 4247488 kB",
"SwapFree: 4247488 kB",
"Dirty: 384 kB",
"Writeback: 0 kB",
"AnonPages: 282752 kB",
"Mapped: 111936 kB",
"Shmem: 26048 kB",
"KReclaimable: 53888 kB",
"Slab: 314240 kB",
"SReclaimable: 53888 kB",
"SUnreclaim: 260352 kB",
"KernelStack: 3968 kB",
"PageTables: 2624 kB",
"NFS_Unstable: 0 kB",
"Bounce: 0 kB",
"WritebackTmp: 0 kB",
"CommitLimit: 6053248 kB",
"Committed_AS: 666752 kB",
"VmallocTotal: 541165879296 kB",
"VmallocUsed: 0 kB",
"VmallocChunk: 0 kB",
"Percpu: 13824 kB",
"HardwareCorrupted: 0 kB",
"AnonHugePages: 0 kB",
"ShmemHugePages: 0 kB",
"ShmemPmdMapped: 0 kB",
"FileHugePages: 0 kB",
"FilePmdMapped: 0 kB",
"CmaTotal: 0 kB",
"CmaFree: 0 kB",
"HugePages_Total: 0",
"HugePages_Free: 0",
"HugePages_Rsvd: 0",
"HugePages_Surp: 0",
"Hugepagesize: 16384 kB",
"Hugetlb: 0 kB",
"----------------service check----------------"
]
}
TASK [3. Delete tmpfile] ***************************************************************************
changed: [testVM]
TASK [debug] ***************************************************************************************
ok: [testVM] => {
"tmpfile_check": {
"changed": true,
"diff": {
"after": {
"path": "/tmp/deployvm_check_output.txt",
"state": "absent"
},
"before": {
"path": "/tmp/deployvm_check_output.txt",
"state": "file"
}
},
"failed": false,
"path": "/tmp/deployvm_check_output.txt",
"state": "absent"
}
}
PLAY RECAP *****************************************************************************************
testVM : ok=5 changed=1 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0
サービスの停止処理に少し時間がかかりました。
以上です。