Tutorial pentru asistenti

Tutorialul pentru asistenti contine, in plus fata de cel pentru studenti, si etapele crearii unui template nou.

Pentru crearea unui image template nou vom folosi utilitarul packer. Acesta se afla instalat in /opt/packer. Cu ajutorul acestuia vom putea crea template-uri pentru orice cloud provider sau tip de virtualizare (Virtual Box, kvm).

Pasii pentru crearea unui image template folosind packer sunt:

1. Autentificarea pe Openstack

source openstack/openstackrc

2. Crearea unui fisier in format Json ce va contine succesiunea de pasi necesari construirii template-ului

Fisierul Json poate fi ulterior stocat intr-un  sistem de versionare (git,svn) si reutilizat/actualizat ori de cat ori este nevoie.

{
"builders": [{
 "type": "openstack",
 "ssh_username": "ubuntu",
 "image_name": "my_custom_template",
 "source_image": "54809904-2740-41c1-ad29-762eafa7b15f",
 "flavor": "e49e1d5a-d002-4d47-bf63-80436772c539",
}],

"provisioners": [{
 "type": "shell",
 "inline": [
 "sleep 30",
 "sudo apt-get update",
 "sudo apt-get install -y python-pip python-dev gcc",
 "sudo pip install heat-cfntools",
 "sudo apt-get clean"
 ]
 }]
}

3. Crearea template-ului propriu-zis

packer build ./template.json
openstack output will be in this color.

==> openstack: Creating temporary keypair for this instance...
==> openstack: Waiting for server (48350145-de9f-4af5-a791-14bb8522a0ed) to become ready...
==> openstack: Created temporary floating IP 10.42.129.134...
==> openstack: Added floating IP 10.42.129.134 to instance...
==> openstack: Waiting for SSH to become available...
==> openstack: Connected to SSH!
==> openstack: Provisioning with shell script: /tmp/packer-shell728100927
[output skipped]
==> openstack: Creating the image: my_custom_template
==> openstack: Image: 20ca6b20-7b13-45d1-89ad-a953065a493a
==> openstack: Waiting for image to become ready...
==> openstack: Deleted temporary floating IP 10.42.129.134
==> openstack: Terminating the source server...
==> openstack: Deleting temporary keypair...
Build 'openstack' finished.

4. Convertirea template-ului privat intr-o imagine publica

In acest moment, template-ul este gata. Acesta va avea ID-ul 20ca6b20-7b13-45d1-89ad-a953065a493a in cazul de fata. Pentru a avea un template public, accesibil tuturor, trebuie sa il facem public

glance image-download 20ca6b20-7b13-45d1-89ad-a953065a493a > tmp.qcow2
glamce image-create --name="my_image_template" --disk-format=qcow2 --container-format=bare --is-public True --file tmp.qcow2 --progress --is-protected True
nova image-delete 20ca6b20-7b13-45d1-89ad-a953065a493a

In acest moment, template-ul este public si poate fi utilizat de oricine.

 

Leave a Reply