|
| 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 | + |
0 commit comments