Projet

Général

Profil

Openstack Setup VM pas dans openstack » Historique » Version 5

Mehdi Abaakouk, 16/10/2014 12:50

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