Skip to content

Instantly share code, notes, and snippets.

@lorin
Last active December 19, 2015 04:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lorin/5901189 to your computer and use it in GitHub Desktop.
Save lorin/5901189 to your computer and use it in GitHub Desktop.
Building CentOS 6.4 images that resize on boot, with oz, libguestfs, and Robert Plestenjak's centos-image-resize script
install
text
key --skip
keyboard us
lang en_US.UTF-8
skipx
network --device eth0 --bootproto dhcp
rootpw %ROOTPW%
firewall --disabled
authconfig --enableshadow --enablemd5
selinux --enforcing
timezone --utc America/New_York
bootloader --location=mbr --append="console=tty0 console=ttyS0,115200"
zerombr yes
clearpart --all
part / --fstype ext4 --size=1024 --grow
reboot
%packages
@base
%post
<template>
<name>centos-6.4</name>
<os>
<name>CentOS-6</name>
<version>4</version>
<arch>x86_64</arch>
<install type='iso'>
<iso>file:///data/isos/CentOS-6.4-x86_64-bin-DVD1.iso</iso>
</install>
</os>
<description>CentOS 6.4 x86_64</description>
<repositories>
<repository name='epel-6'>
<url>http://download.fedoraproject.org/pub/epel/6/$basearch</url>
<signed>no</signed>
</repository>
</repositories>
<packages>
<package name="epel-release" />
<package name="cloud-utils" />
<package name="cloud-init" />
</packages>
<commands>
<command name="resize">
cd /tmp
wget https://github.com/flegmatik/centos-image-resize/archive/master.zip -O centos-image-resize-master.zip
unzip centos-image-resize-master.zip
cd centos-image-resize-master
chmod +x init-part
/bin/bash ./centos-image-mod.sh
</command>
<command name="openstack-user">
useradd openstack
sed -i 's/^user:.*/user: openstack/' /etc/cloud/cloud.cfg
echo "openstack ALL=(ALL) NOPASSWD: ALL" > /etc/sudoers.d/openstack
</command>
<!-- virt-sysprep bug requires that we manually edit ifcfg-eth0.
See https://bugzilla.redhat.com/show_bug.cgi?id=811117
This is fixed in later versions, but broken on precise -->
<command name="remove-hwaddr">
sed -i '/^HWADDR/d' /etc/sysconfig/network-scripts/ifcfg-eth0
</command>
</commands>
</template>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment