Skip to content

Instantly share code, notes, and snippets.

@ody

ody/instances.pp Secret

Last active September 6, 2017 23:52
Show Gist options
  • Save ody/f3e526e70e3b916cdd45bb0857d33d1d to your computer and use it in GitHub Desktop.
Save ody/f3e526e70e3b916cdd45bb0857d33d1d to your computer and use it in GitHub Desktop.
Puppet for GCP Instances Example
$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,
}
}
@nelsonjr
Copy link

nelsonjr commented Sep 6, 2017

name is optional as title == name

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment