Project

General

Profile

Openstack Setup VM pas dans openstack » History » Version 1

Mehdi Abaakouk, 10/16/2014 12:29 PM

1 1 Mehdi Abaakouk
h1. Openstack Setup VM pas dans openstack
2 1 Mehdi Abaakouk
3 1 Mehdi Abaakouk
h2. Use case maposmatic
4 1 Mehdi Abaakouk
5 1 Mehdi Abaakouk
Preparation du fichier hook pour "build-openstack-debian-image"
6 1 Mehdi Abaakouk
7 1 Mehdi Abaakouk
<pre>
8 1 Mehdi Abaakouk
# cat maposmatic-hook.sh 
9 1 Mehdi Abaakouk
set -xv
10 1 Mehdi Abaakouk
11 1 Mehdi Abaakouk
echo "maposmatic" > $BODI_CHROOT_PATH/etc/hostname
12 1 Mehdi Abaakouk
13 1 Mehdi Abaakouk
cat > $BODI_CHROOT_PATH/etc/resolv.conf <<EOF
14 1 Mehdi Abaakouk
domain tetaneutral.net
15 1 Mehdi Abaakouk
search tetaneutral.net
16 1 Mehdi Abaakouk
nameserver 91.224.149.254
17 1 Mehdi Abaakouk
nameserver 91.224.148.10
18 1 Mehdi Abaakouk
EOF
19 1 Mehdi Abaakouk
20 1 Mehdi Abaakouk
cat > $BODI_CHROOT_PATH/etc/network/interfaces <<EOF
21 1 Mehdi Abaakouk
auto lo
22 1 Mehdi Abaakouk
iface lo inet loopback
23 1 Mehdi Abaakouk
auto eth0
24 1 Mehdi Abaakouk
iface eth0 inet manual
25 1 Mehdi Abaakouk
  pre-up /sbin/sysctl -w net.ipv6.conf.eth0.accept_ra=0
26 1 Mehdi Abaakouk
  pre-up /sbin/sysctl -w net.ipv6.conf.eth0.autoconf=0
27 1 Mehdi Abaakouk
  up ip link set eth0 up
28 1 Mehdi Abaakouk
  up ip addr add 89.234.156.232/32 dev eth0
29 1 Mehdi Abaakouk
  up ip route add 91.224.149.0/24 dev eth0
30 1 Mehdi Abaakouk
  up ip route add default via 91.224.149.254
31 1 Mehdi Abaakouk
32 1 Mehdi Abaakouk
iface eth0 inet6 static
33 1 Mehdi Abaakouk
    pre-up /sbin/sysctl -w net.ipv6.conf.eth0.accept_ra=0
34 1 Mehdi Abaakouk
    pre-up /sbin/sysctl -w net.ipv6.conf.eth0.autoconf=0
35 1 Mehdi Abaakouk
    address 2a01:6600:8083:e800::1
36 1 Mehdi Abaakouk
    netmask 56
37 1 Mehdi Abaakouk
    gateway fe80::31
