Forge Home


Puppet Google Compute Module


20,936 latest version

2.0 quality score

We run a couple of automated
scans to help you access a
module's quality. Each module is
given a score based on how well
the author has formatted their
code and documentation and
modules are also checked for
malware using VirusTotal.

Please note, the information below
is for guidance only and neither of
these methods should be considered
an endorsement by Puppet.

Version information

  • 0.0.1 (latest)
released Jun 28th 2012
This module has been deprecated by its author since Dec 19th 2018.

The author has suggested google-gcompute as its replacement.

Start using this module


puppetlabs/node_gce — version 0.0.1 Jun 28th 2012

puppetlabs node_gce module

This module provides Puppet cloud provisioner face for Google Compute.


The puppet module tool in Puppet Enterprise 2.5.0+ and Puppet 2.7.14+ resolves dependencies automatically.

node_gce puppet module dependencies:

  • puppetlabs-lib_puppet
  • puppetlabs-pe_gem

node_gce also depends on the following gem (which are installed by the module):

  • oauth2
  • json (optional)
  • system_timer (optional)
  • rspec (dev only)
  • mocha (dev only)


Install puppetlabs-node_gce module and dependencies into module_path:

$ puppet module install puppetlabs-node_gce
Preparing to install into /etc/puppet/modules ...
Downloading from ...
Installing -- do not interrupt ...
└─┬ puppetlabs-node_gce (v0.0.1)
  ├── puppetlabs-lib_puppet (v0.0.1)
  └── puppetlabs-pe_gem (v0.0.1)

For users, apply either init or optional manifest:

$ puppet apply node_gce/tests/init.pp

For developers of the puppet face, apply dev manifest:

$ puppet apply node_gce/tests/dev.pp

If you are running puppet master and wish to enable node_gce face for a node:

node 'dev1.puppetlabs.lan' {
  class { 'node_gce':
    optional    => true,
    development => true,


The uninstall manifests should remove all gems and node_gce lib files from puppet:

$ puppet apply node_gce/tests/uninstall.pp
$ puppet module uninstall puppetlabs-node_gce


Usage of google compute project requires access to a project domain and a unique project id.

  • Enable Google Compute Engine under Google API services

  • Create a Google Compute project domain and project id. (i.e.

  • Create a product name and authorize API access (project name: "Puppet Cloud Provisioner")

  • Create a 'Client ID for an "installed application"'

  • Execute /tmp/build_gce_credentials.rb specifying that output should go to ~/.fog (spec/fixtures/credentials.yml for testing)

      Building credentials file for Google Compute Oauth2
      Go to this link to authorize the application:
      and enter the code you find after authorizing: 4/sbQCOs8lkz8cvjq2k3-jvzafdsaf.
      client_secret: ida8214kdasfsd93
      authorization_code: sfas1/daf9123123kjfasfojdjsfk213213
      refresh_token: dsfas9123kdsfaj123;sadkfa
      Enter file for storing OAuth2 credentials [/tmp/oauth2_credentials.yml]: ~/.fog
      Storing credentials information in [~/.fog]...

Example ~/.fog configuration:

  :client_id: ""
  :client_secret: "ida8214kdasfsd93"
  :authorization_code: "sfas1/daf9123123kjfasfojdjsfk213213"
  :refresh_token: "dsfas9123kdsfaj123;sadkfa"


Puppet Face node_gce usage is similar to other cloud provisioner faces. It support the following list of actions:

$ puppet help node_gce
USAGE: puppet node_gce <action>

This subcommand provides a command line interface to manage Google Compute
machine instances.  We support creation of instances, shutdown of instances
and basic queries for Google Compute data on a per-project basis.

  --mode MODE                    - The run mode to use (user, agent, or master).
  --render-as FORMAT             - The rendering format to use.
  --verbose                      - Whether to log verbosely.
  --debug                        - Whether to log debug information.


  add_metadata       Add or update project metadata sshkey.
  create             Create a new machine instance.
  disks              List disks.
  firewalls          List firewalls.
  images             List images.
  kernels            List kernels.
  list               List machine instances.
  machine_types      List machine types.
  metadata           List project metadata.
  networks           List networks.
  operations         List operations.
  project            Return information on the project in question.
  rm_metadata        Remove project metadata sshkey.
  terminate          Destroy a running machine instance.
  zones              List zones.

Before creating any new instances, make sure the project metadata contains a ssh key. The sshkey metadata key is 'sshKeys' and the value is a list of ssh keys that's in the format of 'usenname:sshkey-type sshkey value' seperated by newlines.

$ puppet node_gce add_metadata --user='paul' --sshkey=~/.ssh/
$ puppet node_gce metadata
 "kind": "compute#project",
 "id": "12797701871295264544",
 "creationTimestamp": "2012-06-20T19:56:41.970",
 "selfLink": "",
 "name": "",
 "description": "",
 "commonInstanceMetadata": {
  "kind": "compute#metadata",
  "items": [
    "key": "sshKeys",
    "value": "paul:ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAg...",

To create new nodes:

$ puppet node_gce create --name=demo1
 "kind": "compute#instance",
 "id": "12920446812432197392",
 "selfLink": "",
 "name": "foo",
 "description": "",
 "image": "",
 "machineType": "",
 "status": "PROVISIONING",
 "zone": "",
 "networkInterfaces": [
   "kind": "compute#networkInterface",
   "name": "nic0",
   "network": "",
   "networkIP": "",
   "accessConfigs": [
     "kind": "compute#accessConfig",
     "name": "External NAT",
     "type": "ONE_TO_ONE_NAT",
     "natIP": ""
 "disks": [
   "kind": "compute#attachedDisk",
   "type": "EPHEMERAL",
   "mode": "READ_WRITE",
   "index": 0

To ssh into the system after it's created provide the appropriate sshkey and login to the public IP address provided above:

$ ssh -i ~/.ssh/private.rsa username@{ipaddress}

Note: when updating metadata sshkeys, new keys may take upwards of 60 sec to propogate.

Google recommends these additional parameters since compute nodes are ephemeral.

$ ssh -o UserKnownHostsFile=/dev/null -o CheckHostIP=no -o StrictHostKeyChecking=no -i ~/.ssh/private.rsa -o LogLevel=QUIET -A -p 22 username@{ipaddress}


To get your environment setup to be able to run specs:

  • git clone and/or update checkouts of puppet, facter, and node_gce face.

     $ cd ~/src
     % git clone
     % git clone
     % git clone
  • Verify puppet version 2.7.12+ and facter version 1.6.9+:

     % . ~/src/puppet/ext/envpuppet
     % puppet --version
     % facter --version
  • Add node_gce/lib to RUBYLIB:

     % set +e
     % RUBYLIB="${RUBYLIB}:${HOME}/git/puppetlabs-node_gce/lib"; export RUBYLIB
     % gem install rspec mocha oauth
  • Execute bin/credentials_builder.rb and specify output file: spec/fixtures/credentials.yml

  • Create a spec/fixtures/project.yml with your project name in it (see spec/fixtures/project.yml-example).

     % rspec spec