Projet

Général

Profil

Openstack Setup VM pas dans openstack » Historique » Version 8

Mehdi Abaakouk, 16/10/2014 13:15

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