source: installer/vagrant/Vagrantfile-esxi @ f7313c5

configure-oglivelgromero-new-oglivemainmaint-cronmount-efivarfsmultivmmultivm-ogboot-installerogClonningEngineogboot-installer-jenkinsoglive-ipv6test-python-scriptsticket-301ticket-50ticket-50-oldticket-577ticket-585ticket-611ticket-612ticket-693ticket-700ubu24tplunification2use-local-agent-oglivevarios-instalacion
Last change on this file since f7313c5 was f7313c5, checked in by Nicolas Arenas <nicolas.arenas@…>, 20 months ago

Debug ogAdminisrator for Jenkins

  • Property mode set to 100644
File size: 6.8 KB
Line 
1# Vagrantfile to install OpenGnsys virtual environment (production version) using VirtualBox provider.
2
3VAGRANTFILE_API_VERSION = "2"
4# VM provider: Oracle VM VirtualBox.
5ENV['VAGRANT_DEFAULT_PROVIDER'] = "vmware_esxi"
6# OpenGnsys version and OGAgent version.
7OGVERSION=ENV['OGVERSION'] || "test"
8# OGAgent version.
9OGAGENTVERSION="1.1.2"
10# Language (accepted values: es_ES, ca_ES, en_GB).
11LANGUAGE = "es_ES"
12ENV['LC_ALL'] = LANGUAGE + ".UTF-8"
13# Number of OpenGnsys clients (accepted values: from 2 to 9).
14NCLIENTS = 4
15# Repository virtual disk: file and size (GB).
16REPODISK = "ogRepo.vdi"
17REPOSIZE = 50
18# Amount of memory for server and clients (MB)
19SERVERMEM = 2048        # Minimum: 512
20CLIENTMEM = 512         # Minimum: 256
21# Prefixes for MAC and IP addresses.
22MACPREFIX = ENV['OGN_MAC_PREFIX'] || '00:50:56:aa:aa'
23NETPREFIX = ENV['OGN_NET_PREFIX'] || "192.168.2"
24DHCPNET   = ENV['DHCPNET'] || "192.168.2.0"
25# OpenGnsys Server IP address.
26SERVERIP = "#{NETPREFIX}.10"
27# Local port to access OpenGnsys Server.
28LOCALWEBPORT = 8443
29# ESXI Password
30ESXIPASSWORD = ENV['ESXI_PASSWORD'] || 'prompt:'
31
32#Gitea credentials
33GITEA_TOKEN = ENV['GITEA_TOKEN']
34GITEA_USER = ENV['GITEA_USER'] || 'unizar'
35
36# OpenGnsys Server provisioning script: prepare repo disk, install OpenGnsys, change default interface, configure DHCP server.
37OGSERVERSCRIPT = <<EOT
38
39# Fix problem with gitea host
40
41echo "150.214.58.246 ognproject.evlt.uma.es" >> /etc/hosts
42
43# Fix ssh
44mkdir -p /root/.ssh/
45cp /vagrant/config/id_rsa /root/.ssh/id_rsa
46chown root:root /root/.ssh/id_rsa
47chmod 0400 /root/.ssh/id_rsa
48cp /vagrant/config/ssh_config /root/.ssh/config
49chown root:root /root/.ssh/config
50chmod 0400 /root/.ssh/config
51
52# Set language
53export LANG="#{LANGUAGE}.UTF-8"
54echo "LANG=\\\"$LANG\\\"" > /etc/default/locale
55echo "LANG=\\\"$LANG\\\"" >> /etc/environment
56locale-gen --lang #{LANGUAGE}
57sed -i "s/XKBLAYOUT=.*/XKBLAYOUT=\\\"${LANG%_*}\\\"/" /etc/default/keyboard
58dpkg-reconfigure -fnoninteractive console-setup
59
60# Exit if OpenGnsys is installed.
61[ -f /opt/opengnsys/doc/VERSION.json ] && echo "Cannot provision, OpenGnsys is already installed." && exit 1
62
63# Create repo disk
64if [ -z "$(blkid /dev/mapper/og-images | grep ext4)" ]; then
65    pvcreate /dev/sdb
66    vgcreate og /dev/sdb
67    vgchange -ay
68    lvcreate -ay -n images -l 100%VG og
69    mkfs -t ext4 /dev/mapper/og-images
70    mkdir -p /opt/opengnsys/images
71    echo "/dev/mapper/og-images  /opt/opengnsys/images  ext4  defaults  0  0" >> /etc/fstab
72    mount -a
73fi
74
75# Configure eth1 iface
76if [ -f /etc/netplan/01-eth1.yaml ]; then
77    echo "Network configured Skipping"
78else
79    echo "Configuring Network"
80    sed -i "s/##ADDRESS##/${NETPREFIX}.1/g" /tmp/01-eth1.yaml
81    mv /tmp/01-eth1.yaml /etc/netplan
82    chown root:root /etc/netplan/01-eth1.yaml
83    netplan apply
84    sleep 1
85fi
86
87
88# Download installer
89BRANCH="$OGVERSION"
90
91curl --show-error --fail -k -L -o opengnsys_installer_devel_esxi.sh https://$GITEA_USER:$GITEA_TOKEN@ognproject.evlt.uma.es/gitea/unizar/opengnsys/raw/branch/${BRANCH}/installer/opengnsys_installer_devel_esxi.sh
92chmod 755 opengnsys_installer_devel_esxi.sh && ./opengnsys_installer_devel_esxi.sh $BRANCH
93mv /opt/opengnsys/log/bash.log /opt/opengnsys/log/opengnsys_installer.log
94
95
96echo y | /opt/opengnsys/bin/setserveraddr $(ip -o link show | tail -1 | cut -d: -f2)
97
98# Insert DHCP data.
99for ((i=#{NCLIENTS+10}; i>10; i--)); do
100    sed -i "/^}$/ i host pc${i} { hardware ethernet #{MACPREFIX}:${i}; fixed-address #{NETPREFIX}.${i}; }" /etc/dhcp/dhcpd.conf
101done
102service isc-dhcp-server start
103
104# Comment out next lines for automatic data insertion.
105SQL="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"
106for ((i=11; i<=#{NCLIENTS+10}; i++)); do
107    SQL="$SQL ('pc$i', '#{NETPREFIX}.$i', REPLACE('#{MACPREFIX}$i',':',''), 1, 1, 0, 0, 0, 0, '#{NETPREFIX}.1', '255.255.255.0', '00unknown', 'eth0', 'generic', 'fotoordenador.gif'),"
108done
109mysql -u usuog -ppassusuog -D ogAdmBD -e "${SQL%,}"
110/opt/opengnsys/bin/setclientmode ogLiveAdmin pc11 PERM
111for ((i=12; i<=#{NCLIENTS+10}; i++)); do
112    /opt/opengnsys/bin/setclientmode ogLive pc$i PERM
113done
114echo "Notes:"
115echo "- OpenGnsys Server URL: https://localhost:${LOCALWEBPORT}/opengnsys/"
116exit 0
117EOT
118
119
120Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
121  # OpenGnsys Server VM definition.
122  config.vm.define "ogAdministrator-#{OGVERSION}", primary: true do |og|
123    # Specific VirtualBox configuration.
124    og.vm.provider :vmware_esxi do |esxi|
125      # VM name, memory and CPUs.
126      esxi.guest_name = "ogAdministrator-#{OGVERSION}"
127      esxi.guest_memsize = SERVERMEM
128      esxi.esxi_username = 'root'
129      esxi.esxi_password = ESXIPASSWORD
130      esxi.esxi_hostname = 'esxi-jenkins.evlt.uma.es'
131      esxi.clone_from_vm = 'Ubuntu-18-template-image'
132      esxi.esxi_resource_pool = "/"
133      esxi.local_allow_overwrite = 'True'
134      esxi.guest_custom_vmx_settings = [['monitor.allowLegacyCPU', 'TRUE']]
135      esxi.guest_storage = [ 10 ]
136      esxi.esxi_virtual_network = [ 'vLan_742', OGVERSION  ]
137      esxi.guest_mac_address = [ "#{MACPREFIX}:00", "#{MACPREFIX}:01"]
138    end
139    # VM base and host name.
140    og.vm.box = "esxi_clone/dummy"
141    og.vm.hostname = "ogAdministrator-#{OGVERSION}"
142    # Launch provisioning script.
143    og.vm.provision "file", source: "config/01-eth1.yaml" , destination: "/tmp/"
144    og.vm.provision "shell", inline: OGSERVERSCRIPT , env: {"NETPREFIX" => NETPREFIX , "OGVERSION" => OGVERSION , "GITEA_TOKEN" => GITEA_TOKEN , "GITEA_USER" => GITEA_USER , "DHCPNET" => DHCPNET }
145  end
146
147  # config.vm.define "pc11" do |v1|
148  #   # Specific VirtualBox configuration.
149  #   v1.vm.provider :vmware_esxi do |esxi|
150  #     # VM name, memory and CPUs.
151  #     esxi.guest_name = "pc11-#{OGVERSION}"
152  #     esxi.guest_memsize = CLIENTMEM
153  #     esxi.esxi_username = 'root'
154  #     esxi.esxi_password = ESXIPASSWORD
155  #     esxi.esxi_hostname = 'esxi-jenkins.evlt.uma.es'
156  #     esxi.clone_from_vm = 'cli'
157  #     esxi.esxi_resource_pool = "/"
158  #     esxi.local_allow_overwrite = 'True'
159  #     esxi.guest_custom_vmx_settings = [['monitor.allowLegacyCPU', 'TRUE']]
160  #     esxi.guest_storage = [ 10 ]
161  #     esxi.esxi_virtual_network = [ OGVERSION ]
162  #     esxi.guest_mac_address = [ "#{MACPREFIX}:11"]
163  #     esxi.guest_autostart = 'false'
164  #   end
165  #   # VM base and host name.
166  #   v1.vm.box = "esxi_clone/dummy"
167  #   v1.vm.hostname = "pc11-#{OGVERSION}"
168  #   v1.vm.boot_timeout = 10
169  #   v1.ssh.timeout = 5
170  #   v1.ssh.max_tries = 1
171  #   # Launch provisioning script.
172  # end
173end
174
175
176
177
Note: See TracBrowser for help on using the repository browser.