Configurazione di Buildbot per le Macchine Virtuali - Ubuntu 12.10 "quantal"
Contents
Installazione base
qemu-img create -f qcow2 /kvm/vms/vm-quantal-amd64-serial.qcow2 10G qemu-img create -f qcow2 /kvm/vms/vm-quantal-i386-serial.qcow2 10G
Avviare tutte le VM dall'iso di installazione del server, una alla volta, ed effettuare i seguenti passaggi:
kvm -m 2048 -hda /kvm/vms/vm-quantal-amd64-serial.qcow2 -cdrom /kvm/iso/ubuntu/ubuntu-12.10-server-amd64.iso -boot d -smp 2 -cpu qemu64 -net nic,model=virtio -net user,hostfwd=tcp:127.0.0.1:2275-:22 kvm -m 2048 -hda /kvm/vms/vm-quantal-i386-serial.qcow2 -cdrom /kvm/iso/ubuntu/ubuntu-12.10-server-i386.iso -boot d -smp 2 -cpu qemu64 -net nic,model=virtio -net user,hostfwd=tcp:127.0.0.1:2276-:22
Una volta avviate, connettersi al server VNC dall'host locale:
vncviewer -via ${remote-host} localhost
Sostituire ${remote-host} con l'host su cui la vm è stata avviata.
Nota: Quando si attiva l'installazione, vncviewer potrebbe disconnettersi dicendo che il rect è troppo grande. Va tutto bene. Ubuntu ha semplicemente ridimensionato lo schermo vnc. Basta riconnettersi.
Installare, mantenendo per lo più i valori predefiniti, con qualche accorgimento:
- Impostare l'hostname a ubuntu-quantal-amd64 o ubuntu-quantal-i386
- Quando si partizionano i dischi, scegliere "Guided - use entire disk" (non vogliamo LVM)
- Niente aggiornamenti automatici
- Scegliere il software da installare: OpenSSH server
Ora che la VM è installata, bisogna configurarla. Se si ha abbastanza memoria, si possono eseguire le seguenti operazioni simultaneamente:
kvm -m 2048 -hda /kvm/vms/vm-quantal-amd64-serial.qcow2 -cdrom /kvm/iso/ubuntu/ubuntu-12.10-server-amd64.iso -boot c -smp 2 -cpu qemu64 -net nic,model=virtio -net user,hostfwd=tcp:127.0.0.1:2275-:22 -nographic kvm -m 2048 -hda /kvm/vms/vm-quantal-i386-serial.qcow2 -cdrom /kvm/iso/ubuntu/ubuntu-12.10-server-i386.iso -boot c -smp 2 -cpu qemu64 -net nic,model=virtio -net user,hostfwd=tcp:127.0.0.1:2276-:22 -nographic ssh -p 2275 localhost # edit /boot/grub/menu.lst and visudo, see below ssh -p 2276 localhost # edit /boot/grub/menu.lst and visudo, see below ssh -t -p 2275 localhost "mkdir -v .ssh; sudo addgroup $USER sudo" ssh -t -p 2276 localhost "mkdir -v .ssh; sudo addgroup $USER sudo" scp -P 2275 /kvm/vms/authorized_keys localhost:.ssh/ scp -P 2276 /kvm/vms/authorized_keys localhost:.ssh/ echo $'Buildbot\n\n\n\n\ny' | ssh -p 2275 localhost 'chmod -vR go-rwx .ssh; sudo adduser --disabled-password buildbot; sudo addgroup buildbot sudo; sudo mkdir -v ~buildbot/.ssh; sudo cp -vi .ssh/authorized_keys ~buildbot/.ssh/; sudo chown -vR buildbot:buildbot ~buildbot/.ssh; sudo chmod -vR go-rwx ~buildbot/.ssh' echo $'Buildbot\n\n\n\n\ny' | ssh -p 2276 localhost 'chmod -vR go-rwx .ssh; sudo adduser --disabled-password buildbot; sudo addgroup buildbot sudo; sudo mkdir -v ~buildbot/.ssh; sudo cp -vi .ssh/authorized_keys ~buildbot/.ssh/; sudo chown -vR buildbot:buildbot ~buildbot/.ssh; sudo chmod -vR go-rwx ~buildbot/.ssh' scp -P 2275 /kvm/vms/ttyS0.conf buildbot@localhost: scp -P 2276 /kvm/vms/ttyS0.conf buildbot@localhost: ssh -p 2275 buildbot@localhost 'sudo apt-get update && sudo apt-get -y dist-upgrade;' ssh -p 2276 buildbot@localhost 'sudo apt-get update && sudo apt-get -y dist-upgrade;' ssh -p 2275 buildbot@localhost 'sudo cp -vi ttyS0.conf /etc/init/; rm -v ttyS0.conf; sudo shutdown -h now' ssh -p 2276 buildbot@localhost 'sudo cp -vi ttyS0.conf /etc/init/; rm -v ttyS0.conf; sudo shutdown -h now'
Abilitare sudo senza password:
sudo VISUAL=vi visudo # Add line at end: `%sudo ALL=NOPASSWD: ALL'
Modificare /boot/grub/menu.lst:
sudo vi /etc/default/grub # Aggiungere/modificare queste voci: GRUB_CMDLINE_LINUX_DEFAULT="console=tty0 console=ttyS0,115200n8" GRUB_TERMINAL="serial" GRUB_SERIAL_COMMAND="serial --unit=0 --speed=115200 --word=8 --parity=no --stop=1" sudo update-grub # tornare all'host server
VM per creare i .deb
for i in '/kvm/vms/vm-quantal-amd64-serial.qcow2 2275 qemu64' '/kvm/vms/vm-quantal-i386-serial.qcow2 2276 qemu64' ; do \ set $i; \ runvm --user=buildbot --logfile=kernel_$2.log --base-image=$1 --port=$2 --cpu=$3 "$(echo $1 | sed -e 's/serial/build/')" \ "= scp -P $2 -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no /kvm/boost_1_49_0.tar.gz buildbot@localhost:/dev/shm/" \ "= scp -P $2 -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no /kvm/thrift-0.9.0.tar.gz buildbot@localhost:/dev/shm/" \ "sudo DEBIAN_FRONTEND=noninteractive apt-get update" \ "sudo DEBIAN_FRONTEND=noninteractive apt-get -y build-dep mysql-server-5.5" \ "sudo DEBIAN_FRONTEND=noninteractive apt-get install -y devscripts hardening-wrapper fakeroot doxygen texlive-latex-base ghostscript libevent-dev libssl-dev zlib1g-dev libpam0g-dev libreadline-gplv2-dev autoconf automake automake1.9 defoma dpatch ghostscript-x libfontenc1 libjpeg62 libltdl-dev libltdl7 libmail-sendmail-perl libxfont1 lmodern psfontmgr texlive-latex-base-doc ttf-dejavu ttf-dejavu-extra libaio-dev xfonts-encodings xfonts-utils" \ "cd /usr/local/src;sudo tar zxf /dev/shm/thrift-0.9.0.tar.gz;pwd;ls" \ "cd /usr/local/src/thrift-0.9.0;echo;pwd;sudo ./configure --prefix=/usr --enable-shared=no --enable-static=yes CXXFLAGS=-fPIC CFLAGS=-fPIC && echo && echo 'now making' && echo && sleep 3 && sudo make && echo && echo 'now installing' && echo && sleep 3 && sudo make install" \ "cd /usr/local/src;sudo tar zxf /dev/shm/boost_1_49_0.tar.gz;cd /usr/local/include/;sudo ln -vs ../src/boost_1_49_0/boost ." ; \ done
VM per testare l'installazione
Si veda Configurare Buildbot per le Macchine Virtuali - Principi generali per sapere come ottenere my.seed
e sources.append
.
for i in '/kvm/vms/vm-quantal-amd64-serial.qcow2 2275 qemu64' '/kvm/vms/vm-quantal-i386-serial.qcow2 2276 qemu64' ; do \ set $i; \ runvm --user=buildbot --logfile=kernel_$2.log --base-image=$1 --port=$2 --cpu=$3 "$(echo $1 | sed -e 's/serial/install/')" \ "sudo DEBIAN_FRONTEND=noninteractive apt-get update" \ "sudo DEBIAN_FRONTEND=noninteractive apt-get install -y patch libaio1 debconf-utils" \ "= scp -P $2 /kvm/vms/my55.seed /kvm/vms/sources.append buildbot@localhost:/tmp/" \ "sudo debconf-set-selections /tmp/my55.seed" \ "sudo sh -c 'cat /tmp/sources.append >> /etc/apt/sources.list'"; \ done
VM per testare l'upgrade di MySQL
for i in '/kvm/vms/vm-quantal-amd64-install.qcow2 2275 qemu64' '/kvm/vms/vm-quantal-i386-install.qcow2 2276 qemu64' ; do \ set $i; \ runvm --user=buildbot --logfile=kernel_$2.log --base-image=$1 --port=$2 --cpu=$3 "$(echo $1 | sed -e 's/install/upgrade/')" \ "sudo DEBIAN_FRONTEND=noninteractive apt-get install -y patch debconf-utils" \ 'sudo DEBIAN_FRONTEND=noninteractive apt-get install -y libaio1 mysql-server-5.5' \ 'sudo service mysql stop' \ 'sudo rm -rf /var/lib/mysql/' \ 'sudo mysql_install_db' \ 'sudo service mysql start' \ 'sudo mysqladmin --verbose -u root password "rootpass"' \ 'mysql -uroot -prootpass -e "create database mytest; use mytest; create table t(a int primary key); insert into t values (1); select * from t"' ;\ done
VM per testare l'upgrade di MariaDB
Le istruzioni qui sotto si basano su quelle per Natty alla pagina Installare le immagini delle VM per testare l'aggiornamento dei .deb.
for i in '/kvm/vms/vm-quantal-amd64-serial.qcow2 2275 qemu64' '/kvm/vms/vm-quantal-i386-serial.qcow2 2276 qemu64' ; do \ set $i; \ runvm --user=buildbot --logfile=kernel_$2.log --base-image=$1 --port=$2 --cpu=$3 "$(echo $1 | sed -e 's/serial/upgrade2/')" \ "= scp -P $2 -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no /kvm/vms/mariadb-quantal.list buildbot@localhost:/tmp/tmp.list" \ 'sudo mv -vi /tmp/tmp.list /etc/apt/sources.list.d/' \ 'sudo apt-key adv --recv-keys --keyserver keyserver.ubuntu.com 1BB943DB' \ 'sudo apt-get update' \ 'sudo DEBIAN_FRONTEND=noninteractive apt-get install -y --allow-unauthenticated mariadb-server mariadb-server-5.5 mariadb-client mariadb-client-5.5 mariadb-test libmariadbclient-dev' \ 'sudo apt-get -f install' \ 'sudo mysqladmin -u root password "rootpass"' \ 'sudo /etc/init.d/mysql restart' \ 'mysql -uroot -prootpass -e "create database mytest; use mytest; create table t(a int primary key); insert into t values (1); select * from t"' \ 'sudo rm -v /etc/apt/sources.list.d/tmp.list' \ 'sudo apt-get update' \ 'sudo DEBIAN_FRONTEND=noninteractive apt-get install -y libaio1' \ 'sudo DEBIAN_FRONTEND=noninteractive apt-get upgrade -y'; \ done
Aggiungere le chiavi a known_hosts
Seguire queste istruzioni su ogni server kvm (terrier, terrier2, i7, etc...) per aggiungere le VM a known_hosts.
# quantal-amd64 cp -avi /kvm/vms/vm-quantal-amd64-install.qcow2 /kvm/vms/vm-quantal-amd64-test.qcow2 kvm -m 1024 -hda /kvm/vms/vm-quantal-amd64-test.qcow2 -redir tcp:2275::22 -boot c -smp 2 -cpu qemu64 -net nic,model=virtio -net user -nographic sudo su - buildbot ssh -p 2275 buildbot@localhost sudo shutdown -h now # answer "yes" when prompted exit # the buildbot user rm -v /kvm/vms/vm-quantal-amd64-test.qcow2 # quantal-i386 cp -avi /kvm/vms/vm-quantal-i386-install.qcow2 /kvm/vms/vm-quantal-i386-test.qcow2 kvm -m 1024 -hda /kvm/vms/vm-quantal-i386-test.qcow2 -redir tcp:2276::22 -boot c -smp 2 -cpu qemu64 -net nic,model=virtio -net user -nographic sudo su - buildbot ssh -p 2276 buildbot@localhost sudo shutdown -h now # answer "yes" when prompted exit # the buildbot user rm -v /kvm/vms/vm-quantal-i386-test.qcow2