-
-
Save ody/f3e526e70e3b916cdd45bb0857d33d1d to your computer and use it in GitHub Desktop.
Puppet for GCP Instances Example
This file contains 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
$project = 'slice-cody' # Don't forget to update this with you're project name. | |
$credpath = '/home/ody/engine-only.json' # Don't forget to update this to the path and name of the service account key you created and downloaded earlier. | |
$cred = 'default' | |
gauth_credential { $cred: | |
provider => serviceaccount, | |
path => $credpath, | |
scopes => ['https://www.googleapis.com/auth/cloud-platform'], | |
} | |
gcompute_network { 'default': | |
project => $project, | |
credential => $cred, | |
} | |
gcompute_region { 'us-west1': | |
project => $project, | |
credential => $cred, | |
} | |
gcompute_zone { 'us-west1-c': | |
project => $project, | |
credential => $cred, | |
} | |
gcompute_machine_type { 'f1-micro': | |
name => 'f1-micro', | |
zone => 'us-west1-c', | |
project => $project, | |
credential => $cred, | |
} | |
['one','two','three','four','five'].each |$vm| { | |
gcompute_address { $vm: | |
ensure => present, | |
region => 'us-west1', | |
project => $project, | |
credential => $cred, | |
} | |
gcompute_disk { $vm: | |
ensure => present, | |
size_gb => 50, | |
source_image => gcompute_image_family('ubuntu-1604-lts', 'ubuntu-os-cloud'), | |
zone => 'us-west1-c', | |
project => $project, | |
credential => $cred, | |
} | |
gcompute_instance { $vm: | |
ensure => present, | |
machine_type => 'f1-micro', | |
disks => [ | |
{ | |
boot => true, | |
source => $vm, | |
auto_delete => true, | |
} | |
], | |
network_interfaces => [ | |
{ | |
network => 'default', | |
access_configs => [ | |
{ | |
name => 'External NAT', | |
nat_ip => $vm, | |
type => 'ONE_TO_ONE_NAT', | |
} | |
], | |
} | |
], | |
zone => 'us-west1-c', | |
project => $project, | |
credential => $cred, | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
name is optional as title == name