source: installer/vagrant/Vagrantfile-devel-vbox @ f009c3d

918-git-images-111dconfigfileconfigure-oglivegit-imageslgromero-new-oglivemainmaint-cronmount-efivarfsmultivmmultivm-ogboot-installerogClonningEngineogboot-installer-jenkinsoglive-ipv6test-python-scriptsticket-301ticket-50ticket-50-oldticket-577ticket-585ticket-611ticket-612ticket-693ticket-700ubu24tplunification2use-local-agent-oglivevarios-instalacionwebconsole3
Last change on this file since f009c3d was dced872, checked in by ramon <ramongomez@…>, 8 years ago

#730 Instalador compatibile con CentOS 7; usar últimos ogLive y actulizar tickets cerrados.

git-svn-id: https://opengnsys.es/svn/branches/version1.1@5361 a21b9725-9963-47de-94b9-378ad31fedc9

  • Property mode set to 100644
File size: 8.0 KB
RevLine 
[aeedc72]1# Vagrantfile to install OpenGnsys 1.1 virtual environment using VirtualBox provider.
2
3VAGRANTFILE_API_VERSION = "2"
4# VM provider: Oracle VM VirtualBox.
5ENV['VAGRANT_DEFAULT_PROVIDER'] = "virtualbox"
[4f19d25]6# Language (accepted values: es_ES, ca_ES, en_GB).
[84b21fce]7LANGUAGE = "es_ES"
8ENV['LC_ALL'] = LANGUAGE + ".UTF-8"
[4f19d25]9# Number of OpenGnsys clients (accepted values: from 2 to 9).
10NCLIENTS = 4
[aeedc72]11# Repository virtual disk: file and size (GB).
[4f19d25]12REPODISK = "ogRepo.vdi"
[aeedc72]13REPOSIZE = 50
14# Amount of memory for server and clients (MB)
[b32e00f]15SERVERMEM = 1024        # Minimum: 512
16CLIENTMEM = 512         # Minimum: 256
[aeedc72]17# Clients MAC address prefix.
18MACPREFIX = "08:00:27:0E:65:"
[4f19d25]19NETPREFIX = "192.168.2."
[aeedc72]20# Local port to access OpenGnsys Server.
21LOCALWEBPORT = 8443
22
23# OpenGnsys Server provisioning script: prepare repo disk, install OpenGnsys, change default interface, configure DHCP server.
24OGSERVERSCRIPT = <<EOT
[ccec614]25# Exit if OpenGnsys is installed.
26[ -f /opt/opengnsys/doc/VERSION.txt ] && echo "Cannot provision, OpenGnsys is already installed." && exit 1
27# Mount repository disk, if necesary.
28if [ -n "$(blkid /dev/sdb1 | grep ext4)" ]; then
29    echo -e "o\nn\np\n\n\n\nw" | fdisk /dev/sdb
30    mkfs -t ext4 /dev/sdb1
31    mkdir -p /opt/opengnsys/images
32    echo "/dev/sdb1  /opt/opengnsys/images  ext4  defaults  0  0" >> /etc/fstab
33    mount -a
34fi
[2e97c42]35# Install OpenGnsys and change server address.
[4707481]36wget -q http://opengnsys.es/svn/branches/version1.1/installer/opengnsys_installer.sh -O - | bash || exit $?
37mv /opt/opengnsys/log/bash.log /opt/opengnsys/log/opengnsys_installer.log
38echo y | /opt/opengnsys/bin/setserveraddr enp0s8
[2e97c42]39# Insert DHCP data.
[4f19d25]40for ((i=#{NCLIENTS}; i>0; i--)); do
41    sed -i "/^}$/ i host ogClient0${i} { hardware ethernet #{MACPREFIX}0${i}; fixed-address #{NETPREFIX}1${i}; }" /etc/dhcp/dhcpd.conf
42done
[aeedc72]43service isc-dhcp-server restart
[2e97c42]44# Set language.
[84b21fce]45export LANG="#{LANGUAGE}.UTF-8"
46echo "LANG=\"$LANG\"" > /etc/default/locale
[ebe5709]47echo "LANG=\"$LANG\"" >> /etc/environment
[84b21fce]48locale-gen --lang #{LANGUAGE}
[8883aa5]49sed -i "s/XKBLAYOUT=.*/XKBLAYOUT=\"${LANG%_*}\"/" /etc/default/keyboard
[ebe5709]50dpkg-reconfigure -fnoninteractive console-setup
[b32e00f]51# Comment out next lines for automatic data insertion.
[4f19d25]52#SQL="INSERT INTO aulas (nombreaula, idcentro, urlfoto, grupoid, ubicacion, puestos, modomul, ipmul, pormul, velmul, router, netmask, ntp, dns, proxy, modp2p, timep2p) VALUES  ('Aula virtual', 1, 'aula.jpg', 0, 'Despliegue virtual con Vagrant.', 5, 2, '239.194.2.11', 9000, 70, '#{NETPREFIX}1', '255.255.255.0', '', '', '', 'peer', 30); INSERT INTO ordenadores (nombreordenador, ip, mac, idaula, idrepositorio, idperfilhard, idmenu, idproautoexec, grupoid, router, mascara, arranque, netiface, netdriver, fotoord) VALUES"
53#for ((i=1; i<=#{NCLIENTS}; i++)); do
54#    SQL="$SQL ('ogClient0$i', '#{NETPREFIX}1$i', REPLACE('#{MACPREFIX}0$i',':',''), 1, 1, 0, 0, 0, 0, '#{NETPREFIX}1', '255.255.255.0', '00unknown', 'eth0', 'generic', 'fotoordenador.gif'),"
55#done
56#mysql -u usuog -ppassusuog -D ogAdmBD -e "${SQL%,}"
[dced872]57#/opt/opengnsys/bin/setclientmode ogLiveAdmin ogClient01 PERM
[4f19d25]58#for ((i=2; i<=#{NCLIENTS}; i++)); do
[dced872]59#    /opt/opengnsys/bin/setclientmode ogLive ogClient0$i PERM
[4f19d25]60#done
[4707481]61# Comment out next lines to install new Angular-based web application (on early development).
62#apt-get install -y git nodejs npm
63#ln -fs nodejs /usr/bin/node
64#npm install bower -g
65#svn export http://opengnsys.es/svn/branches/version1.1-tickets/ogWebAdmin-ticket761/admin/WebConsole/angular /opt/opengnsys/www/angular
66#cd /opt/opengnsys/www/angular
67#chown -R vagrant.vagrant .
68#su vagrant -c "bower install -F"
69#sed -i 's!BASE_URL = .*$!BASE_URL = "https://localhost:#{LOCALWEBPORT}/opengnsys";!' ogWebAdmin/assets/js/config.constants.js
70#### TEMPORAL PATCHES
71#su vagrant -c "bower install angular-sanitize -F"
72#su vagrant -c "bower install angular-translate-loader-static-files -F"
73#su vagrant -c "bower install angular-ui-select -F"
74#su vagrant -c "bower install bootstrap -F"
75#su vagrant -c "bower install isteven-angular-multiselect -F"
76#ln -s globunet-util.min.css ogWebAdmin/lib/globunet/dist/css/globunet-util.css
77#cp -a ogWebAdmin/assets/i18n/es.json ogWebAdmin/assets/i18n/en.json
78#sed -i 's/jm.bardallo/usuog/' ogWebAdmin/assets/js/controllers/login.controller.js
79#sed -i "s/DirectoryIndex index.php/DirectoryIndex index.php index.html/" /etc/apache2/sites-enabled/opengnsys.conf
80#service apache2 reload
81echo "Notes:"
82echo "- OpenGnsys Server URL: https://localhost:#{LOCALWEBPORT}/opengnsys/"
83[ -d /opt/opengnsys/www/angular ] && echo "- Angular-based web URL: https://localhost:#{LOCALWEBPORT}/opengnsys/angular/ogWebAdmin/"
[ccec614]84exit 0
[2e97c42]85EOT
86
87# Client 1 OS provisioning script.
88MODELSCRIPT = <<EOT
[b32e00f]89# Comment out next lines to install and configure OGAgent for Ubuntu.
[4707481]90#apt-get update -y
[2e97c42]91#apt-get install -y libxss1 policykit-1 python python-requests python-qt4 python-six python-prctl
[4707481]92#wget -q --no-check-certificate https://#{NETPREFIX}10/opengnsys/descargas/ogagent_1.1.0_all.deb
[b6fd406]93#dpkg -i ogagent_1.1.0_all.deb
[4f19d25]94#sed -i "0,/remote=/ s,remote=.*,remote=https://#{NETPREFIX}10/opengnsys/rest/," /usr/share/OGAgent/cfg/ogagent.cfg
95# Remove network configuration added by Vagrant.
96sed -i "/VAGRANT/,$ d" /etc/network/interfaces
[4707481]97echo "Notes:"
98echo "- After now, use VirtualBox GUI to disable network interface 1 and restart this VM."
[4f19d25]99# Leave VM halted.
[2e97c42]100sleep 2
101poweroff &
[aeedc72]102EOT
103
104Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
105
106  # OpenGnsys Server VM definition.
[4f19d25]107  config.vm.define "ogAdministrator", primary: true do |og|
[aeedc72]108    # Specific VirtualBox configuration.
109    og.vm.provider "virtualbox" do |vb|
110      # VM name, memory and CPUs.
[4f19d25]111      vb.name = "ogAdministrator"
[aeedc72]112      vb.memory = SERVERMEM
113      vb.cpus = 1
[1a2fa9ee]114      # 2nd virtual disk path (current dir on Windows, VM dir on other OSes)
115      if Vagrant::Util::Platform.windows? then
116        second_disk = File.join(".", REPODISK)
117      else
118        line = `VBoxManage list systemproperties`.match("Default machine folder.*")[0]
119        vb_machine_folder = line.split(':')[1].strip()
120        second_disk = File.join(vb_machine_folder, vb.name, REPODISK)
121      end
[aeedc72]122      # Create repo virtual disk, if needed.
123      unless File.exist?(second_disk)
124        vb.customize ['createhd', '--filename', second_disk, '--size', REPOSIZE * 1024]
125      end
126      # Attach repo virtual disk.
[b6fd406]127      vb.customize ['storageattach', :id, '--storagectl', 'SATA Controller', '--port', 1, '--device', 0, '--type', 'hdd', '--medium', second_disk]
[aeedc72]128    end
129    # VM base and host name.
[b6fd406]130    og.vm.box = "bento/ubuntu-16.04"
[4f19d25]131    og.vm.hostname = "ogAdministrator"
[aeedc72]132    # Network configuration: forward web port and attach new interface to VMs private network.
[1a2fa9ee]133    og.vm.network "forwarded_port", guest: 443, host: LOCALWEBPORT, host_ip: "127.0.0.1"
[aeedc72]134    og.vm.network "private_network", ip: "#{NETPREFIX}10", virtualbox__intnet: true
[b32e00f]135    # Comment out to disable synced folder.
136    #og.vm.synced_folder ".", "/vagrant", disabled: true
[aeedc72]137    # Launch provisioning script.
138    og.vm.provision "shell", inline: OGSERVERSCRIPT
139  end
140
141  # Client 1 VM definition.
[4f19d25]142  config.vm.define "ogClient01", autostart: false do |v1|
[b6fd406]143    v1.vm.box = "bento/ubuntu-16.04"
[4f19d25]144    v1.vm.hostname = "ogClient01"
[aeedc72]145    v1.vm.network "private_network", mac: "#{MACPREFIX}01".tr(":",""), type: "dhcp", virtualbox__intnet: true
146    v1.vm.provider "virtualbox" do |vb|
[4f19d25]147      vb.name = "ogClient01"
[aeedc72]148      vb.memory = CLIENTMEM
149      vb.cpus = 1
150      vb.customize ['modifyvm', :id, '--boot1', 'net', '--boot2', 'disk']
151    end
[84b21fce]152    v1.vm.synced_folder ".", "/vagrant", disabled: true
[2e97c42]153    v1.vm.provision "shell", inline: MODELSCRIPT
[aeedc72]154  end
155
[4f19d25]156  # Clonable clients definition.
157  (2..NCLIENTS).each do |i|
158    config.vm.define "ogClient0#{i}", autostart: false do |cl|
159      cl.vm.box = "clink15/pxe"
160      cl.ssh.insert_key = false
161      cl.vm.boot_timeout = 5
162      cl.vm.network "private_network", mac: "#{MACPREFIX}".tr(":","") + "%02d" % "#{i}", type: "dhcp", virtualbox__intnet: true
163      cl.vm.provider "virtualbox" do |vb|
164        vb.name = "ogClient0#{i}"
165        vb.memory = CLIENTMEM
166        vb.cpus = 1
167        vb.customize ['modifyvm', :id, '--boot1', 'net', '--boot2', 'disk']
168        vb.customize ["modifyvm", :id, "--nic1", "none"]
169      end
[aeedc72]170    end
171  end
172
173end
174
Note: See TracBrowser for help on using the repository browser.