Created
January 30, 2015 09:31
-
-
Save leitu/88d247d62f07ac40b7a4 to your computer and use it in GitHub Desktop.
KS
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# CentOS 6 Server kickstart for XenServer | |
# branch: master | |
########################################## | |
# Install, not upgrade | |
install | |
# Install from a friendly mirror and add updates | |
#repo --name=base --baseurl=http://10.18.2.179/CentOS/6.5/os-min | |
#repo --name=updates --baseurl=http://10.18.2.179/CentOS/updates/x86_64 | |
# Language and keyboard setup | |
lang en_US.UTF-8 | |
keyboard us | |
# Configure networking without IPv6, firewall off | |
# for STATIC IP: uncomment and configure | |
# network --onboot=yes --device=eth0 --bootproto=static --ip=192.168.###.### --netmask=255.255.255.0 --gateway=192.168.###.### --nameserver | |
=###.###.###.### --noipv6 --hostname=$$$ | |
# for DHCP: | |
network --bootproto=dhcp --device=eth0 --onboot=no --noipv6 | |
firewall --enabled --service=ssh | |
# Set timezone | |
#timezone --utc Etc/UTC | |
timezone --utc Asia/Shanghai | |
# Authentication | |
rootpw Asdfqwerty | |
# if you want to preset the root password in a public kickstart file, use SHA512crypt e.g. | |
# rootpw --iscrypted $6$9dC4m770Q1o$FCOvPxuqc1B22HM21M5WuUfhkiQntzMuAV7MY0qfVcvhwNQ2L86PcnDWfjDd12IFxWtRiTuvO/niB0Q3Xpf2I. | |
authconfig --enableshadow --passalgo=sha512 | |
# SELinux disable | |
selinux --enforcing | |
# Disable anything graphical | |
skipx | |
text | |
#Setup the disk | |
zerombr | |
clearpart --all --initlabel --drives=xvda | |
part /boot --fstype=ext3 --size=500 --ondisk=xvda | |
part pv.1 --size=1 --grow --asprimary --ondisk=xvda | |
volgroup myvg pv.1 | |
logvol / --fstype=ext4 --name=RootVol --vgname=myvg --grow --size=1024 | |
logvol /var --fstype=ext4 --name=VarVol --vgname=myvg --size=2048 | |
logvol swap --fstype=swap --name=SwapVol --vgname=myvg --size=1024 | |
#part /boot --fstype=ext3 --size=500 --asprimary | |
#part / --fstype=ext4 --grow --size=1024 --asprimary | |
bootloader --timeout=5 --driveorder=xvda --append="console=hvc0" | |
#reboot server | |
reboot | |
# Minimal package set | |
%packages --ignoremissing | |
@Base | |
@Core | |
@Development Tools | |
openssl-devel | |
readline-devel | |
zlib-devel | |
vim | |
wget | |
%end | |
# Copy grub.cfg to a backup and then make adaptations for buggy pygrub | |
%post --log=/root/ks-post.log | |
echo -n "Network fixes" | |
# initscripts don't like this file to be missing. | |
cat > /etc/sysconfig/network << EOF | |
NETWORKING=yes | |
NOZEROCONF=yes | |
EOF | |
echo -n "." | |
# For cloud images, 'eth0' _is_ the predictable device name, since | |
# we don't want to be tied to specific virtual (!) hardware | |
rm -f /etc/udev/rules.d/70* | |
ln -s /dev/null /etc/udev/rules.d/80-net-name-slot.rules | |
echo -n "." | |
# simple eth0 config, again not hard-coded to the build hardware | |
cat > /etc/sysconfig/network-scripts/ifcfg-eth0 << EOF | |
DEVICE="eth0" | |
BOOTPROTO="dhcp" | |
ONBOOT="yes" | |
TYPE="Ethernet" | |
PERSISTENT_DHCLIENT="yes" | |
EOF | |
echo -n "." | |
# generic localhost names | |
cat > /etc/hosts << EOF | |
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4 | |
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6 | |
EOF | |
echo -n "." | |
# since NetworkManager is disabled, need to enable normal networking | |
chkconfig network on | |
echo . | |
# utility script | |
#echo -n "Utility scripts" | |
#echo "== Utility scripts ==" >> /root/ks-post.debug.log | |
#wget -O /opt/domu-hostname.sh https://github.com/frederickding/xenserver-kickstart/raw/develop/opt/domu-hostname.sh 2>> /root/ks-post.debu | |
g.log | |
#chmod +x /opt/domu-hostname.sh | |
#echo . | |
# remove unnecessary packages | |
echo -n "Removing unnecessary packages" | |
echo "== Removing unnecessary packages ==" >> /root/ks-post.debug.log | |
yum -C -y remove linux-firmware >> /root/ks-post.debug.log 2&>1 | |
echo . | |
# generalization | |
echo -n "Generalizing" | |
rm -f /etc/ssh/ssh_host_* | |
echo . | |
#Add extra package | |
#echo -n "Add packages" | |
#yum groupinstall -y "GNOME Desktop" | |
#yum install -y libxslt-devel ntp tigervnc-server xorg-x11-fonts-Type1 | |
yum install -y libxslt-devel ntp | |
#echo . | |
# Install puppet | |
echo -n "Puppet" | |
rpm --import http://10.18.2.179/puppet/el/RPM-GPG-KEY-puppetlabs | |
cat > /etc/yum.repos.d/puppet.repo << EOF | |
[ThoughtWorks-puppet] | |
name=ThoughtWorks-puppet | |
baseurl=http://10.18.2.179/puppet/el/6/products/x86_64 | |
gpgcheck=1 | |
EOF | |
yum install -y puppet facter 2&>1 | |
echo . | |
# Install latest cloud-init | |
echo -n "Cloud-int" | |
yum install -y http://10.18.2.179/scaleworks/deps/cloud-init-0.7.5-10.el6.centos.2.x86_64.rpm | |
wget -O /etc/cloud/cloud.cfg http://10.18.2.179/fedora/ks/cloud.cfg | |
echo . | |
#Add scaleworks | |
echo -n "Add scaleworks" | |
echo "scaleworks ALL=(ALL) NOPASSWD: ALL" > /etc/sudoers.d/01-scaleworks | |
sed -i -e 's@ requiretty@ !requiretty@' /etc/sudoers | |
echo . | |
#Add install Xentools | |
echo -n "xe tools" | |
rpm -ivh http://10.18.2.179/scaleworks/deps/xe-guest-utilities-xenstore-6.2.0-1150.x86_64.rpm | |
rpm -ivh http://10.18.2.179/scaleworks/deps/xe-guest-utilities-6.2.0-1150.x86_64.rpm | |
echo 'xenstore_write_cached "attr/Customs/Kickstart" "0"' >> /usr/sbin/xe-update-guest-attrs | |
service xe-linux-distribution restart | |
echo . | |
%end | |
%post --nochroot --log=/root/ks-post-2.log | |
#Cleanup | |
echo "Clean up" | |
rm -rf /mnt/sysimage/var/lib/cloud/ | |
rm -rf /mnt/sysimage/var/log/cloud-init*.log | |
rm -rf /mnt/sysimage/run/cloud-init | |
# files | |
rm -rf /mnt/sysimage/root/anaconda-ks.cfg | |
rm -rf /mnt/sysimage/root/ks-post-2.log | |
rm -rf /mnt/sysimage/root/ks-post.log | |
rm -rf /mnt/sysimage/root/ks-post.debug.log | |
rm -rf /mnt/sysimage/install.log | |
rm -rf /mnt/sysimage/install.log.syslog | |
echo . | |
#reboot | |
reboot | |
%end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Fedora 20 Server kickstart for XenServer | |
# branch: master | |
########################################## | |
# Install, not upgrade | |
install | |
# Install from a friendly mirror and add updates | |
#url --mirrorlist=http://mirrors.fedoraproject.org/mirrorlist?repo=fedora-20&arch=$basearch | |
#url --mirrorlist=http://10.18.2.179/fedora/20/os/ | |
#repo --name=updates | |
# Language and keyboard setup | |
lang en_US.UTF-8 | |
keyboard us | |
# Configure networking without IPv6, firewall off | |
# for STATIC IP: uncomment and configure | |
# network --onboot=yes --device=eth0 --bootproto=static --ip=192.168.###.### --netmask=255.255.255.0 --gateway=192.168.###.### --nameserver | |
=###.###.###.### --noipv6 --hostname=$$$ | |
# for DHCP: | |
network --bootproto=dhcp --device=eth0 --onboot=on | |
firewall --enabled --service=ssh | |
# Set timezone | |
#timezone --utc Etc/UTC | |
timezone --utc Asia/Shanghai | |
# Authentication | |
rootpw Asdfqwerty | |
# if you want to preset the root password in a public kickstart file, use SHA512crypt e.g. | |
# rootpw --iscrypted $6$9dC4m770Q1o$FCOvPxuqc1B22HM21M5WuUfhkiQntzMuAV7MY0qfVcvhwNQ2L86PcnDWfjDd12IFxWtRiTuvO/niB0Q3Xpf2I. | |
authconfig --enableshadow --passalgo=sha512 | |
# SELinux disable | |
selinux --enforcing | |
# Disable anything graphical | |
skipx | |
text | |
#Setup the disk | |
zerombr | |
clearpart --all --drives=xvda | |
part /boot --fstype=ext3 --size=500 --ondisk=xvda | |
part pv.1 --size=1 --grow --asprimary --ondisk=xvda | |
volgroup myvg pv.1 | |
logvol / --fstype=ext4 --name=RootVol --vgname=myvg --grow --size=1024 | |
logvol /var --fstype=ext4 --name=VarVol --vgname=myvg --size=2048 | |
logvol swap --fstype=swap --name=SwapVol --vgname=myvg --size=1024 | |
#part /boot --fstype=ext3 --size=500 --asprimary | |
#part / --fstype=ext4 --grow --size=1024 --asprimary | |
bootloader --timeout=5 --driveorder=xvda --append="console=hvc0" | |
#reboot server | |
reboot | |
# Minimal package set | |
%packages --excludedocs | |
@standard | |
@Development Tools | |
gcc | |
gcc-c++ | |
make | |
openssl-devel | |
libxml2 | |
libxml2-devel | |
libxslt | |
git | |
man | |
vim | |
wget | |
net-tools | |
NetworkManager | |
%end | |
# Copy grub.cfg to a backup and then make adaptations for buggy pygrub | |
%post --log=/root/ks-post.log | |
echo -n "Network fixes" | |
# initscripts don't like this file to be missing. | |
cat > /etc/sysconfig/network << EOF | |
NETWORKING=yes | |
NOZEROCONF=yes | |
EOF | |
echo -n "." | |
# For cloud images, 'eth0' _is_ the predictable device name, since | |
# we don't want to be tied to specific virtual (!) hardware | |
rm -f /etc/udev/rules.d/70* | |
ln -s /dev/null /etc/udev/rules.d/80-net-name-slot.rules | |
echo -n "." | |
# simple eth0 config, again not hard-coded to the build hardware | |
cat > /etc/sysconfig/network-scripts/ifcfg-eth0 << EOF | |
DEVICE="eth0" | |
BOOTPROTO="dhcp" | |
ONBOOT="yes" | |
TYPE="Ethernet" | |
PERSISTENT_DHCLIENT="yes" | |
EOF | |
echo -n "." | |
# generic localhost names | |
cat > /etc/hosts << EOF | |
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4 | |
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6 | |
EOF | |
echo -n "." | |
# since NetworkManager is disabled, need to enable normal networking | |
chkconfig network on | |
echo . | |
# utility script | |
#echo -n "Utility scripts" | |
#echo "== Utility scripts ==" >> /root/ks-post.debug.log | |
#wget -O /opt/domu-hostname.sh https://github.com/frederickding/xenserver-kickstart/raw/develop/opt/domu-hostname.sh 2>> /root/ks-post.debu | |
g.log | |
#chmod +x /opt/domu-hostname.sh | |
#echo . | |
echo -e "umask 027" >> /etc/sysconfig/init | |
# remove unnecessary packages | |
echo -n "Removing unnecessary packages" | |
echo "== Removing unnecessary packages ==" >> /root/ks-post.debug.log | |
yum -C -y remove linux-firmware >> /root/ks-post.debug.log 2&>1 | |
echo . | |
# generalization | |
echo -n "Generalizing" | |
rm -f /etc/ssh/ssh_host_* | |
echo . | |
#Add extra package | |
echo -n "Add packages" | |
#yum groupinstall -y "GNOME Desktop" | |
#yum install -y libxslt-devel ntp tigervnc-server xorg-x11-fonts-Type1 | |
yum install -y libxslt-devel ntp | |
echo . | |
# Install puppet | |
echo -n "Puppet" | |
rpm -ivh http://yum.puppetlabs.com/puppetlabs-release-fedora-20.noarch.rpm | |
yum install -y puppet facter 2&>1 | |
echo . | |
# Install latest cloud-init | |
echo -n "Cloud-int" | |
yum install -y http://10.18.2.179/scaleworks/deps/cloud-init-0.7.5-8.fc21.x86_64.rpm | |
wget -O /etc/cloud/cloud.cfg http://10.18.2.179/fedora/ks/cloud.cfg | |
echo . | |
#Add scaleworks | |
echo -n "Add scaleworks" | |
echo "scaleworks ALL=(ALL) NOPASSWD: ALL" > /etc/sudoers.d/01-scaleworks | |
sed -i -e 's@ requiretty@ !requiretty@' /etc/sudoers | |
echo . | |
# fix boot for older pygrub/XenServer | |
# you should comment out this entire section if on XenServer Creedence/Xen 4.4 | |
echo -n "Fixing boot" | |
echo "== GRUB fixes ==" >> /root/ks-post.debug.log | |
cp /boot/grub2/grub.cfg /boot/grub2/grub.cfg.bak | |
cp /etc/default/grub /etc/default/grub.bak | |
cp --no-preserve=mode /etc/grub.d/00_header /etc/grub.d/00_header.bak | |
sed -i 's/GRUB_DEFAULT=saved/GRUB_DEFAULT=0/' /etc/default/grub | |
sed -i 's/default="\\${next_entry}"/default="0"/' /etc/grub.d/00_header | |
echo -n "." | |
grub2-mkconfig -o /boot/grub2/grub.cfg >> /root/ks-post.debug.log 2&>1 | |
echo . | |
#Add install Xentools | |
echo -n "xe tools" | |
rpm -ivh http://10.18.2.179/scaleworks/deps/xe-guest-utilities-xenstore-6.2.0-1150.x86_64.rpm | |
rpm -ivh http://10.18.2.179/scaleworks/deps/xe-guest-utilities-6.2.0-1150.x86_64.rpm | |
sed -i '180s/\.\*/\:\.\*/g' /usr/sbin/xe-update-guest-attrs | |
sed -i '181s/addr\://g' /usr/sbin/xe-update-guest-attrs | |
sed -i '182s/addr\://g' /usr/sbin/xe-update-guest-attrs | |
echo '#build custom addons' >> /usr/sbin/xe-update-guest-attrs | |
echo 'xenstore_write_cached "attr/Customs/Kickstart" "0"' >> /usr/sbin/xe-update-guest-attrs | |
service xe-linux-distribution restart | |
echo . | |
%end | |
%post --nochroot --log=/root/ks-post-2.log | |
#Stop service | |
echo "Stop service" | |
/bin/systemctl stop NetworkManager.service | |
/bin/systemctl disable NetworkManager.service | |
echo . | |
#Cleanup | |
echo "Clean up" | |
rm -rf /var/lib/cloud/ | |
rm -rf /var/log/cloud-init*.log | |
rm -rf /run/cloud-init | |
# files | |
rm -rf /root/anaconda-ks.cfg | |
rm -rf /root/ks-post-2.log | |
rm -rf /root/ks-post.log | |
rm -rf /root/ks-post.debug.log | |
echo . | |
#reboot | |
reboot | |
%end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Ubuntu 12 Server kickstart for XenServer | |
# branch: master | |
########################################## | |
# Install, not upgrade | |
install | |
# Install from a friendly mirror and add updates | |
#url --url http://10.18.2.179/ubuntu/os | |
cdrom | |
# Language and keyboard setup | |
lang en_US.UTF-8 | |
keyboard us | |
# Configure networking without IPv6, firewall off | |
# for STATIC IP: uncomment and configure | |
# network --onboot=yes --device=eth0 --bootproto=static --ip=192.168.###.### --netmask=255.255.255.0 --gateway=192.168.###.### --nameserver | |
=###.###.###.### --noipv6 --hostname=$$$ | |
# for DHCP: | |
network --bootproto=dhcp --device=eth0 | |
firewall --disabled | |
# Set timezone | |
#timezone --utc Etc/UTC | |
timezone --utc Asia/Shanghai | |
# Authentication | |
rootpw --disabled | |
user scaleworks --fullname "scaleworks" --password Asdfqwerty | |
auth --useshadow --enablemd5 | |
# if you want to preset the root password in a public kickstart file, use SHA512crypt e.g. | |
# rootpw --iscrypted $6$9dC4m770Q1o$FCOvPxuqc1B22HM21M5WuUfhkiQntzMuAV7MY0qfVcvhwNQ2L86PcnDWfjDd12IFxWtRiTuvO/niB0Q3Xpf2I. | |
authconfig --enableshadow --passalgo=sha512 | |
# Disable anything graphical | |
skipx | |
text | |
#Setup the disk | |
zerombr yes | |
clearpart --all | |
pressed partman-auto-lv/guided_size string 7680MB | |
part /boot --fstype=ext3 --size=500 --asprimary | |
part pv.1 --size=1 --grow --asprimary | |
volgroup myvg pv.1 | |
logvol / --fstype=ext4 --name=RootVol --vgname=myvg --grow --size=1024 | |
logvol /var --fstype=ext4 --name=VarVol --vgname=myvg --size=2048 | |
logvol swap --fstype=swap --name=SwapVol --vgname=myvg --size=1024 | |
#part /boot --fstype=ext3 --size=500 --asprimary | |
#part / --fstype=ext4 --grow --size=1024 --asprimary | |
bootloader --location=mbr | |
preseed base-installer/install-recommends boolean false | |
#reboot server | |
reboot | |
# Minimal package set | |
%packages | |
ubuntu-minimal | |
ca-certificates | |
openssl | |
python | |
wget | |
tcpd | |
openssh-server | |
curl | |
screen | |
vim | |
linux-image-virtual | |
%post | |
#!/bin/sh | |
echo -n "Minimizing kernel" | |
apt-get install -f -y linux-virtual | |
apt-get remove -y linux-firmware | |
dpkg -l | grep extra | grep linux | awk '{print $2}' | xargs apt-get remove -y | |
echo . | |
echo -n "/etc/fstab fixes" | |
# update fstab for the root partition | |
perl -pi -e 's/(errors=remount-ro)/noatime,nodiratime,$1,barrier=0/' /etc/fstab | |
echo . | |
echo -n "Network fixes" | |
# For cloud images, 'eth0' _is_ the predictable device name, since | |
# we don't want to be tied to specific virtual (!) hardware | |
rm -f /etc/udev/rules.d/70* | |
ln -s /dev/null /etc/udev/rules.d/80-net-name-slot.rules | |
echo . | |
# generic localhost names | |
echo "localhost.localdomain" > /etc/hostname | |
echo . | |
cat > /etc/hosts << EOF | |
127.0.0.1 localhost | |
127.0.1.1 localhost | |
#The following lines are desirable for IPv6 capable hosts | |
::1 ip6-localhost ip6-loopback | |
fe00::0 ip6-localnet | |
ff00::0 ip6-mcastprefix | |
ff02::1 ip6-allnodes | |
ff02::2 ip6-allrouters | |
EOF | |
echo . | |
# generalization | |
echo -n "Generalizing" | |
rm -f /etc/ssh/ssh_host_* | |
rm -f /var/cache/apt/archives/*.deb | |
rm -f /var/cache/apt/*cache.bin | |
rm -f /var/lib/apt/lists/*_Packages | |
echo . | |
# fix boot for older pygrub/XenServer | |
# you should comment out this entire section if on XenServer Creedence/Xen 4.4 | |
echo -n "Fixing boot" | |
cp /boot/grub/grub.cfg /boot/grub/grub.cfg.bak | |
cp /etc/default/grub /etc/default/grub.bak | |
cp --no-preserve=mode /etc/grub.d/00_header /etc/grub.d/00_header.bak | |
sed -i 's/GRUB_DEFAULT=saved/GRUB_DEFAULT=0/' /etc/default/grub | |
sed -i 's/default="\\${next_entry}"/default="0"/' /etc/grub.d/00_header | |
echo -n "." | |
cp --no-preserve=mode /etc/grub.d/10_linux /etc/grub.d/10_linux.bak | |
sed -i 's/${sixteenbit}//' /etc/grub.d/10_linux | |
echo -n "." | |
update-grub | |
echo . | |
echo "add repo" | |
cat > /etc/apt/sources.list << EOF | |
deb http://mirrors.yun-idc.com/ubuntu/ precise main restricted universe | |
deb http://mirrors.yun-idc.com/ubuntu/ precise-security main restricted universe | |
deb http://mirrors.yun-idc.com/ubuntu/ precise-updates main restricted universe | |
EOF | |
apt-get update | |
apt-get upgrade -y | |
echo -n "." | |
# Install puppet | |
echo -n "Puppet" | |
wget -O /tmp/puppetlabs-release-precise.deb http://apt.puppetlabs.com/puppetlabs-release-precise.deb | |
apt-get update | |
apt-get install -y puppet facter 2&>1 | |
echo . | |
# Install latest cloud-init | |
echo -n "Cloud-int" | |
apt-get install -y cloud-init | |
wget -O /etc/cloud/cloud.cfg http://10.18.2.179/fedora/ks/cloud.cfg | |
echo . | |
#Add install Xentools | |
echo -n "xe tools" | |
wget -O /tmp/xe-guest-utilities_6.2.0-1150_amd64.deb http://10.18.2.179/scaleworks/deps/xe-guest-utilities_6.2.0-1150_amd64.deb | |
echo '#build custom addons' >> /usr/sbin/xe-update-guest-attrs | |
echo 'xenstore_write_cached "attr/Customs/Kickstart" "0"' >> /usr/sbin/xe-update-guest-attrs | |
service xe-linux-distribution restart | |
echo . | |
# setup locales | |
locale-gen en_US.UTF-8 | |
update-locale LANG="en_US.UTF-8" | |
echo 'LANG=en_US.UTF-8' >> /etc/environment | |
echo 'LC_ALL=en_US.UTF-8' >> /etc/environment | |
#install paravirt kernel image | |
apt-get install -f -y linux-virtual | |
dpkg -l | grep generic | grep linux | awk '{print $2}' | xargs apt-get remove -y | |
#Cleanup | |
echo "Clean up" | |
rm -rf /target/var/lib/cloud/ | |
rm -rf /target/var/log/cloud-init*.log | |
rm -rf /target/run/cloud-init | |
# files | |
rm -rf /target/root/ks-post-2.log | |
rm -rf /target/root/ks-post.log | |
rm -rf /target/root/ks-post.debug.log | |
echo . | |
%end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
#Define Displayname & Diskname | |
VML=centos65 | |
REPO=http://10.18.2.179/CentOS/6.5/os-min | |
KS=http://10.18.2.179/fedora/ks/C65.ks | |
#Support we are using local storage | |
SRUUID=`xe sr-list name-label="Local storage" --minimal` | |
#Get template uuid | |
TPUUID=`xe template-list name-label="CentOS 6 (64-bit)" --minimal` | |
#Use RHEL ENTERPRISE 6 64bit as template | |
VMUUID=`xe vm-install new-name-label=${VML} sr-uuid=${SRUUID} template=${TPUUID}` | |
#Set CPUs and Memory | |
create_vm() { | |
xe vm-param-set VCPUs-max=1 uuid=${VMUUID} | |
xe vm-param-set VCPUs-at-startup=1 uuid=${VMUUID} | |
xe vm-param-set memory-dynamic-max=1GiB uuid=${VMUUID} | |
xe vm-param-set memory-static-max=1GiB uuid=${VMUUID} | |
xe vm-param-set memory-dynamic-min=1GiB uuid=${VMUUID} | |
xe vm-param-set memory-static-min=1GiB uuid=${VMUUID} | |
#Set HV or PV | |
xe vm-param-set HVM-boot-policy="" uuid=${VMUUID} | |
xe vm-param-set PV-bootloader="eliloader" uuid=${VMUUID} | |
#After setting PV, transfer install url and Kickstart | |
xe vm-param-set other-config:install-repository="${REPO}" uuid=${VMUUID} | |
xe vm-param-set PV-args="console=hvc0 utf8 nogpt noipv6 ks=${KS}" uuid=${VMUUID} | |
#Change default VDI to 40GiB | |
#VBDUUID=`xe vbd-list vm-name-label=${VML} --minimal` | |
#VDIUUID=`xe vbd-param-get uuid=${VBDUUID} param-name=vdi-uuid --minimal` | |
#xe vdi-resize uuid=${VDIUUID} disk-size=40GiB | |
#We are not removing the data | |
#xe vm-disk-remove vm=${VML} | |
#ORIVBD=`xe vbd-list vm-name-label={VML} --minimal` | |
#Add extra disk | |
#xe vm-disk-add uuid=${VMUUID} sr-uuid=${SRUUID} device=2 disk-size=40GiB | |
#VDBUUID=`xe vbd-list vm-uuid=${VMUUID} userdevice=0 params=uuid --minimal` | |
#xe vbd-param-set bootable=true uuid=${VDBUUID} | |
#Create relative network with eth0 | |
BRUUID=`xe network-list bridge=xenbr0 --minimal` | |
xe vif-create vm-uuid=${VMUUID} network-uuid=${BRUUID} mac=random device=0 | |
#ADD cdrom as devices, then reject xs-tools. since it will be installed with ks | |
xe vm-cd-add cd-name=xs-tools.iso device=1 vm=${VML} | |
xe vm-cd-eject uuid=${VMUUID} | |
#Start to install | |
xe vm-start uuid=${VMUUID} | |
} | |
create_template() { | |
#rename default VDI | |
VBDUUID=`xe vbd-list vm-name-label=${VML} device=xvda --minimal` | |
VDIUUID=`xe vbd-param-get uuid=${VBDUUID} param-name=vdi-uuid --minimal` | |
xe vdi-param-set uuid=${VDIUUID} name-label=${VML} name-description="create by cli" | |
while true | |
do | |
DOMAINID=`list_domains | grep ${VMUUID} | awk '{ print $1}'` | |
CODE=`xenstore-read /local/domain/${DOMAINID}/attr/Customs/Kickstart` | |
if [ "$CODE" == "0" ]; then | |
SPUUID=`xe vm-snapshot name-label=${VML} new-name-label=Image-${VML}_${DATE} new-name-description=Image-${VML}` | |
xe snapshot-copy uuid=${SPUUID} new-name-label=Image-${VML} | |
break | |
fi | |
echo "it's not finishing yet" | |
sleep 300 | |
done | |
} | |
stop_template() { | |
xe vm-shutdown force=true vm=${VML} | |
xe vm-param-set uuid=${VDIUUID} name-label=${VML}-Live | |
} | |
create_vm | |
sleep 600 | |
create_template | |
stop_template |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
#Define Displayname & Diskname | |
VML=Image-fedora20 | |
#Support we are using local storage | |
SRUUID=`xe sr-list name-label="Local storage" --minimal` | |
#Get template uuid | |
TPUUID=`xe template-list name-label="CentOS 6 (64-bit)" --minimal` | |
#Use RHEL ENTERPRISE 6 64bit as template | |
VMUUID=`xe vm-install new-name-label=${VML} sr-uuid=${SRUUID} template=${TPUUID}` | |
#Set CPUs and Memory | |
create_vm() { | |
xe vm-param-set VCPUs-max=1 uuid=${VMUUID} | |
xe vm-param-set VCPUs-at-startup=1 uuid=${VMUUID} | |
xe vm-param-set memory-dynamic-max=1GiB uuid=${VMUUID} | |
xe vm-param-set memory-static-max=1GiB uuid=${VMUUID} | |
xe vm-param-set memory-dynamic-min=1GiB uuid=${VMUUID} | |
xe vm-param-set memory-static-min=1GiB uuid=${VMUUID} | |
#Set HV or PV | |
xe vm-param-set HVM-boot-policy="" uuid=${VMUUID} | |
xe vm-param-set PV-bootloader="eliloader" uuid=${VMUUID} | |
#After setting PV, transfer install url and Kickstart | |
xe vm-param-set other-config:install-repository="http://10.18.2.179/fedora/20/os" uuid=${VMUUID} | |
xe vm-param-set PV-args="console=hvc0 utf8 nogpt noipv6 ks=http://10.18.2.179/fedora/ks/f20.ks" uuid=${VMUUID} | |
#Change default VDI to 40GiB | |
#VBDUUID=`xe vbd-list vm-name-label=${VML} --minimal` | |
#VDIUUID=`xe vbd-param-get uuid=${VBDUUID} param-name=vdi-uuid --minimal` | |
#xe vdi-resize uuid=${VDIUUID} disk-size=40GiB | |
#We are not removing the data | |
#xe vm-disk-remove vm=${VML} | |
#ORIVBD=`xe vbd-list vm-name-label={VML} --minimal` | |
#Add extra disk | |
#xe vm-disk-add uuid=${VMUUID} sr-uuid=${SRUUID} device=2 disk-size=40GiB | |
#VDBUUID=`xe vbd-list vm-uuid=${VMUUID} userdevice=0 params=uuid --minimal` | |
#xe vbd-param-set bootable=true uuid=${VDBUUID} | |
#Create relative network with eth0 | |
BRUUID=`xe network-list bridge=xenbr0 --minimal` | |
xe vif-create vm-uuid=${VMUUID} network-uuid=${BRUUID} mac=random device=0 | |
#ADD cdrom as devices, then reject xs-tools. since it will be installed with ks | |
xe vm-cd-add cd-name=xs-tools.iso device=1 vm=${VML} | |
xe vm-cd-eject uuid=${VMUUID} | |
#Start to install | |
xe vm-start uuid=${VMUUID} | |
} | |
create_template() { | |
#rename default VDI | |
VBDUUID=`xe vbd-list vm-name-label=${VML} device=xvda --minimal` | |
VDIUUID=`xe vbd-param-get uuid=${VBDUUID} param-name=vdi-uuid --minimal` | |
xe vdi-param-set uuid=${VDIUUID} name-label=${VML} name-description="create by cli" | |
while true | |
do | |
DOMAINID=`list_domains | grep ${VMUUID} | awk '{ print $1}'` | |
CODE=`xenstore-read /local/domain/${DOMAINID}/attr/Customs/Kickstart` | |
if [ "$CODE" == "0" ]; then | |
SPUUID=`xe vm-snapshot name-label=${VML} new-name-label=${VML}_${DATE} new-name-description=${VML}` | |
xe snapshot-copy uuid=${SPUUID} new-name-label=Image-${VML} | |
break | |
else | |
echo "it's not finishing yet" | |
sleep 300 | |
fi | |
done | |
} | |
stop_template() { | |
xe vm-shutdown force=true vm=${VML} | |
xe vm-param-set uuid=${VDIUUID} name-label=${VML}-Live | |
} | |
create_vm | |
sleep 300 | |
create_template | |
stop_template |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
#Define Displayname & Diskname | |
VML=ubuntu12 | |
#REPO=http://10.18.2.179/ubuntu | |
ISO=ubuntu-12.04.4-server-amd64.iso | |
KS=http://10.18.2.179/fedora/ks/u12.ks | |
#Support we are using local storage | |
SRUUID=`xe sr-list name-label="Local storage" --minimal` | |
#Get template uuid | |
TPUUID=`xe template-list name-label="Ubuntu Precise Pangolin 12.04 (64-bit)" --minimal` | |
#Use RHEL ENTERPRISE 6 64bit as template | |
VMUUID=`xe vm-install new-name-label=${VML} sr-uuid=${SRUUID} template=${TPUUID}` | |
#Set CPUs and Memory | |
create_vm() { | |
xe vm-param-set VCPUs-max=1 uuid=${VMUUID} | |
xe vm-param-set VCPUs-at-startup=1 uuid=${VMUUID} | |
xe vm-param-set memory-dynamic-max=256MiB uuid=${VMUUID} | |
xe vm-param-set memory-static-max=256MiB uuid=${VMUUID} | |
xe vm-param-set memory-dynamic-min=256MiB uuid=${VMUUID} | |
xe vm-param-set memory-static-min=256MiB uuid=${VMUUID} | |
#Set HV or PV | |
xe vm-param-set HVM-boot-policy="" uuid=${VMUUID} | |
xe vm-param-set PV-bootloader="eliloader" uuid=${VMUUID} | |
#ADD cdrom as devices, then reject xs-tools. since it will be installed with ks | |
xe vm-cd-add cd-name=${ISO} device=1 vm=${VML} | |
CDUUID=`xe vbd-list vm-name-label=${VML} type=CD params=uuid --minimal` | |
xe vbd-param-set uuid=${CDUUID} bootable=true | |
#After setting PV, transfer install url and Kickstart | |
#xe vm-param-set other-config:install-repository="${REPO}" uuid=${VMUUID} | |
xe vm-param-set other-config:install-repository=cdrom uuid=${VMUUID} | |
xe vm-param-set PV-args="console=hvc0 utf8 nogpt noipv6 ks=${KS}" uuid=${VMUUID} | |
#Change default VDI to 40GiB | |
#VBDUUID=`xe vbd-list vm-name-label=${VML} --minimal` | |
#VDIUUID=`xe vbd-param-get uuid=${VBDUUID} param-name=vdi-uuid --minimal` | |
#xe vdi-resize uuid=${VDIUUID} disk-size=40GiB | |
#We are not removing the data | |
#xe vm-disk-remove vm=${VML} | |
#ORIVBD=`xe vbd-list vm-name-label={VML} --minimal` | |
#Add extra disk | |
#xe vm-disk-add uuid=${VMUUID} sr-uuid=${SRUUID} device=2 disk-size=40GiB | |
#VDBUUID=`xe vbd-list vm-uuid=${VMUUID} userdevice=0 params=uuid --minimal` | |
#xe vbd-param-set bootable=true uuid=${VDBUUID} | |
#Create relative network with eth0 | |
BRUUID=`xe network-list bridge=xenbr0 --minimal` | |
xe vif-create vm-uuid=${VMUUID} network-uuid=${BRUUID} mac=random device=0 | |
#Start to install | |
xe vm-start uuid=${VMUUID} | |
} | |
create_template() { | |
#rename default VDI | |
VBDUUID=`xe vbd-list vm-name-label=${VML} device=xvda --minimal` | |
VDIUUID=`xe vbd-param-get uuid=${VBDUUID} param-name=vdi-uuid --minimal` | |
xe vdi-param-set uuid=${VDIUUID} name-label=${VML} name-description="create by cli" | |
while true | |
do | |
DOMAINID=`list_domains | grep ${VMUUID} | awk '{ print $1}'` | |
CODE=`xenstore-read /local/domain/${DOMAINID}/attr/Customs/Kickstart` | |
if [ "$CODE" == "0" ]; then | |
SPUUID=`xe vm-snapshot name-label=${VML} new-name-label=Image-${VML}_${DATE} new-name-description=Image-${VML}` | |
xe snapshot-copy uuid=${SPUUID} new-name-label=Image-${VML} | |
break | |
fi | |
echo "it's not finishing yet" | |
sleep 300 | |
done | |
} | |
stop_template() { | |
xe vm-shutdown force=true vm=${VML} | |
xe vm-param-set uuid=${VDIUUID} name-label=${VML}-Live | |
} | |
create_vm | |
sleep 600 | |
create_template | |
stop_template |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment