<template>
<name>centos72-source</name>
<os>
<name>CentOS-7</name>
<version>2</version>
<arch>x86_64</arch>
<install type='iso'>
<iso>file:///data/md0/iso/CentOS-7.2-x86_64-Minimal-1511.iso</iso>
</install>
<rootpw>Ct@2017Yun!@$%.CN</rootpw>
</os>
<disk>
<size>20</size>
</disk>
<description>CentOS 7.2 x86_64</description>
<packages>
<package name='net-tools'/>
<package name='acpid'/>
<package name='cloud-utils-growpart'/>
<package name='sysstat'/>
</packages>
<commands>
<command name='install_qga'>
cd /root
tar xf qga.20171124.tar.gz
cd qga
bash ./install_qga_local.sh
</command>
<command name='sed_profile'>
echo "NOZEROCONF=yes" >> /etc/sysconfig/network
rm -rf /etc/udev/rules.d/70-persistent-net.rules
touch /etc/udev/rules.d/75-persistent-net-generator.rules
chmod +x /var/lib/cloud/scripts/per-boot/resetroot
chmod +x /var/lib/cloud/scripts/per-instance/ssh.sh
chmod +x /usr/local/bin/nic_set_mq.sh
echo "/usr/local/bin/nic_set_mq.sh > /tmp/nic_set_mq.log 2>&1" >> /etc/rc.d/rc.local
chmod +x /etc/rc.d/rc.local
</command>
<command name='install_Cloudinit_and_dependencies'>
mkdir -p /root/.pip/
yum install wget -y
yum install epel-release -y
yum clean all
yum install python-pip -y
pip install setuptools jinja2 prettytable oauthlib pyyaml requests jsonpatch jsonschema six --upgrade
cd /root
wget https://launchpad.net/cloud-init/trunk/17.1/+download/cloud-init-17.1.tar.gz
tar -zxvf cloud-init-17.1.tar.gz
cd ./cloud-init-17.1
python setup.py build
python setup.py install --init-system systemd
</command>
<command name='console'>
grub2-mkconfig -o /boot/grub2/grub.cfg
</command>
<command name='services'>
systemctl enable sshd
systemctl disable firewalld
systemctl enable cloud-init
systemctl enable cloud-config
systemctl enable cloud-final
systemctl enable cloud-init-local
systemctl enable acpid
systemctl disable NetworkManager
</command>
<command name='clear-logs'>
rm -rf /root/*
rm -rf /var/log/anaconda*
rm -rf /var/log/message
>/var/log/boot.log
>/var/log/messages
>/var/log/cloud-init-output.log
>/var/log/yum.log
>/var/log/lastlog
</command>
</commands>
<files>
<file name="/root/qga.20171124.tar.gz" type="url">
file:///data/nvme0n1/OZ-build-image/scripts/qga.20171124.tar.gz
</file>
<file name="/var/lib/cloud/scripts/per-boot/resetroot" type="url">
file:///data/nvme0n1/OZ-build-image/scripts/resetroot
</file>
<file name="/etc/cloud/cloud.cfg" type="url">
file:///data/nvme0n1/OZ-build-image/scripts/cloud.cfg_centos7
</file>
<file name="/usr/local/bin/nic_set_mq.sh" type="url">
file:///data/nvme0n1/OZ-build-image/scripts/nic_set_mq.sh
</file>
<file name="/etc/default/grub" type="url">
file:///data/nvme0n1/OZ-build-image/scripts/grub_centos7
</file>
<file name="/var/lib/cloud/scripts/per-instance/ssh.sh" type="url">
file:///data/nvme0n1/OZ-build-image/scripts/ssh-centos7.ssh
</file>
<file name="/root/.pip/pip.conf" type="url">
file:///data/nvme0n1/OZ-build-image/scripts/pip.conf
</file>
<file name="/lib/systemd/system/cloud-init-local.service" type="url">
file:///data/nvme0n1/OZ-build-image/scripts/cloud-init-local.service
</file>
<file name="/lib/systemd/system/cloud-init.service" type="url">
file:///data/nvme0n1/OZ-build-image/scripts/cloud-init.service
</file>
</files>
</template>
install text keyboard us lang en_US.UTF-8 skipx network --device eth0 --bootproto dhcp --onboot=on rootpw Ct@2017Yun!@$%.CN firewall --disabled authconfig --enableshadow --enablemd5 timezone --utc Asia/Shanghai selinux --disabled zerombr clearpart --all --drives=vda bootloader --location=mbr --append="console=tty0 console=ttyS0,115200n8" part / --fstype xfs --size=2048 --grow --ondisk=vda reboot %post cat <<EOL >> /etc/rc.local if [ ! -d /root/.ssh ] ; then mkdir -p /root/.ssh chmod 0700 /root/.ssh restorecon /root/.ssh fi EOL echo "ttyS0" >> /etc/securetty cat <<EOF > /etc/init/ttyS0.conf start on stopped rc RUNLEVEL=[2345] stop on starting runlevel [016] respawn instance /dev/ttyS0 exec /sbin/agetty /dev/ttyS0 115200 vt100-nav EOF %end %packages --nobase --excludedocs %end
但谈何容易。
浙公网安备 33010602011771号