Skip to content

Commit cdaafae

Browse files
committed
Add VM image setup script for verification
1 parent 3425d16 commit cdaafae

14 files changed

Lines changed: 639 additions & 0 deletions
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
.terraform
2+
terraform.tfvars
3+
terraform.tfstate
4+
terraform.tfstate.backup
5+
rdp/*.rdp
6+
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# This Source Code Form is subject to the terms of the Mozilla Public
2+
# License, v. 2.0. If a copy of the MPL was not distributed with this
3+
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
4+
5+
.PHONY: apply ansible destroy
6+
7+
SHELL=/bin/bash
8+
9+
all: apply
10+
11+
terraform.tfvars:
12+
cat terraform.tfvars.template | sed -e "s/%password%/$$(pwgen -s --remove-chars="\'\"$$%{}" -y 20 1)/gi" > terraform.tfvars
13+
# Chrome policy template via https://dl.google.com/dl/edgedl/chrome/policy/policy_templates.zip
14+
@if [ -f ansible/files/policy_templates.zip ]; then \
15+
sed -i'' -e 's/chrome-policy-template-archive = ""/chrome-policy-template-archive = "policy_templates.zip"/' terraform.tfvars; \
16+
else \
17+
echo "WARNING: missing Chrome ADM/ADMX policy template. Download via https://dl.google.com/dl/edgedl/chrome/policy/policy_templates.zip"; \
18+
echo "WARNING: then put it under ansible/files/policy_templates.zip."; \
19+
fi
20+
# Edge policy template via https://www.microsoft.com/ja-jp/edge/business/download
21+
@if [ -f ansible/files/MicrosoftEdgePolicyTemplates.zip ]; then \
22+
sed -i'' -e 's/edge-policy-template-archive = ""/edge-policy-template-archive = "MicrosoftEdgePolicyTemplates.zip"/' terraform.tfvars; \
23+
else \
24+
echo "WARNING: Missing Edge ADM/ADMX policy template. Download via https://www.microsoft.com/ja-jp/edge/business/download"; \
25+
echo "WARNING: then put it under ansible/files/MicrosoftEdgePolicyTemplates.zip."; \
26+
fi
27+
28+
CHROME_WEBEXT_VERSION=$(shell cat ../../../webextensions/chrome/manifest.json | jq --raw-output ".version")
29+
EDGE_WEBEXT_VERSION=$(shell cat ../../../webextensions/edge/manifest.json | jq --raw-output ".version")
30+
manifest.xml:
31+
cat manifest.xml.template | sed -e "s/CHROME_WEBEXT_VERSION/$(CHROME_WEBEXT_VERSION)/" \
32+
-e "s/EDGE_WEBEXT_VERSION/$(EDGE_WEBEXT_VERSION)/" > ansible/files/manifest.xml
33+
34+
apply: terraform.tfvars manifest.xml
35+
terraform init
36+
terraform plan
37+
time (terraform apply -auto-approve && ansible-playbook -i ansible/hosts ansible/playbook.yml)
38+
39+
apply-playbook:
40+
ansible-playbook -i ansible/hosts ansible/playbook.yml
41+
42+
destroy:
43+
terraform destroy -auto-approve
44+
45+
clean:
46+
rm -rf terraform.tfvars .terraform terraform.tfstate terraform.tfstate.backup
47+
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
hosts
2+
playbook.yml
3+
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
REM
2+
REM c:\Users\Public配下にchrome,edgeのポリシーテンプレートがある想定
3+
REM
4+
5+
REM MicrosoftEdgePolicyTemplates.zipがedgeとして展開されている想定
6+
xcopy /F /E /Y /V edge\windows\admx\*.admx c:\Windows\PolicyDefinitions\
7+
xcopy /F /E /Y /V edge\windows\admx\en-US c:\Windows\PolicyDefinitions\en-US
8+
xcopy /F /E /Y /V edge\windows\admx\ja-JP c:\Windows\PolicyDefinitions\ja-JP
9+
10+
REM policy_templates.zipがchromeとして展開されている想定
11+
xcopy /F /E /Y /V chrome\windows\admx\*.admx c:\Windows\PolicyDefinitions\
12+
xcopy /F /E /Y /V chrome\windows\admx\en-US c:\Windows\PolicyDefinitions\en-US
13+
xcopy /F /E /Y /V chrome\windows\admx\ja-JP c:\Windows\PolicyDefinitions\ja-JP
14+
15+
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
REM
2+
REM ダミーのドメインに参加状態にする
3+
REM See https://hitco.at/blog/apply-edge-policies-for-non-domain-joined-devices/
4+
5+
reg add HKLM\SOFTWARE\Microsoft\Enrollments\FFFFFFFF-FFFF-FFFF-FFFF-FFFFFFFFFFFF /v EnrollmentState /t reg_dword /d 1 /f
6+
reg add HKLM\SOFTWARE\Microsoft\Enrollments\FFFFFFFF-FFFF-FFFF-FFFF-FFFFFFFFFFFF /v EnrollmentType /t reg_dword /d 0 /f
7+
reg add HKLM\SOFTWARE\Microsoft\Enrollments\FFFFFFFF-FFFF-FFFF-FFFF-FFFFFFFFFFFF /v IsFederated /t reg_dword /d 0 /f
8+
reg add HKLM\SOFTWARE\Microsoft\Provisioning\OMADM\Accounts\FFFFFFFF-FFFF-FFFF-FFFF-FFFFFFFFFFFF /v Flags /t reg_dword /d 0xd6fb7f /f
9+
reg add HKLM\SOFTWARE\Microsoft\Provisioning\OMADM\Accounts\FFFFFFFF-FFFF-FFFF-FFFF-FFFFFFFFFFFF /v AcctUId /t reg_sz /d "0x000000000000000000000000000000000000000000000000000000000000000000000000" /f
10+
reg add HKLM\SOFTWARE\Microsoft\Provisioning\OMADM\Accounts\FFFFFFFF-FFFF-FFFF-FFFF-FFFFFFFFFFFF /v RoamingCount /t reg_dword /d 0 /f
11+
reg add HKLM\SOFTWARE\Microsoft\Provisioning\OMADM\Accounts\FFFFFFFF-FFFF-FFFF-FFFF-FFFFFFFFFFFF /v SslClientCertReference /t reg_sz /d "MY;User;0000000000000000000000000000000000000000" /f
12+
reg add HKLM\SOFTWARE\Microsoft\Provisioning\OMADM\Accounts\FFFFFFFF-FFFF-FFFF-FFFF-FFFFFFFFFFFF /v ProtoVer /t reg_sz /d "1.2" /f
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
REM
2+
REM ダミーのドメインから離脱する
3+
REM See https://hitco.at/blog/apply-edge-policies-for-non-domain-joined-devices/
4+
5+
reg delete HKLM\SOFTWARE\Microsoft\Enrollments\FFFFFFFF-FFFF-FFFF-FFFF-FFFFFFFFFFFF /f
6+
reg delete HKLM\SOFTWARE\Microsoft\Provisioning\OMADM\Accounts\FFFFFFFF-FFFF-FFFF-FFFF-FFFFFFFFFFFF /f
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version='1.0' encoding='UTF-8'?>
2+
<gupdate xmlns='http://www.google.com/update2/response' protocol='2.0'>
3+
<app appid='omgmjffdahkpfpginoledpigpfpmlncm'><!-- Edge用アドオンのIDを書く -->
4+
<updatecheck codebase='file:///C:/Users/Public/webextensions/edge.crx' version='1.0' /><!-- `edge.crx` の実際のFile URLを書く -->
5+
</app>
6+
</gupdate>
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<FirstLogonCommands>
2+
<SynchronousCommand>
3+
<CommandLine>cmd /c "mkdir C:\terraform"</CommandLine>
4+
<Description>Create the Terraform working directory</Description>
5+
<Order>11</Order>
6+
</SynchronousCommand>
7+
<SynchronousCommand>
8+
<CommandLine>cmd /c "copy C:\AzureData\CustomData.bin C:\terraform\winrm.ps1"</CommandLine>
9+
<Description>Move the CustomData file to the working directory</Description>
10+
<Order>12</Order>
11+
</SynchronousCommand>
12+
<SynchronousCommand>
13+
<CommandLine>powershell.exe -sta -ExecutionPolicy Unrestricted -file C:\terraform\winrm.ps1</CommandLine>
14+
<Description>Execute the WinRM enabling script</Description>
15+
<Order>13</Order>
16+
</SynchronousCommand>
17+
</FirstLogonCommands>
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
2+
Invoke-WebRequest -Uri https://raw.githubusercontent.com/ansible/ansible-documentation/devel/examples/scripts/ConfigureRemotingForAnsible.ps1 -OutFile ConfigureRemotingForAnsible.ps1
3+
powershell -ExecutionPolicy ByPass -File ConfigureRemotingForAnsible.ps1
4+
Remove-Item -path ConfigureRemotingForAnsible.ps1 -force

0 commit comments

Comments
 (0)