Compare commits
14 Commits
main
...
malaga-aut
Author | SHA1 | Date |
---|---|---|
|
43a2425f58 | |
|
aa2cbc5998 | |
|
aa98f82e7c | |
|
11658fe1f1 | |
|
daf281c9cf | |
|
1bf5dc31b1 | |
|
f3b167f11d | |
|
cc65ca98b6 | |
|
90e419fa4c | |
|
fe84920048 | |
|
6bf86e5aba | |
|
a7757e00aa | |
|
bd4791dea9 | |
|
41add758aa |
|
@ -2,17 +2,59 @@ pipeline {
|
|||
agent {
|
||||
label 'ogAdministrator'
|
||||
}
|
||||
parameters {
|
||||
string(name: 'BRANCH', defaultValue: 'main', description: 'Deployment environment')
|
||||
string(name: 'EXTRA_NAME', description: 'Some additional text to better identify the VMs within ESXi')
|
||||
string(name: 'NUMBER_OF_CLIENTS', defaultValue: '1', description: 'Number of clients to deploy')
|
||||
string(name: 'DEFAULT_UDS_REST_URL', defaultValue: 'https://uds-broker.evlt.uma.es/uds/rest/', description: 'UDS REST URL')
|
||||
string(name: 'DEFAULT_UDS_AUTHENTICATOR' , defaultValue: 'Usuarios locales', description: 'UDS REST authenticator')
|
||||
string(name: 'DEFAULT_OGLIVE' , defaultValue: 'ogLive-noble-6.8.0-31-generic-amd64-r20240716_20241014.iso', description: 'oGLive ISO image')
|
||||
}
|
||||
environment {
|
||||
UDS_CREDENTIALS = credentials('UDS_CREDENTIALS')
|
||||
BRANCH = "${params.BRANCH}"
|
||||
VI_USERNAME = 'root'
|
||||
VI_PASSWORD = credentials('VI_PASSWORD')
|
||||
GITEA_USER = "unizar"
|
||||
GITEA_TOKEN = credentials('GITEA_TOKEN')
|
||||
VAGRANT_FILE = "Vagrantfile-esxi"
|
||||
ESXI_PASSWORD = credentials('VI_PASSWORD')
|
||||
USER_SSK_PRIVATE_KEY = credentials('ognproject-ssh-private-key')
|
||||
|
||||
|
||||
}
|
||||
|
||||
stages {
|
||||
stage('Build') {
|
||||
stage ('Create environment') {
|
||||
steps {
|
||||
sh "echo root > root_passwd"
|
||||
sh 'docker run --privileged -v /dev:/dev -v /run:/run -v $(pwd):/installer -w /installer --rm opengnsys/oginstallerbuilder ./builder.sh'
|
||||
}
|
||||
}
|
||||
stage ('Upload Image to NFS')
|
||||
{
|
||||
steps {
|
||||
sh "cp ubuntu-from-scratch.iso /mnt/srv/artefactos/oginstaller/oginstaller-${BRANCH_NAME}_${BUILD_NUMBER}.iso"
|
||||
script {
|
||||
sh """
|
||||
echo "BRANCH: ${BRANCH}"
|
||||
echo "EXTRA_NAME: ${EXTRA_NAME}"
|
||||
echo "NUMBER_OF_CLIENTS: ${NUMBER_OF_CLIENTS}"
|
||||
echo "DEFAULT_UDS_REST_URL: ${DEFAULT_UDS_REST_URL}"
|
||||
echo "DEFAULT_UDS_AUTHENTICATOR: ${DEFAULT_UDS_AUTHENTICATOR}"
|
||||
echo "DEFAULT_OGLIVE: ${DEFAULT_OGLIVE}"
|
||||
echo "UDS_CREDENTIALS: ${UDS_CREDENTIALS}"
|
||||
echo "VI_USERNAME: ${VI_USERNAME}"
|
||||
echo "VI_PASSWORD: ${VI_PASSWORD}"
|
||||
echo "GITEA_USER: ${GITEA_USER}"
|
||||
echo "GITEA_TOKEN: ${GITEA_TOKEN}"
|
||||
echo "VAGRANT_FILE: ${VAGRANT_FILE}"
|
||||
echo "ESXI_PASSWORD: ${ESXI_PASSWORD}"
|
||||
chmod 755 vagrant/provision_esxi_net.sh
|
||||
cat vagrant/provision_esxi_net.sh
|
||||
echo "vagrant/provision_esxi_net.sh executed"
|
||||
cp $USER_SSK_PRIVATE_KEY installer/vagrant/config/id_rsa
|
||||
BRANCH_EXTRA=$BRANCH
|
||||
EXTRA_NAME=${EXTRA_NAME// /}
|
||||
[[ -n $EXTRA_NAME ]] && BRANCH_EXTRA=$BRANCH-$EXTRA_NAME
|
||||
export BRANCH_EXTRA
|
||||
echo ========================= Setting up an ESXi network
|
||||
installer/vagrant/provision_esxi_net.sh $BRANCH_EXTRA
|
||||
|
||||
"""
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,73 @@
|
|||
VAGRANTFILE_API_VERSION = "2"
|
||||
ENV['VAGRANT_DEFAULT_PROVIDER'] = "vmware_esxi"
|
||||
|
||||
BRANCH=ENV['BRANCH'] || "main"
|
||||
BRANCH_EXTRA=ENV['BRANCH_EXTRA'] || BRANCH
|
||||
|
||||
#OGAGENTVERSION="1.4.2"
|
||||
|
||||
LANGUAGE = "es_ES"
|
||||
ENV['LC_ALL'] = LANGUAGE + ".UTF-8"
|
||||
|
||||
# NCLIENTS = ENV['NUMBER_OF_CLIENTS']|| 4
|
||||
# NCLIENTS = NCLIENTS.to_i
|
||||
|
||||
SERVERMEM = 2048 # Minimum: 512
|
||||
CLIENTMEM = 512 # Minimum: 256
|
||||
|
||||
MACPREFIX = ENV['OGN_MAC_PREFIX'] || '00:50:56:aa:aa'
|
||||
NETPREFIX = ENV['OGN_NET_PREFIX'] || "192.168.2"
|
||||
DHCPNET = ENV['DHCPNET'] || "192.168.2.0"
|
||||
|
||||
SERVERIP = "#{NETPREFIX}.10"
|
||||
|
||||
LOCALWEBPORT = 8443
|
||||
|
||||
ESXIPASSWORD = ENV['ESXI_PASSWORD'] || 'prompt:'
|
||||
|
||||
GITEA_TOKEN = ENV['GITEA_TOKEN']
|
||||
GITEA_USER = ENV['GITEA_USER'] || 'unizar'
|
||||
SSH_GIT_KEY_PASS = ENV['SSH_GIT_KEY_PASS'] || ''
|
||||
|
||||
OGSERVERSCRIPT = <<OEOL
|
||||
sed -i 's/APT::Periodic::Update-Package-Lists "1";/APT::Periodic::Update-Package-Lists "0";/g' /etc/apt/apt.conf.d/20auto-upgrades
|
||||
sed -i 's/APT::Periodic::Unattended-Upgrade "1";/APT::Periodic::Unattended-Upgrade "0";/g' /etc/apt/apt.conf.d/20auto-upgrades
|
||||
echo "APT::Periodic::Download-Upgradeable-Packages "0";" >> /etc/apt/apt.conf.d/20auto-upgrades
|
||||
echo "APT::Periodic::AutocleanInterval "0"; >> /etc/apt/apt.conf.d/20auto-upgrades
|
||||
export GIT_SSL_NO_VERIFY=1
|
||||
export INTERFACE="eth0"
|
||||
apt -y update
|
||||
apt install -y git curl jq unzip python3 python3-git
|
||||
EXTIP=$(ip -o -4 addr show "$INTERFACE" | awk '{print $4}' | cut -d'/' -f1)
|
||||
echo "La dirección IP de la interfaz $INTERFACE es: $EXTIP"
|
||||
git clone https://ognproject.evlt.uma.es/gitea/opengnsys/oginstaller.git /tmp/repo
|
||||
cd /tmp/repo
|
||||
mkdir /tmp/oginstall
|
||||
git checkout #{BRANCH}
|
||||
cp -r python-installer/* /tmp/oginstall
|
||||
cp -r component-installer/* /tmp/oginstall
|
||||
chmod 755 /tmp/oginstall/*.sh
|
||||
chmod 755 /tmp/oginstall/*.py
|
||||
cp /vagrant/config/config_* /tmp/oginstall/
|
||||
OEOL
|
||||
|
||||
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
|
||||
config.vm.provider :vmware_esxi do |esxi|
|
||||
esxi.esxi_hostname = 'esxi-jenkins.evlt.uma.es'
|
||||
esxi.esxi_username = 'root'
|
||||
esxi.esxi_password = ESXIPASSWORD
|
||||
esxi.esxi_virtual_network = ['vLan_742' , BRANCH_EXTRA ]
|
||||
esxi.guest_mac_address = [ "#{MACPREFIX}:01", "#{MACPREFIX}:02" ]
|
||||
esxi.clone_from_vm = 'template-ubuntu24'
|
||||
esxi.esxi_resource_pool = "/"
|
||||
esxi.local_allow_overwrite = 'True'
|
||||
esxi.guest_nic_type = 'e1000'
|
||||
esxi.guest_custom_vmx_settings = [['monitor.allowLegacyCPU', 'TRUE']]
|
||||
esxi.guest_storage = [ 10 ]
|
||||
end
|
||||
config.vm.box = "esxi_clone/dummy"
|
||||
config.vm.hostname = "og-#{BRANCH_EXTRA}"
|
||||
config.vm.provision "shell", inline: OGSERVERSCRIPT
|
||||
config.vm.provision "shell", inline: "sudo /tmp/oginstall/component-installer.sh"
|
||||
end
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
network:
|
||||
ethernets:
|
||||
eth1:
|
||||
dhcp4: false
|
||||
addresses: [##ADDRESS##/24]
|
||||
version: 2
|
||||
renderer: networkd
|
|
@ -0,0 +1 @@
|
|||
{"release": "opengnsys_devel-0.0.21", "ogCore_ServerIP": "192.168.2.1", "ogBoot_ServerIP": "192.168.2.1", "ogBoot_Dir": "/opt/opengnsys/ogboot", "ogLive_Default": "https://ognproject.evlt.uma.es/oglive/ogLive-noble-6.8.0-31-generic-amd64-r20241128.62778c9_20241129.iso", "ogBootSambaUser": "opengnsys", "ogBootSambaPass": "og", "confirm_ogBootSambaPass": "og"}
|
|
@ -0,0 +1 @@
|
|||
{"release": "opengnsys_devel-0.0.21", "username": "ogadmin", "password": "12345678", "confirm_password": "12345678"}
|
|
@ -0,0 +1 @@
|
|||
{"release": "opengnsys_devel-0.0.21", "ogbootIP": "192.168.2.1", "ogDhcpIP": "192.168.2.1", "ogDhcp_Dir": "/opt/opengnsys/ogdhcp", "interfaces": ["eth1"]}
|
|
@ -0,0 +1 @@
|
|||
{"release": "opengnsys_devel-0.0.21", "ogcore_ip": "https://127.0.0.1:8443"}
|
|
@ -0,0 +1 @@
|
|||
{"release": "opengnsys_devel-0.0.21", "ogrepository_ip": "192.168.2.1", "ogcore_server_ip": "192.168.2.1", "ogrepository_samba_user": "opengnsys", "ogrepository_samba_pass": "og", "confirm_repository_password": "og"}
|
|
@ -0,0 +1,47 @@
|
|||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
|
||||
BRANCH=$1
|
||||
BRANCH=${BRANCH:-"main"}
|
||||
ESXCLI=/usr/bin/esxcli
|
||||
VSWITCH="vSwitch2"
|
||||
source ~/.pass
|
||||
|
||||
|
||||
# Check if portgroup exists
|
||||
function checkIfPortgroupExists () {
|
||||
local i=0
|
||||
PORTGROUPS=( $($ESXCLI network vswitch standard portgroup list | grep $BRANCH | awk ' { print $1 }') )
|
||||
for portgroup in "${PORTGROUPS[@]}"; do
|
||||
if [ $portgroup == $BRANCH ] ; then
|
||||
echo "Portgroup $BRANCH is not going to be created, already exists"
|
||||
echo "Please Check ESXI configuration"
|
||||
exit 0
|
||||
fi
|
||||
done
|
||||
}
|
||||
function createPortGroup() {
|
||||
echo Adding portgroup $BRANCH to $VSWITCH
|
||||
$ESXCLI network vswitch standard portgroup add --portgroup-name=$BRANCH --vswitch-name=$VSWITCH
|
||||
}
|
||||
|
||||
function getMaxVlan(){
|
||||
PORTGROUPS=( $($ESXCLI --formatter=csv network vswitch standard portgroup list | grep $VSWITCH | cut -d "," -f3 ) )
|
||||
IFS=$'\n'
|
||||
MAX_VLAN=$(echo "${PORTGROUPS[*]}" | sort -nr | head -n1)
|
||||
NEXT_VLAN=$(( MAX_VLAN + 1 ))
|
||||
[[ $NEXT_VLAN -lt 3000 ]] && NEXT_VLAN=3000
|
||||
echo VLAN assigned is $NEXT_VLAN
|
||||
}
|
||||
|
||||
function setVlan(){
|
||||
$ESXCLI network vswitch standard portgroup set -p $BRANCH --vlan-id $1
|
||||
}
|
||||
|
||||
#### SCRIPT
|
||||
checkIfPortgroupExists
|
||||
createPortGroup
|
||||
getMaxVlan
|
||||
setVlan $NEXT_VLAN
|
||||
echo portgroup $BRANCH created with vlan_id $NEXT_VLAN
|
Loading…
Reference in New Issue