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
77
78
79
80
81
82
83
84
85
86
87
|
=====================
Leap Cloudadmin Tools
=====================
Tools to clone a new kvm instance from an existing baseimage, using LVM.
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
** should set root password # currently broken
** generate ssh host keys
** adding ssh keys to /root.ssh/authorized_keys so they can log in
** apt-get update/upgrade
Setup (once)
============
apt-get install dosfstools mtools
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/libvirt/local/cloudinit/NAME.cfg
* create new VM:
/usr/local/bin/create-guest-with-cloudinit -r 7 -n 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 213.73.91.35 62.141.58.13
dns-search leap.se
License
=======
see LICENSE file
|