diff options
author | ramon <ramongomez@us.es> | 2016-03-14 10:07:41 +0000 |
---|---|---|
committer | ramon <ramongomez@us.es> | 2016-03-14 10:07:41 +0000 |
commit | aeedc72b0de0aeb278e2ba2ca05dbc21aecfda51 (patch) | |
tree | 528c3902c490ae6283f27dc8b2764cb75404a55f /installer | |
parent | b781e8bc51214e3034a55ab76db7630110b71373 (diff) |
#739: Ficheros para crear 2 entornos de trabajo virtuales para versión oficial y para versión en desarrollo 1.1; añadir instrucciones de uso.
git-svn-id: https://opengnsys.es/svn/branches/version1.1@4822 a21b9725-9963-47de-94b9-378ad31fedc9
Diffstat (limited to 'installer')
-rw-r--r-- | installer/vagrant/README.es.txt | 61 | ||||
-rw-r--r-- | installer/vagrant/Vagrantfile-1.1-vbox | 105 | ||||
-rw-r--r-- | installer/vagrant/Vagrantfile-trunk-vbox | 105 |
3 files changed, 271 insertions, 0 deletions
diff --git a/installer/vagrant/README.es.txt b/installer/vagrant/README.es.txt new file mode 100644 index 00000000..30c99c34 --- /dev/null +++ b/installer/vagrant/README.es.txt @@ -0,0 +1,61 @@ + +Preparar entorno virtual de desarrollo para OpenGnsys +===================================================== + + +Ficheros de configuración disponibles: + + - Vagrantfile-trunk-vbox Vagrantfile para OpenGnsys oficial con proveedor VirtualBox. + - Vagrantfile-1.1-vbox Vagrantfile para OpenGnsys en desarrollo con proveedor VirtualBox. + + +Requisitos previos. + + - Instalar Oracle VM VirtualBox 5.0 con su Extension Pack. + - Instalar la última versión oficial de Vagrant (no usar la incluida en Ubuntu 14.04). + + +El entorno de trabajo. + + - opengnsys: MV para servidor OpenGnsys basada en Ubuntu 14.04 y 2º disco para repositorio. + - virt1: MV cliente modelo con Ubuntu 14.04 instalado. + - virt2: MV cliente para clonar con disco vacío. + + +Ejecutar el entorno virtual. + + - Crear un directorio de trabajo. + - Copiar el fichero Vagrantfile correspondiente en dicho directorio como Vagrantfile. + - Opcional: editar las variables de configuración del fichero Vagrantfile para el entorno personal. + - REPODISK, REPOSIZE: fichero y tamaño (en GB) del disco duro virtual para el repositorio de imágenes. + - SERVERMEM, CLIENTMEM: memoria virtual (en MB) para servidor y clientes. + - NETPREFIX: prefijo para las direcciones IP de la red virtual. + - MACPREFIX: prefijo para las direcciones MAC de los clientes. + - LOCALWEBPORT: puerto local para acceder al web de administración del servidor. + + - Iniciar la MV del servidor: + vagrant up opengnsys + - Iniciar las MV de los clientes (tras iniciar el servidor): + vagrant up virt1 + vagrant up virt2 + +Nota: los procesos de inicio pueden tardar varios minutos en la primera ejecución, porque descargan y configuran las máquinas virtuales. +Nota: antes de iniciar las MV de los clientes, debe accederse a la web de OpenGnsys para crear el aula e incorporar los equipos. + + +Descripción de las MV. + + - Máquina virtual opengnsys. + - Usuario de acceso SSH: vagrant, clave: vagrant. + - La interfaz 2 de VirtualBox está definida en la red privada para las MV del entorno. + - Instalación de OpenGnsys Server con datos por defecto. + - Acceder desde un navegador del host local a la web de OpenGnsys en la URL: + https://localhost:8443/opengnsys/ + - Configurar el DHCP usando las direcciones MAC de los clientes según lo indicado en la definición de la interfaz 2 de cada MV en Virtual Box. + + - Máquinas virtuales para cliente modelo y cliente para clonar. + - La interfaz 2 de cada MV VirtualBox está definida en la red privada del entorno. + - Ignorar los posibles errores de conexión de Vagrant. + - Usar VirtualBox para deshabilitar la interfaz 1 de las MV cliente. + - Una vez desplegadas las MV deberán ser controladas directamente con VirtaulBox. + diff --git a/installer/vagrant/Vagrantfile-1.1-vbox b/installer/vagrant/Vagrantfile-1.1-vbox new file mode 100644 index 00000000..1d0d3784 --- /dev/null +++ b/installer/vagrant/Vagrantfile-1.1-vbox @@ -0,0 +1,105 @@ +# Vagrantfile to install OpenGnsys 1.1 virtual environment using VirtualBox provider. + +VAGRANTFILE_API_VERSION = "2" +# VM provider: Oracle VM VirtualBox. +ENV['VAGRANT_DEFAULT_PROVIDER'] = "virtualbox" +# Language. +ENV['LC_ALL'] = "es_ES.UTF-8" + +# Repository virtual disk: file and size (GB). +REPODISK = "repo.vdi" +REPOSIZE = 50 +# Amount of memory for server and clients (MB) +SERVERMEM = 1024 +CLIENTMEM = 512 +# Clients MAC address prefix. +MACPREFIX = "08:00:27:0E:65:" +NETPREFIX = "192.168.50." +# Local port to access OpenGnsys Server. +LOCALWEBPORT = 8443 + +# OpenGnsys Server provisioning script: prepare repo disk, install OpenGnsys, change default interface, configure DHCP server. +OGSERVERSCRIPT = <<EOT +test -n "$(blkid /dev/sdb1 | grep ext4)" && exit +echo -e "o\nn\np\n\n\n\nw" | fdisk /dev/sdb +mkfs -t ext4 /dev/sdb1 +mkdir -p /opt/opengnsys/images +echo "/dev/sdb1 /opt/opengnsys/images ext4 defaults 0 0" >> /etc/fstab +mount -a +wget -q http://opengnsys.es/svn/branches/version1.1/installer/opengnsys_installer.sh -O - | bash +cp /etc/dhcp/dhcpd-eth1.conf /etc/dhcp/dhcpd-eth1-orig.conf # temporal +echo y | sudo /opt/opengnsys/bin/setserveraddr eth1 +echo "New OpenGnsys local URL: https://localhost:#{LOCALWEBPORT}/opengnsys/" +sed -e 's/routers /routers #{NETPREFIX}1/' /etc/dhcp/dhcpd-eth1-orig.conf >/etc/dhcp/dhcpd.conf # temporal +sed -i -e 's#://[^/]*/#://#{NETPREFIX}10/#g' /opt/opengnsys/www/controlacceso.php # temporal +sed -i -e 's#://[^/]*/#://#{NETPREFIX}10/#g' /opt/opengnsys/client/etc/ogAdmClient.cfg # temporal +sed -i '/^}/d' /etc/dhcp/dhcpd.conf +echo " + host virt1 { hardware ethernet #{MACPREFIX}01; fixed-address #{NETPREFIX}101; } + host virt2 { hardware ethernet #{MACPREFIX}02; fixed-address #{NETPREFIX}102; } +}" >> /etc/dhcp/dhcpd.conf +service isc-dhcp-server restart +locale-gen --lang es_ES +EOT + +Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| + + # OpenGnsys Server VM definition. + config.vm.define "opengnsys" do |og| + # Specific VirtualBox configuration. + og.vm.provider "virtualbox" do |vb| + # VM name, memory and CPUs. + vb.name = "opengnsys" + vb.memory = SERVERMEM + vb.cpus = 1 + # Get VM disk path + line = `VBoxManage list systemproperties | grep "Default machine folder"` + vb_machine_folder = line.split(':')[1].strip() + second_disk = File.join(vb_machine_folder, vb.name, REPODISK) + # Create repo virtual disk, if needed. + unless File.exist?(second_disk) + vb.customize ['createhd', '--filename', second_disk, '--size', REPOSIZE * 1024] + end + # Attach repo virtual disk. + vb.customize ['storageattach', :id, '--storagectl', 'SATAController', '--port', 1, '--device', 0, '--type', 'hdd', '--medium', second_disk] + end + # VM base and host name. + og.vm.box = "ubuntu/trusty64" + og.vm.hostname = "opengnsys" + # Network configuration: forward web port and attach new interface to VMs private network. + og.vm.network "forwarded_port", guest: 443, host: 8443 + og.vm.network "private_network", ip: "#{NETPREFIX}10", virtualbox__intnet: true + # Launch provisioning script. + og.vm.provision "shell", inline: OGSERVERSCRIPT + end + + # Client 1 VM definition. + config.vm.define "virt1" do |v1| + v1.vm.box = "ubuntu/trusty64" + v1.vm.hostname = "virt1" + v1.vm.network "private_network", mac: "#{MACPREFIX}01".tr(":",""), type: "dhcp", virtualbox__intnet: true + v1.vm.provider "virtualbox" do |vb| + vb.name = "virt1" + vb.memory = CLIENTMEM + vb.cpus = 1 + vb.customize ['modifyvm', :id, '--boot1', 'net', '--boot2', 'disk'] + end + end + + # Client 2 VM definition. + config.vm.define "virt2" do |v2| + v2.vm.box = "clink15/pxe" + v2.ssh.insert_key = false + v2.vm.boot_timeout = 5 + v2.vm.network "private_network", mac: "#{MACPREFIX}02".tr(":",""), type: "dhcp", virtualbox__intnet: true + v2.vm.provider "virtualbox" do |vb| + vb.name = "virt2" + vb.memory = CLIENTMEM + vb.cpus = 1 + vb.customize ['modifyvm', :id, '--boot1', 'net', '--boot2', 'disk'] + vb.customize ["modifyvm", :id, "--nic1", "none"] + end + end + +end + diff --git a/installer/vagrant/Vagrantfile-trunk-vbox b/installer/vagrant/Vagrantfile-trunk-vbox new file mode 100644 index 00000000..edf2d9da --- /dev/null +++ b/installer/vagrant/Vagrantfile-trunk-vbox @@ -0,0 +1,105 @@ +# Vagrantfile to install OpenGnsys Trunk virtual environment using VirtualBox provider. + +VAGRANTFILE_API_VERSION = "2" +# VM provider: Oracle VM VirtualBox. +ENV['VAGRANT_DEFAULT_PROVIDER'] = "virtualbox" +# Language. +ENV['LC_ALL'] = "es_ES.UTF-8" + +# Repository virtual disk: file and size (GB). +REPODISK = "repo.vdi" +REPOSIZE = 50 +# Amount of memory for server and clients (MB) +SERVERMEM = 1024 +CLIENTMEM = 512 +# Clients MAC address prefix. +MACPREFIX = "08:00:27:0E:65:" +NETPREFIX = "192.168.50." +# Local port to access OpenGnsys Server. +LOCALWEBPORT = 8443 + +# OpenGnsys Server provisioning script: prepare repo disk, install OpenGnsys, change default interface, configure DHCP server. +OGSERVERSCRIPT = <<EOT +test -n "$(blkid /dev/sdb1 | grep ext4)" && exit +echo -e "o\nn\np\n\n\n\nw" | fdisk /dev/sdb +mkfs -t ext4 /dev/sdb1 +mkdir -p /opt/opengnsys/images +echo "/dev/sdb1 /opt/opengnsys/images ext4 defaults 0 0" >> /etc/fstab +mount -a +wget -q http://opengnsys.es/svn/trunk/installer/opengnsys_installer.sh -O - | bash +cp /etc/dhcp/dhcpd-eth1.conf /etc/dhcp/dhcpd-eth1-orig.conf # temporal +echo y | sudo /opt/opengnsys/bin/setserveraddr eth1 +echo "New OpenGnsys local URL: https://localhost:#{LOCALWEBPORT}/opengnsys/" +sed -e 's/routers /routers #{NETPREFIX}1/' /etc/dhcp/dhcpd-eth1-orig.conf >/etc/dhcp/dhcpd.conf # temporal +sed -i -e 's#://[^/]*/#://#{NETPREFIX}10/#g' /opt/opengnsys/www/controlacceso.php # temporal +sed -i -e 's#://[^/]*/#://#{NETPREFIX}10/#g' /opt/opengnsys/client/etc/ogAdmClient.cfg # temporal +sed -i '/^}/d' /etc/dhcp/dhcpd.conf +echo " + host virt1 { hardware ethernet #{MACPREFIX}01; fixed-address #{NETPREFIX}101; } + host virt2 { hardware ethernet #{MACPREFIX}02; fixed-address #{NETPREFIX}102; } +}" >> /etc/dhcp/dhcpd.conf +service isc-dhcp-server restart +locale-gen --lang es_ES +EOT + +Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| + + # OpenGnsys Server VM definition. + config.vm.define "opengnsys" do |og| + # Specific VirtualBox configuration. + og.vm.provider "virtualbox" do |vb| + # VM name, memory and CPUs. + vb.name = "opengnsys" + vb.memory = SERVERMEM + vb.cpus = 1 + # Get VM disk path + line = `VBoxManage list systemproperties | grep "Default machine folder"` + vb_machine_folder = line.split(':')[1].strip() + second_disk = File.join(vb_machine_folder, vb.name, REPODISK) + # Create repo virtual disk, if needed. + unless File.exist?(second_disk) + vb.customize ['createhd', '--filename', second_disk, '--size', REPOSIZE * 1024] + end + # Attach repo virtual disk. + vb.customize ['storageattach', :id, '--storagectl', 'SATAController', '--port', 1, '--device', 0, '--type', 'hdd', '--medium', second_disk] + end + # VM base and host name. + og.vm.box = "ubuntu/trusty64" + og.vm.hostname = "opengnsys" + # Network configuration: forward web port and attach new interface to VMs private network. + og.vm.network "forwarded_port", guest: 443, host: 8443 + og.vm.network "private_network", ip: "#{NETPREFIX}10", virtualbox__intnet: true + # Launch provisioning script. + og.vm.provision "shell", inline: OGSERVERSCRIPT + end + + # Client 1 VM definition. + config.vm.define "virt1" do |v1| + v1.vm.box = "ubuntu/trusty64" + v1.vm.hostname = "virt1" + v1.vm.network "private_network", mac: "#{MACPREFIX}01".tr(":",""), type: "dhcp", virtualbox__intnet: true + v1.vm.provider "virtualbox" do |vb| + vb.name = "virt1" + vb.memory = CLIENTMEM + vb.cpus = 1 + vb.customize ['modifyvm', :id, '--boot1', 'net', '--boot2', 'disk'] + end + end + + # Client 2 VM definition. + config.vm.define "virt2" do |v2| + v2.vm.box = "clink15/pxe" + v2.ssh.insert_key = false + v2.vm.boot_timeout = 5 + v2.vm.network "private_network", mac: "#{MACPREFIX}02".tr(":",""), type: "dhcp", virtualbox__intnet: true + v2.vm.provider "virtualbox" do |vb| + vb.name = "virt2" + vb.memory = CLIENTMEM + vb.cpus = 1 + vb.customize ['modifyvm', :id, '--boot1', 'net', '--boot2', 'disk'] + vb.customize ["modifyvm", :id, "--nic1", "none"] + end + end + +end + |