Skip to content

Commit

Permalink
Added WALinuxVersion parameter option
Browse files Browse the repository at this point in the history
  • Loading branch information
Welasco committed Nov 20, 2023
1 parent 7d1320a commit d15fc72
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 21 deletions.
6 changes: 6 additions & 0 deletions bicep/main.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ param ShellScriptName string = 'configureopnsense.sh'
@sys.description('OPN Version')
param OpnVersion string = '23.1'

@sys.description('Azure WALinux agent Version')
param WALinuxVersion string = '2.9.1.1'

@sys.description('Deploy Windows VM Trusted Subnet')
param DeployWindows bool = false

Expand Down Expand Up @@ -390,6 +393,7 @@ module opnSenseSecondary 'modules/VM/opnsense.bicep' = if(scenarioOption == 'Act
ShellScriptObj: {
OpnScriptURI: OpnScriptURI
OpnVersion: OpnVersion
WALinuxVersion: WALinuxVersion
OpnType: 'Secondary'
TrustedSubnetName: '${virtualNetworkName}/${useexistingvirtualNetwork ? existingTrustedSubnetName : trustedSubnetName}'
WindowsSubnetName: DeployWindows ? '${virtualNetworkName}/${useexistingvirtualNetwork ? existingWindowsSubnet : windowsvmsubnetname}' : ''
Expand Down Expand Up @@ -428,6 +432,7 @@ module opnSensePrimary 'modules/VM/opnsense.bicep' = if(scenarioOption == 'Activ
ShellScriptObj: {
OpnScriptURI: OpnScriptURI
OpnVersion: OpnVersion
WALinuxVersion: WALinuxVersion
OpnType: 'Primary'
TrustedSubnetName: '${virtualNetworkName}/${useexistingvirtualNetwork ? existingTrustedSubnetName : trustedSubnetName}'
WindowsSubnetName: DeployWindows ? '${virtualNetworkName}/${useexistingvirtualNetwork ? existingWindowsSubnet : windowsvmsubnetname}' : ''
Expand Down Expand Up @@ -464,6 +469,7 @@ module opnSenseTwoNics 'modules/VM/opnsense.bicep' = if(scenarioOption == 'TwoNi
ShellScriptObj: {
OpnScriptURI: OpnScriptURI
OpnVersion: OpnVersion
WALinuxVersion: WALinuxVersion
OpnType: 'TwoNics'
TrustedSubnetName: '${virtualNetworkName}/${useexistingvirtualNetwork ? existingTrustedSubnetName : trustedSubnetName}'
WindowsSubnetName: DeployWindows ? '${virtualNetworkName}/${useexistingvirtualNetwork ? existingWindowsSubnet : windowsvmsubnetname}' : ''
Expand Down
2 changes: 1 addition & 1 deletion bicep/modules/VM/opnsense.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ resource vmext 'Microsoft.Compute/virtualMachines/extensions@2023-07-01' = {
fileUris: [
'${OPNScriptURI}${ShellScriptName}'
]
commandToExecute: 'sh ${ShellScriptName} ${ShellScriptObj.OpnScriptURI} ${ShellScriptObj.OpnVersion} ${ShellScriptObj.OpnType} ${!empty(ShellScriptObj.TrustedSubnetName) ? trustedSubnet.properties.addressPrefix : ''} ${!empty(ShellScriptObj.WindowsSubnetName) ? windowsvmsubnet.properties.addressPrefix : '1.1.1.1/32'} ${ShellScriptObj.publicIPAddress} ${ShellScriptObj.opnSenseSecondarytrustedNicIP}'
commandToExecute: 'sh ${ShellScriptName} ${ShellScriptObj.OpnScriptURI} ${ShellScriptObj.OpnVersion} ${ShellScriptObj.WALinuxVersion} ${ShellScriptObj.OpnType} ${!empty(ShellScriptObj.TrustedSubnetName) ? trustedSubnet.properties.addressPrefix : ''} ${!empty(ShellScriptObj.WindowsSubnetName) ? windowsvmsubnet.properties.addressPrefix : '1.1.1.1/32'} ${ShellScriptObj.publicIPAddress} ${ShellScriptObj.opnSenseSecondarytrustedNicIP}'
}
}
}
Expand Down
8 changes: 8 additions & 0 deletions bicep/uiFormDefinition.json
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,13 @@
"toolTip": "OPNsense Releases. Latest: 22.7, 23.1 Reference: https://docs.opnsense.org/releases.html",
"defaultValue": "23.1"
},
{
"name": "WALinuxVersion",
"type": "Microsoft.Common.TextBox",
"label": "Azure WALinux agent Version",
"toolTip": "Azure WALinux agent Releases. Only version number, dont add v at the begining. Latest: 2.9.0.4, 2.9.1.1 Reference: https://github.com/Azure/WALinuxAgent/releases",
"defaultValue": "2.9.1.1"
},
{
"name": "DeployWindows",
"type": "Microsoft.Common.CheckBox",
Expand Down Expand Up @@ -375,6 +382,7 @@
"OpnScriptURI": "[steps('VirtualMachineConfig').OpnScriptURI]",
"ShellScriptName": "[steps('VirtualMachineConfig').ShellScriptName]",
"OpnVersion": "[steps('VirtualMachineConfig').OpnVersion]",
"WALinuxVersion": "[steps('VirtualMachineConfig').WALinuxVersion]",
"DeployWindows": "[steps('VirtualMachineConfig').DeployWindows]",
"WinUsername": "[steps('VirtualMachineConfig').WinUsername]",
"WinPassword": "[steps('VirtualMachineConfig').WinPassword]",
Expand Down
41 changes: 21 additions & 20 deletions scripts/configureopnsense.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,39 +3,40 @@
# Script Params
# $1 = OPNScriptURI
# $2 = OpnVersion
# $3 = Primary/Secondary/TwoNics
# $4 = Trusted Nic subnet prefix - used to get the gw
# $5 = Windows-VM-Subnet subnet prefix - used to route/nat allow internet access from Windows Management VM
# $6 = ELB VIP Address
# $7 = Private IP Secondary Server
# $3 = WALinuxVersion
# $4 = Primary/Secondary/TwoNics
# $5 = Trusted Nic subnet prefix - used to get the gw
# $6 = Windows-VM-Subnet subnet prefix - used to route/nat allow internet access from Windows Management VM
# $7 = ELB VIP Address
# $8 = Private IP Secondary Server

# Check if Primary or Secondary Server to setup Firewal Sync
# Note: Firewall Sync should only be setup in the Primary Server
if [ "$3" = "Primary" ]; then
if [ "$4" = "Primary" ]; then
fetch $1config-active-active-primary.xml
fetch $1get_nic_gw.py
gwip=$(python get_nic_gw.py $4)
gwip=$(python get_nic_gw.py $5)
sed -i "" "s/yyy.yyy.yyy.yyy/$gwip/" config-active-active-primary.xml
sed -i "" "s_zzz.zzz.zzz.zzz_$5_" config-active-active-primary.xml
sed -i "" "s/www.www.www.www/$6/" config-active-active-primary.xml
sed -i "" "s/xxx.xxx.xxx.xxx/$7/" config-active-active-primary.xml
sed -i "" "s_zzz.zzz.zzz.zzz_$6_" config-active-active-primary.xml
sed -i "" "s/www.www.www.www/$7/" config-active-active-primary.xml
sed -i "" "s/xxx.xxx.xxx.xxx/$8/" config-active-active-primary.xml
sed -i "" "s/<hostname>OPNsense<\/hostname>/<hostname>OPNsense-Primary<\/hostname>/" config-active-active-primary.xml
cp config-active-active-primary.xml /usr/local/etc/config.xml
elif [ "$3" = "Secondary" ]; then
elif [ "$4" = "Secondary" ]; then
fetch $1config-active-active-secondary.xml
fetch $1get_nic_gw.py
gwip=$(python get_nic_gw.py $4)
gwip=$(python get_nic_gw.py $5)
sed -i "" "s/yyy.yyy.yyy.yyy/$gwip/" config-active-active-secondary.xml
sed -i "" "s_zzz.zzz.zzz.zzz_$5_" config-active-active-secondary.xml
sed -i "" "s/www.www.www.www/$6/" config-active-active-secondary.xml
sed -i "" "s_zzz.zzz.zzz.zzz_$6_" config-active-active-secondary.xml
sed -i "" "s/www.www.www.www/$7/" config-active-active-secondary.xml
sed -i "" "s/<hostname>OPNsense<\/hostname>/<hostname>OPNsense-Secondary<\/hostname>/" config-active-active-secondary.xml
cp config-active-active-secondary.xml /usr/local/etc/config.xml
elif [ "$3" = "TwoNics" ]; then
elif [ "$4" = "TwoNics" ]; then
fetch $1config.xml
fetch $1get_nic_gw.py
gwip=$(python get_nic_gw.py $4)
gwip=$(python get_nic_gw.py $5)
sed -i "" "s/yyy.yyy.yyy.yyy/$gwip/" config.xml
sed -i "" "s_zzz.zzz.zzz.zzz_$5_" config.xml
sed -i "" "s_zzz.zzz.zzz.zzz_$6_" config.xml
cp config.xml /usr/local/etc/config.xml
fi

Expand All @@ -61,9 +62,9 @@ sed -i "" "s/reboot/shutdown -r +1/g" opnsense-bootstrap.sh.in
sh ./opnsense-bootstrap.sh.in -y -r "$2"

# Add Azure waagent
fetch https://github.com/Azure/WALinuxAgent/archive/refs/tags/v2.8.0.11.tar.gz
tar -xvzf v2.8.0.11.tar.gz
cd WALinuxAgent-2.8.0.11/
fetch https://github.com/Azure/WALinuxAgent/archive/refs/tags/v$3.tar.gz
tar -xvzf v$3.tar.gz
cd WALinuxAgent-$3/
python3 setup.py install --register-service --lnx-distro=freebsd --force
cd ..

Expand Down

0 comments on commit d15fc72

Please sign in to comment.