38 1 Mehdi Abaakouk
EOF
39 1 Mehdi Abaakouk
40 1 Mehdi Abaakouk
mkdir -p $BODI_CHROOT_PATH/root/.ssh
41 1 Mehdi Abaakouk
chmod 600 $BODI_CHROOT_PATH/root/.ssh
42 1 Mehdi Abaakouk
cat >> $BODI_CHROOT_PATH/root/.ssh/authorized_keys <<EOF
43 1 Mehdi Abaakouk
ssh-dss AAAAB3NzaC1kc3MAAACBAJtnGLvuz4uVD6fnERDxDi/C0UyzwCiKmgNtEessopREYasAX4Gu6Fg10jAyIL5Nuc7YDnqj//pOfxNjD7hp99a2ZmkRQgh/ltClxYML9fqhBHgsUCpVse9nOYDHDnDgvXIPRSDUHat2UFpdchHVrFURNLIlZnBztsr+GCDURTV/AAAAFQD9SrBcH49ltaKOm6V5ssCPmgs1SwAAAIAbAvkQ3/tMzzdACO5B9s5Yb3ZuM7XImm0iqufivVf2Xy39g8HOBulUsN7eKEGPhVriqNolgIO7q7tVgYAff4/NE4yDP0Kp0SPg4tjt2yFJuL31Y3wzwHjnKrjgNlDSLl3uZnRXSipwUMwGKbdHB6NZSqlq192VKbHilQ00pbiMlAAAAIB5dfB1lVHkJ0o5CcaVQRPbca9DvbbRwnoTSmKHc5DUcqsPqDhS07CkM9ZcJuY1Nh4wGl4Q9kArj7Tnsvvygf/HReSUcIk4+nbDytJ8/pca/Qx4fzQQyppa94TylN62LSFT6MIJKLoMwYa0dQURT7Mv5+9Qj2vk5pZ38w2iQ9zVCg== root@h1
44 1 Mehdi Abaakouk
ssh-dss AAAAB3NzaC1kc3MAAACBALnkOhUs6zyiHfllmziS+wmxTs+rpV3Up3N7R9Sha/X5mxwy0YHPT1B0/xi9dcxxYVty6C0sUHsncXQ1o8MRYFnILswVv5fwn8bpwYVDnFyjc7quOZa4XBbriyJ9+EuTMt1ereEV3wMPkBLfX6mhqxtCaNrN/9oeuxGG53ej+dCjAAAAFQDt7TB5ka3UTaOZnjjtl1B60SNmQwAAAIBbBStlNvCRyTUElesZzMDrnAhYYYMju0lQvptEaiaXZA3/nBbvYg1kMkGyUnpovj7KkljVn2YBSyywqCsiUDtT2y0rshUHxa8mn3nlD2+5jADUFK/SAki4fNlMcPBbcFhqJ7Yr5mv1TNtgW4lNhuZFEv40nqbP6RdZXPPvicHvXwAAAIBQEqvH0oMYcrbSgo2/10sFqmspY00HcKWNW5bJCERQr85UwAFtmGXz3CclIcINyPngNHmrexkQWQ5cb2xcFgR8gb2RinyjvPnSAU6ZyfMKjjqYVrMDzkcDYJu9q+NHYL6WZuXltS0RiZa0v83pI8WjywZkOPgaVexvVr+0RtkW9g== maxime@petazzoni
45 1 Mehdi Abaakouk
EOF
46 1 Mehdi Abaakouk
47 1 Mehdi Abaakouk
sed -i -e 's/^.*Port.*$/Port 2222/' -e 's/^[# ]*PasswordAuthentication.*$/PasswordAuthentication no/' $BODI_CHROOT_PATH/etc/ssh/sshd_config
48 1 Mehdi Abaakouk
chroot $BODI_CHROOT_PATH dpkg-reconfigure openssh-server
49 1 Mehdi Abaakouk
chroot $BODI_CHROOT_PATH apt-get purge -y cloud-init*
50 1 Mehdi Abaakouk
chroot $BODI_CHROOT_PATH passwd -d root
51 1 Mehdi Abaakouk
</pre>
52 1 Mehdi Abaakouk
53 1 Mehdi Abaakouk
Preparation de l'image disk
54 1 Mehdi Abaakouk
55 1 Mehdi Abaakouk
<pre>
56 1 Mehdi Abaakouk
/root/tools/images/build-openstack-debian-image --image-size 20 --release jessie  -u http://apt.tetaneutral.net/debian/ -s http://apt.tetaneutral.net/debian/ --no-dhcp -e acpi-support --output maposmatic --hook maposmatic-hook.sh
57 1 Mehdi Abaakouk
mv maposmatic.raw /maposmatic.raw
58 1 Mehdi Abaakouk
</pre>
59 1 Mehdi Abaakouk
60 1 Mehdi Abaakouk
Setup de la VM
61 1 Mehdi Abaakouk
62 1 Mehdi Abaakouk
<pre>
63 1 Mehdi Abaakouk
virt-install --name maposmatic --vcpus=4,maxvcpus=8 --memory 8192,maxmemory=16384 --network bridge=br-eth0,model=virtio --nographics --serial pty --wait -1 --noreboot --autostart --disk /maposmatic.raw,bus=virtio,cache=none,io=native --disk /dev/sdb,bus=virtio,cache=none,io=native --disk /dev/sdc,bus=virtio,cache=none,io=native --import
64 1 Mehdi Abaakouk
<pre>
65 1 Mehdi Abaakouk
66 1 Mehdi Abaakouk
Modification du xml pour les trucs non pris en charge par virt-install:
67 1 Mehdi Abaakouk
68 1 Mehdi Abaakouk
<pre>
69 1 Mehdi Abaakouk
virsh edit maposmatic
70 1 Mehdi Abaakouk
71 1 Mehdi Abaakouk
# Pour chaque bridge ajouter, le vlan et openvswitch comme ceci:
72 1 Mehdi Abaakouk
    <vlan><tag id='3132'/></vlan><virtualport type='openvswitch'/>
