Skip to content

Commit ead28b2

Browse files
authored
Merge pull request #6 from dmauser/dmauser-supreme-engine
Modernize templates, fix cloud-init provisioning race, reorganize repo and rewrite docs
2 parents 6a43ef0 + badfe81 commit ead28b2

35 files changed

Lines changed: 1058 additions & 232 deletions

.gitattributes

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Normalize line endings on commit for text files.
2+
* text=auto
3+
4+
# Scripts executed on Linux VMs (via Custom Script Extension / cloud-init) must
5+
# always be checked out with LF endings. CRLF causes the shebang to fail with
6+
# "bad interpreter: No such file or directory".
7+
*.sh text eol=lf
8+
*.azcli text eol=lf
9+
cloud-init.txt text eol=lf
10+
11+
# Windows scripts keep CRLF.
12+
*.ps1 text eol=crlf
13+
14+
# Templates and docs.
15+
*.bicep text eol=lf
16+
*.json text eol=lf
17+
*.md text eol=lf
18+
*.yml text eol=lf
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
name: Validate templates
2+
3+
on:
4+
push:
5+
branches: [master]
6+
paths: ['infra/**', 'scripts/**', '.github/workflows/validate-templates.yml']
7+
pull_request:
8+
paths: ['infra/**', 'scripts/**', '.github/workflows/validate-templates.yml']
9+
workflow_dispatch:
10+
11+
permissions:
12+
contents: read
13+
14+
jobs:
15+
bicep:
16+
name: Build, lint and check ARM output is in sync
17+
runs-on: ubuntu-latest
18+
steps:
19+
- uses: actions/checkout@v4
20+
21+
- name: Install Bicep CLI
22+
run: |
23+
curl -sLo bicep https://github.com/Azure/bicep/releases/latest/download/bicep-linux-x64
24+
chmod +x bicep && sudo mv bicep /usr/local/bin/bicep
25+
bicep --version
26+
27+
- name: Lint Bicep sources
28+
run: |
29+
for src in infra/bicep/*.bicep; do
30+
echo "Linting $src"
31+
bicep lint "$src"
32+
done
33+
34+
# The ARM JSON under infra/arm/ is generated, never hand-edited. Rebuild it
35+
# and fail if the result differs from what is committed.
36+
- name: Rebuild ARM templates and verify they match the committed output
37+
run: |
38+
for src in infra/bicep/*.bicep; do
39+
out="infra/arm/$(basename "${src%.bicep}").json"
40+
bicep build "$src" --outfile "$out"
41+
done
42+
if ! git diff --exit-code -- infra/arm; then
43+
echo "::error::infra/arm/*.json is out of sync with infra/bicep/*.bicep. Run 'az bicep build' and commit the result."
44+
exit 1
45+
fi
46+
47+
shell:
48+
name: Shell script syntax and line endings
49+
runs-on: ubuntu-latest
50+
steps:
51+
- uses: actions/checkout@v4
52+
53+
# CRLF in a script executed by the Custom Script Extension breaks the
54+
# shebang with "bad interpreter: No such file or directory".
55+
- name: Reject CRLF line endings
56+
run: |
57+
if grep -rlU $'\r' scripts/linux labs; then
58+
echo "::error::Files above contain CRLF line endings; they must be LF."
59+
exit 1
60+
fi
61+
62+
- name: Check syntax
63+
run: for f in scripts/linux/*.sh; do bash -n "$f"; done

README.md

Lines changed: 292 additions & 17 deletions
Large diffs are not rendered by default.

WinRouter.json

Lines changed: 0 additions & 177 deletions
This file was deleted.

notes.txt renamed to docs/notes.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@ az vm create \
77
--custom-data cloud-init.txt
88

99

10-
az network public-ip create --name $spoke1name-vm-pip --resource-group $rg --location $vhub1location --allocation-method Dynamic --output none
10+
az network public-ip create --name $spoke1name-vm-pip --resource-group $rg --location $vhub1location --allocation-method Static --sku Standard --output none
1111
az network nic create --resource-group $rg -n $spoke1name-vm-nic --location $vhub1location --subnet vmsubnet --vnet-name $spoke1name-vnet --public-ip-address $spoke1name-vm-pip --output none
1212
az vm create -n $spoke1name-vm -g $rg --image Ubuntu2404 --size Standard_B1s --admin-username $username --admin-password $password --nics $spoke1name-vm-nic --no-wait --location $vhub1location --output none
Lines changed: 12 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
"metadata": {
55
"_generator": {
66
"name": "bicep",
7-
"version": "0.44.1.10279",
8-
"templateHash": "8094453408631886471"
7+
"version": "0.46.1.21595",
8+
"templateHash": "2884941074303245104"
99
}
1010
},
1111
"parameters": {
@@ -78,7 +78,7 @@
7878
},
7979
"scriptUri": {
8080
"type": "string",
81-
"defaultValue": "[uri(deployment().properties.templateLink.uri, 'linuxrouter.sh')]",
81+
"defaultValue": "[uri(deployment().properties.templateLink.uri, '../../scripts/linux/linuxrouter.sh')]",
8282
"metadata": {
8383
"description": "Script that will be executed"
8484
}
@@ -103,12 +103,20 @@
103103
"metadata": {
104104
"description": "Deploy Public IP Address"
105105
}
106+
},
107+
"allowSshFromAddressPrefix": {
108+
"type": "string",
109+
"defaultValue": "",
110+
"metadata": {
111+
"description": "Source address prefix allowed to reach the VM on TCP 22, for example 203.0.113.4/32. Standard SKU public IPs deny inbound traffic by default, so leave this empty only if you do not need SSH from the internet. Use Internet to allow any source (not recommended)."
112+
}
106113
}
107114
},
108115
"variables": {
109116
"extensionName": "CustomScript",
110117
"nicName": "[format('{0}-NIC', parameters('virtualMachineName'))]",
111118
"publicIPAddressName": "[format('{0}-PublicIP', parameters('virtualMachineName'))]",
119+
"sshSecurityRules": "[if(empty(parameters('allowSshFromAddressPrefix')), createArray(), createArray(createObject('name', 'Allow-SSH-Inbound', 'properties', createObject('priority', 200, 'protocol', 'Tcp', 'access', 'Allow', 'direction', 'Inbound', 'sourceAddressPrefix', parameters('allowSshFromAddressPrefix'), 'sourcePortRange', '*', 'destinationAddressPrefix', '*', 'destinationPortRange', '22'))))]",
112120
"osVersionDefinitions": {
113121
"22.04": {
114122
"publisher": "Canonical",
@@ -131,25 +139,7 @@
131139
"name": "default-nsg",
132140
"location": "[parameters('location')]",
133141
"properties": {
134-
"securityRules": [
135-
{
136-
"name": "Allow-Traffic-RFC-1918",
137-
"properties": {
138-
"priority": 300,
139-
"protocol": "*",
140-
"access": "Allow",
141-
"direction": "Inbound",
142-
"sourceAddressPrefixes": [
143-
"10.0.0.0/8",
144-
"172.16.0.0/12",
145-
"192.168.0.0/16"
146-
],
147-
"sourcePortRange": "*",
148-
"destinationAddressPrefix": "*",
149-
"destinationPortRange": "*"
150-
}
151-
}
152-
]
142+
"securityRules": "[concat(variables('sshSecurityRules'), createArray(createObject('name', 'Allow-Traffic-RFC-1918', 'properties', createObject('priority', 300, 'protocol', '*', 'access', 'Allow', 'direction', 'Inbound', 'sourceAddressPrefixes', createArray('10.0.0.0/8', '172.16.0.0/12', '192.168.0.0/16'), 'sourcePortRange', '*', 'destinationAddressPrefix', '*', 'destinationPortRange', '*'))))]"
153143
}
154144
},
155145
{

0 commit comments

Comments
 (0)