私はJenkinsを使用して仮想アプライアンスの導入を自動化しています。最初のステップは、KVMに標準のCentOS 7最小限のVMを構築することです。KVMにゲストをデプロイするためのビルド
ISOとキックスタートファイルがある
#!/bin/bash
#Variables
diskpath="/var/lib/libvirt/images/"
buildname=$(date +"%m-%d-%y-%H-%M")
vmextension=".dsk"
#Change to images directory
cd /var/lib/libvirt/images/
#Deploy VM with with kickstart file
sudo virt-install \
--name=$buildname \
--nographics \
--hvm \
--virt-type=kvm \
--file=$diskpath$buildname$vmextension \
--file-size=20 \
--nonsparse \
--vcpu=2 \
--ram=2048 \
--network bridge=br0 \
--os-type=linux \
--os-variant=generic \
--location=http://0.0.0.0/iso/ \
--initrd-inject /var/lib/libvirt/images/autobuild-ks.cfg \
--extra-args="ks=http://0.0.0.0/ks/autobuild-ks.cfg console=ttyS0"
(私はセキュリティ上の目的のために変更されているIPアドレス):私は、KVMマシン上でローカルに実行しているときに動作し、このタスクを実行するために、短いbashスクリプトを書きました別のサーバーに格納されており、このスクリプトを動作させるためにhttpでアクセスすることができます。明らかにするために、スクリプトは機能します。
私が問題にするのは、このスクリプトをJenkinsにビルドステップとして入れると、スクリプトが動作することです。ただし、OSがインストールされ、kvmゲストがシャットダウンプロセスを開始した後は、最後にハングします。ここ
は、キックスタートファイルです:
#version=DEVEL
# System authorization information
auth --enableshadow --passalgo=sha512
# Use Network installation media
url --url=http://0.0.0.0/iso
# Use graphical install
#graphical
# Run the Setup Agent on first boot
firstboot --enable
ignoredisk --only-use=sda
# Keyboard layouts
keyboard --vckeymap=gb --xlayouts='gb'
# System language
lang en_GB.UTF-8
# Network information
network --bootproto=dhcp --device=ens160 --ipv6=auto --activate
network --hostname=hostname.domain.com
# Root password
rootpw --iscrypted
taken_encryption_output_out_for_the_purposes_of_security
#Shutdown after installation
shutdown
# System services
services --enabled="chronyd"
# System timezone
timezone Europe/London --isUtc
# System bootloader configuration
bootloader --append=" crashkernel=auto" --location=mbr --boot-
drive=sda
autopart --type=lvm
# Partition clearing information
clearpart --none --initlabel
%packages
@^minimal
@core
chrony
kexec-tools
%end
%addon com_redhat_kdump --enable --reserve-mb='auto'
%end
%anaconda
pwpolicy root --minlen=6 --minquality=50 --notstrict --nochanges --
notempty
pwpolicy user --minlen=6 --minquality=50 --notstrict --nochanges --
notempty
pwpolicy luks --minlen=6 --minquality=50 --notstrict --nochanges --
notempty
%end
私はそれがキックスタートファイルが、わからないでシャットダウン・オプションとは何かだと思います。私がkvmサーバにsshを実行すると、新しく作成されたVMが表示され、スクリプトは動作しますが、Jenkinsはハングします。
[[email protected] ~]# virsh list --all
Id Name State
----------------------------------------------------
- 09-22-17-16-21 shut off
は、これまでのところ私は、シャットダウン、再起動を試みたと明らかにキックスタートファイル内のデフォルトは停止し、彼らはどちらか私のために働いていないしています。
どのように私は正常に完了するためのビルドを得ることができるアイデア?それがハングアップした場合、私は:-)ください