73 1 Mehdi Abaakouk
74 1 Mehdi Abaakouk
# Pour ceph, remplacer:
75 1 Mehdi Abaakouk
76 1 Mehdi Abaakouk
    <disk type='file' device='disk'>
77 1 Mehdi Abaakouk
      <driver name='qemu' type='raw' cache='none' io='native'/>
78 1 Mehdi Abaakouk
      <source file='/maposmatic.raw'/>
79 1 Mehdi Abaakouk
      <target dev='vda' bus='virtio'/>
80 1 Mehdi Abaakouk
      <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/>
81 1 Mehdi Abaakouk
    </disk>
82 1 Mehdi Abaakouk
83 1 Mehdi Abaakouk
# Par:
84 1 Mehdi Abaakouk
85 1 Mehdi Abaakouk
    <disk type='network' device='disk'>
86 1 Mehdi Abaakouk
        <driver name='qemu' type='raw'/>
87 1 Mehdi Abaakouk
        <source protocol='rbd' name='ssds/maposmatic-disk'>
88 1 Mehdi Abaakouk
                <host name='192.168.99.101' port='6789'/>
89 1 Mehdi Abaakouk
                <host name='192.168.99.102' port='6789'/>
90 1 Mehdi Abaakouk
                <host name='192.168.99.103' port='6789'/>
91 1 Mehdi Abaakouk
        </source>
92 1 Mehdi Abaakouk
        <auth username='openstack-service'>
93 1 Mehdi Abaakouk
            <secret type='ceph' uuid='1fe74663-8dfa-486c-bb80-3bd94c90c967'/>
94 1 Mehdi Abaakouk
        </auth>
95 1 Mehdi Abaakouk
        <target dev='vda' bus='virtio'/>
96 1 Mehdi Abaakouk
        <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/>
97 1 Mehdi Abaakouk
    </disk>
98 1 Mehdi Abaakouk
</pre>
99 1 Mehdi Abaakouk
100 1 Mehdi Abaakouk
puis import du disque dans ceph
101 1 Mehdi Abaakouk
102 1 Mehdi Abaakouk
<pre>
103 1 Mehdi Abaakouk
rbd -p ssds import /maposmatic.raw  maposmatic-disk
104 1 Mehdi Abaakouk
</pre>
105 1 Mehdi Abaakouk
106 1 Mehdi Abaakouk
Boot de la VM
107 1 Mehdi Abaakouk
108 1 Mehdi Abaakouk
<pre>
109 1 Mehdi Abaakouk
virsh start openstack
110 1 Mehdi Abaakouk
</pre>