Created
August 6, 2016 07:18
-
-
Save ncouture/b2aa675c95b255421cf247631d18c1ec to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{% import "path_utils.jinja" as path_utils with context %} | |
{% set project = env["project"] %} | |
{% set deployment = env["deployment"] %} | |
{% set name = "%s-vm-tmpl" % env["name"] %} | |
{% set instanceName = "%s-vm" % deployment %} | |
{% set zone = properties["zone"] %} | |
{% set machineType = properties["machineType"] %} | |
{% set network = path_utils.networkPath(properties["network"]) %} | |
{% set subnetwork = properties["subnetwork"] %} | |
{% set bootDiskType = properties["bootDiskType"] %} | |
{% set bootDiskSizeGb = properties["bootDiskSizeGb"] %} | |
resources: | |
- name: {{ name }} | |
type: vm_instance.py | |
properties: | |
instanceName: {{ instanceName }} | |
sourceImage: https://www.googleapis.com/compute/v1/projects/bitnami-launchpad/global/images/bitnami-postgresql-9-5-3-1-linux-debian-8-x86-64 | |
zone: {{ zone }} | |
machineType: {{ machineType }} | |
network: {{ network }} | |
{% if subnetwork %} | |
subnetwork: {{ subnetwork }} | |
{% endif %} | |
bootDiskType: {{ bootDiskType }} | |
bootDiskSizeGb: {{ bootDiskSizeGb }} | |
staticIP: False | |
serviceAccounts: | |
- email: default | |
scopes: | |
- 'https://www.googleapis.com/auth/cloud.useraccounts.readonly' | |
- 'https://www.googleapis.com/auth/devstorage.read_only' | |
- 'https://www.googleapis.com/auth/logging.write' | |
- 'https://www.googleapis.com/auth/monitoring.write' | |
- 'https://www.googleapis.com/auth/cloudruntimeconfig' | |
metadata: | |
items: | |
- key: google-cloud-marketplace-generate-password | |
value: bitnami-base-password | |
- key: bitnami-base-password | |
value: $(ref.generated-password.password) | |
- key: status-config-url | |
value: $(ref.software-status.config-url) | |
- key: status-variable-path | |
value: $(ref.software-status.variable-path) | |
- key: status-uptime-deadline | |
value: 420 | |
- key: startup-script | |
value: $(ref.software-status-script.startup-script) | |
tags: | |
items: | |
- {{ deployment }}-tcp-5432 | |
- name: generated-password | |
type: password.py | |
properties: | |
length: 8 | |
includeSymbols: False | |
- name: software-status | |
type: software_status.py | |
properties: | |
timeout: 480 | |
waiterDependsOn: | |
- {{ instanceName }} | |
- name: software-status-script | |
type: software_status_script.py | |
properties: | |
checkScript: |- | |
failed=$(/etc/init.d/bitnami status \ | |
| grep "not running" | cut -d" " -f1 | tr "\n" " ") | |
if [ ! -z "$failed" ]; then | |
echo "Processes failed to start: $failed" | |
exit 1 | |
fi | |
{% if properties["enableTcp5432"] %} | |
- name: {{ deployment }}-tcp-5432 | |
type: compute.v1.firewall | |
properties: | |
network: {{ network }} | |
sourceRanges: ["0.0.0.0/0"] | |
targetTags: ["{{ deployment }}-tcp-5432"] | |
allowed: | |
- IPProtocol: TCP | |
ports: ["5432"] | |
{% endif %} | |
outputs: | |
- name: deployment | |
value: {{ deployment }} | |
- name: password | |
value: $(ref.generated-password.password) | |
- name: project | |
value: {{ project }} | |
- name: vmId | |
value: $(ref.{{ instanceName }}.id) | |
- name: vmName | |
value: {{ instanceName }} | |
- name: vmSelfLink | |
value: $(ref.{{ instanceName }}.selfLink) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment