-
Notifications
You must be signed in to change notification settings - Fork 2
/
updateRGTemplate.py
29 lines (21 loc) · 1 KB
/
updateRGTemplate.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import json
import os
import subprocess
import sys
from pprint import pprint
templateString = subprocess.check_output(['az.bat', 'group', 'export', '-n', 'bishal-packer-app', '-o', 'json']).decode(sys.stdout.encoding)
template = json.loads(templateString)
print(template["resources"])
template["parameters"]["imageUrl"] = {
"defaultValue": "",
"type": "String"
}
for resource in template["resources"]:
if resource["type"] == "Microsoft.Compute/virtualMachineScaleSets":
resource["properties"]["virtualMachineProfile"]["storageProfile"]["osDisk"]["image"] = "[parameters('imageUrl')]"
#pprint(resource)
pprint(template["resources"])
#outputFile = os.path.join($(System.DefaultWorkingDirectory), "updatedResourceTemplate.json")
outputFile = os.path.join("E:\\github\\packer-sample", "updatedResourceTemplate.json")
with open(outputFile, 'w') as f:
json.dump(template, f)