summaryrefslogtreecommitdiff
path: root/README.md
blob: 80467bb2d2dfd1e605e0d82ae4fd2f7f089bea0d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
=====================
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 Instance
==============

* edit /etc/cloudinit/NAME.cfg, using vmtest.cfg.example from this repository as template
* 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, 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