===================== Leap Cloudadmin Tools ===================== Tools to clone a new kvm instance from an existing baseimage Outline ======= Cloning Images will take these steps: * Clone Disk and xml-config from (inactive) Domain leap-baseimage-wheezy, using virt-clone * Use sfdisk to grow the root partition. * Create second disk (vfat-formatted), put the files meta-data and user-data on it * Start new Domain and attach second disk to it * Cloud-init will start at the end of the boot process, find the disk containing userdata, and configure the Domain: ** set up timezone ** setting a default locale ** setting hostname ** editing /etc/hosts for fqdn ** sets root password ** generate ssh host keys ** adding ssh keys to /root.ssh/authorized_keys so they can log in ** apt-get update/upgrade Setup (once) ============ * We need util-linux from wheezy, because of the "sfdisk-feature": https://bugs.launchpad.net/ubuntu/+source/util-linux/+bug/686124 which lets us script the growing of the root partition. apt-get install dosfstools mtools apt-get install -t wheezy util-linux echo "mtools_skip_check=1">~/.mtoolsrc mkdir /var/lib/libvirt/cloudinit chown libvirt-qemu /var/lib/libvirt/cloudinit * Clone repository git clone git://code.leap.se/leap_cloudadmin /usr/local/bin/leap_cloudadmin ln -s /usr/local/bin/leap_cloudadmin/create-guest-with-cloudinit /usr/local/bin/create-guest-with-cloudinit Clone Instance ============== * edit /etc/cloudinit/NAME.cfg, using vmtest.cfg.example from this repository as template: cp /usr/local/bin/leap_cloudadmin/vmtest.cfg.example /etc/cloudinit/NAME.cfg * create new VM: /usr/local/bin/create-guest-with-cloudinit -s 7 NAME * see /var/log/cloud-init.log on guest for information on cloudinit run Modify Userdata later, if needed ================================ mount -o loop /var/lib/libvirt/cloudinit/cloudinit-test-user-data.img /mnt Configure new guest =================== Networking ---------- * By default, eth0 uses NATed networking through the host virbr0. It gets an dynamic IP throught dhcp, and can access the internet through that. * To assign a static IP, either configure it in the condig file (recommended), or add it later after logging into the vm. Add according entry to /etc/network/interfaces, i.e.: allow-hotplug eth1 iface eth1 inet static address 94.103.43.9 netmask 255.255.255.0 network 94.103.43.0 broadcast 94.103.43.255 gateway 94.103.43.1 # dns-* options are implemented by the resolvconf package, if installed dns-nameservers 8.8.8.8 8.8.4.4 dns-search leap.se