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

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 c680f93 was ebe5709, checked in by ramon <ramongomez@…>, 9 years ago

#739: Cambios en entornos Vagrant: incluir teclado adecuado y solucionar algunas dependencias en el entorno para OGAgent.

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

  • Property mode set to 100644
File size: 6.1 KB
Line 
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"
6# Language (accepted values: es_ES, ca_ES, en_GB).
7LANGUAGE = "es_ES"
8ENV['LC_ALL'] = LANGUAGE + ".UTF-8"
9# Number of OpenGnsys clients (accepted values: from 2 to 9).
10NCLIENTS = 4
11# Repository virtual disk: file and size (GB).
12REPODISK = "ogRepo.vdi"
13REPOSIZE = 50
14# Amount of memory for server and clients (MB)
15SERVERMEM = 1024
16CLIENTMEM = 512
17# Clients MAC address prefix.
18MACPREFIX = "08:00:27:0E:65:"
19NETPREFIX = "192.168.2."
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
25# Mount repository disk.
26test -n "$(blkid /dev/sdb1 | grep ext4)" && exit
27echo -e "o\nn\np\n\n\n\nw" | fdisk /dev/sdb
28mkfs -t ext4 /dev/sdb1
29mkdir -p /opt/opengnsys/images
30echo "/dev/sdb1  /opt/opengnsys/images  ext4  defaults  0  0" >> /etc/fstab
31mount -a
32# Install OpenGnsys and change server address.
33wget -q http://opengnsys.es/svn/branches/version1.1/installer/opengnsys_installer.sh -O - | bash
34echo y | sudo /opt/opengnsys/bin/setserveraddr eth1
35# Insert DHCP data.
36for ((i=#{NCLIENTS}; i>0; i--)); do
37    sed -i "/^}$/ i host ogClient0${i} { hardware ethernet #{MACPREFIX}0${i}; fixed-address #{NETPREFIX}1${i}; }" /etc/dhcp/dhcpd.conf
38done
39service isc-dhcp-server restart
40# Set language.
41export LANG="#{LANGUAGE}.UTF-8"
42echo "LANG=\"$LANG\"" > /etc/default/locale
43echo "LANG=\"$LANG\"" >> /etc/environment
44locale-gen --lang #{LANGUAGE}
45dpkg-reconfigure -fnoninteractive console-setup
46# Unmcomment next lines for automatic data insertion.
47#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"
48#for ((i=1; i<=#{NCLIENTS}; i++)); do
49#    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'),"
50#done
51#mysql -u usuog -ppassusuog -D ogAdmBD -e "${SQL%,}"
52#/opt/opengnsys/bin/setclientmode ogAdmin ogClient01 1
53#for ((i=2; i<=#{NCLIENTS}; i++)); do
54#    /opt/opengnsys/bin/setclientmode ogClient ogClient0$i 1
55#done
56echo "New OpenGnsys local URL: https://localhost:#{LOCALWEBPORT}/opengnsys/"
57EOT
58
59# Client 1 OS provisioning script.
60MODELSCRIPT = <<EOT
61# Uncomment next lines to install and configure OGAgent for Ubuntu.
62#apt-get install -y libxss1 policykit-1 python python-requests python-qt4 python-six python-prctl
63#wget -q http://opengnsys.es/svn/branches/version1.1-tickets/OGAgent-ticket718/client/shared/lib/ogagent/ogagent_1.0.0_all.deb  # temporal
64#dpkg -i ogagent_1.0.0_all.deb
65#sed -i "0,/remote=/ s,remote=.*,remote=https://#{NETPREFIX}10/opengnsys/rest/," /usr/share/OGAgent/cfg/ogagent.cfg
66# Remove network configuration added by Vagrant.
67sed -i "/VAGRANT/,$ d" /etc/network/interfaces
68echo "After now, use VirtualBox GUI to disable network interface 1 and work with this VM."
69# Leave VM halted.
70sleep 2
71poweroff &
72EOT
73
74Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
75
76  # OpenGnsys Server VM definition.
77  config.vm.define "ogAdministrator", primary: true do |og|
78    # Specific VirtualBox configuration.
79    og.vm.provider "virtualbox" do |vb|
80      # VM name, memory and CPUs.
81      vb.name = "ogAdministrator"
82      vb.memory = SERVERMEM
83      vb.cpus = 1
84      # Get VM disk path
85      line = `VBoxManage list systemproperties | grep "Default machine folder"`
86      vb_machine_folder = line.split(':')[1].strip()
87      second_disk = File.join(vb_machine_folder, vb.name, REPODISK)
88      # Create repo virtual disk, if needed.
89      unless File.exist?(second_disk)
90        vb.customize ['createhd', '--filename', second_disk, '--size', REPOSIZE * 1024]
91      end
92      # Attach repo virtual disk.
93      vb.customize ['storageattach', :id, '--storagectl', 'SATAController', '--port', 1, '--device', 0, '--type', 'hdd', '--medium', second_disk]
94    end
95    # VM base and host name.
96    og.vm.box = "ubuntu/trusty64"
97    og.vm.hostname = "ogAdministrator"
98    # Network configuration: forward web port and attach new interface to VMs private network.
99    og.vm.network "forwarded_port", guest: 443, host: 8443
100    og.vm.network "private_network", ip: "#{NETPREFIX}10", virtualbox__intnet: true
101    # Disable synced folder.
102    og.vm.synced_folder ".", "/vagrant", disabled: true
103    # Launch provisioning script.
104    og.vm.provision "shell", inline: OGSERVERSCRIPT
105  end
106
107  # Client 1 VM definition.
108  config.vm.define "ogClient01", autostart: false do |v1|
109    v1.vm.box = "ubuntu/trusty64"
110    v1.vm.hostname = "ogClient01"
111    v1.vm.network "private_network", mac: "#{MACPREFIX}01".tr(":",""), type: "dhcp", virtualbox__intnet: true
112    v1.vm.provider "virtualbox" do |vb|
113      vb.name = "ogClient01"
114      vb.memory = CLIENTMEM
115      vb.cpus = 1
116      vb.customize ['modifyvm', :id, '--boot1', 'net', '--boot2', 'disk']
117    end
118    v1.vm.synced_folder ".", "/vagrant", disabled: true
119    v1.vm.provision "shell", inline: MODELSCRIPT
120  end
121
122  # Clonable clients definition.
123  (2..NCLIENTS).each do |i|
124    config.vm.define "ogClient0#{i}", autostart: false do |cl|
125      cl.vm.box = "clink15/pxe"
126      cl.ssh.insert_key = false
127      cl.vm.boot_timeout = 5
128      cl.vm.network "private_network", mac: "#{MACPREFIX}".tr(":","") + "%02d" % "#{i}", type: "dhcp", virtualbox__intnet: true
129      cl.vm.provider "virtualbox" do |vb|
130        vb.name = "ogClient0#{i}"
131        vb.memory = CLIENTMEM
132        vb.cpus = 1
133        vb.customize ['modifyvm', :id, '--boot1', 'net', '--boot2', 'disk']
134        vb.customize ["modifyvm", :id, "--nic1", "none"]
135      end
136    end
137  end
138
139end
140
Note: See TracBrowser for help on using the repository browser.