Adoptable Cookbooks List

Looking for a cookbook to adopt? You can now see a list of cookbooks available for adoption!
List of Adoptable Cookbooks

Supermarket Belongs to the Community

Supermarket belongs to the community. While Chef has the responsibility to keep it running and be stewards of its functionality, what it does and how it works is driven by the community. The chef/supermarket repository will continue to be where development of the Supermarket application takes place. Come be part of shaping the direction of Supermarket by opening issues and pull requests or by joining us on the Chef Mailing List.

Select Badges

Select Supported Platforms

Select Status

RSS

gce (2) Versions 0.3.0

LWRPs for managing GCE resources

Policyfile
Berkshelf
Knife
cookbook 'gce', '~> 0.3.0', :supermarket
cookbook 'gce', '~> 0.3.0'
knife supermarket install gce
knife supermarket download gce
README
Dependencies
Quality 33%

Google Compute Engine Cookbook LWRP

Description

This cookbook provides libraries, resources and providers to configure
and manage Google Compute Engine components. The currently supported
GCE resources are:

  • disks (disk)
  • firewalls (firewall)
  • instances (instance)
  • lb forwarding rules (lb_forwardingrule)
  • lb health checks (lb_healthcheck)
  • lb target pools (lb_targetpool)
  • metadata (metadata)
  • networks (network)
  • snapshots (snapshot)
  • tags (tags)

Requirements

Requires fog ruby gem to interact with GCP.

Authorizing Setup

In order to use the Google Compute Engine cookbook with your servers, you will first
need to authorize its use of the Google Compute Engine API. Authorization to use
any of Google's Cloud service API's utilizes an OAuth 2.0
Service account.
Once your project has been created, log in to the
Google Developers Console and
select your project. Next select APIs & auth then Credentials. Create a new
"Client ID" and specify "Service account". This will generate a new public/private key
pair.

    % knife data bag show gce service_account
    {
      "project_id": "my-gce-project",
      "client_email": "my-gce-project@developer.gserviceaccount.com",
      "key_location": "/home/user/.my-gce-project-private-key.p12"
    }

This can be loaded in a recipe with:

    gce = data_bag_item("gce", "service_account")

And to access the values:

    gce['project_id']
    gce['client_email']
    gce['key_location']

Installation

Download and install as you would other cookbooks.

From the Chef Community Site

knife cookbook site install gce

Using Librarian-Chef

Librarian-Chef Librarian is a framework
for writing bundlers, which are tools that resolve, fetch, install, and isolate a project's
dependencies, in Ruby.

To use the Opscode platform version:

    echo "cookbook 'gce'" >> Cheffile
    librarian-chef install

To use the Git version:

    echo "cookbook 'gce', :git => 'git@github.com:chef-partners/google-compute-engine.git'" >> Cheffile
    librarian-chef install

Recipes

default.rb

The default recipe installs the fog ruby gem, which this
cookbook requires in order to work with the GCE API. Make sure that
the google-compute-engine recipe is in the node or role run_list before any resources
from this cookbook are used.

    "run_list": [
      "recipe[google-compute-engine]"
    ]

Libraries

The cookbook has a library module, Google::Gce, which can be
included where necessary:

  include Google::Gce

Resources and Providers

This cookbook provides a resource and corresponding provider.

disk.rb

Manage GCE persistent disk with this resource.

Actions:

  • create - create a new disk.
  • delete - delete a disk.
  • attach - attach the specified disk.
  • detach - detach the specified disk.

Attribute Parameters:

firewall.rb

  • create - create a new firewall.
  • delete - delete a firewall.

instance.rb

  • create - create a new instance.
  • delete - delete a instance.

lb_forwardingrule.rb

  • create - create a new forwarding rule.
  • delete - delete a forwarding rule.

lb_healthcheck.rb

  • create - create a new healthcheck.
  • delete - delete a healthcheck.

lb_targetpool.rb

  • create - create a new targetpool.
  • add_instance - add instance to targetpool.
  • add_healthcheck - add healthcheck to targetpool.
  • remove_instance - remove instance from a targetpool.
  • remove_healthcheck - remove healthcheck from a targetpool.
  • delete - delete a targetpool.

metadata.rb

  • set - set instance metadata.
  • delete - delete instance metadata.

network.rb

  • create - create a new network.
  • delete - delete a network.

snapshot.rb

  • create - create a new snapshot.
  • delete - delete a snapshot.

tags.rb

  • set - set instance tags.
  • delete - delete instance tags.

Usage

instance

This will create a new instance.

    gce_instance "my-gce-instance" do
      machine_type "n1-standard-1"
      zone_name "us-central1-a"
      boot_disk_image "debian-7-wheezy-v20140318"
      service_account_scopes ["compute", "userinfo.email", "devstorage.full_control"]
      auto_restart true
      on_host_maintenance "MIGRATE"
      action :create
    end

firewall

This will create a new firewall.

    gce_firewall "my-firewall" do
      client_email gce['client_email']
      key_location gce['key_location']
      project_id gce['project_id']
      description "my firewall"
      allowed [{"tcp"=>"1000"}, {"tcp"=>["1001","1002"]}, {"udp"=>"1000-1002"}, {"udp"=>["1010-1012"]}]
      source_tags ["foo", "bar"]
      target_tags ["baz", "qux"]
    end

This will delete an existing firewall.

    gce_firewall "my-firewall" do
      client_email gce['client_email']
      key_location gce['key_location']
      project_id gce['project_id']
      action :delete
    end

License and Authors

Copyright 2014, Google, Inc.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

Dependent cookbooks

This cookbook has no specified dependencies.

Contingent cookbooks

There are no cookbooks that are contingent upon this one.

Collaborator Number Metric
            

0.3.0 passed this metric

Contributing File Metric
            

0.3.0 failed this metric

Failure: To pass this metric, your cookbook metadata must include a source url, the source url must be in the form of https://github.com/user/repo, and your repo must contain a CONTRIBUTING.md file

Foodcritic Metric
            

0.3.0 failed this metric

FC055: Ensure maintainer is set in metadata: gce/providers/metadata.rb:1
FC055: Ensure maintainer is set in metadata: gce/resources/metadata.rb:1
FC056: Ensure maintainer_email is set in metadata: gce/providers/metadata.rb:1
FC056: Ensure maintainer_email is set in metadata: gce/resources/metadata.rb:1
FC062: Cookbook should have version metadata: gce/providers/metadata.rb:1
FC062: Cookbook should have version metadata: gce/resources/metadata.rb:1
FC064: Ensure issues_url is set in metadata: gce/metadata.rb:1
FC064: Ensure issues_url is set in metadata: gce/providers/metadata.rb:1
FC064: Ensure issues_url is set in metadata: gce/resources/metadata.rb:1
FC065: Ensure source_url is set in metadata: gce/metadata.rb:1
FC065: Ensure source_url is set in metadata: gce/providers/metadata.rb:1
FC065: Ensure source_url is set in metadata: gce/resources/metadata.rb:1
FC066: Ensure chef_version is set in metadata: gce/metadata.rb:1
FC066: Ensure chef_version is set in metadata: gce/providers/metadata.rb:1
FC066: Ensure chef_version is set in metadata: gce/resources/metadata.rb:1
FC067: Ensure at least one platform supported in metadata: gce/metadata.rb:1
FC067: Ensure at least one platform supported in metadata: gce/providers/metadata.rb:1
FC067: Ensure at least one platform supported in metadata: gce/resources/metadata.rb:1
FC068: Ensure license is set in metadata: gce/providers/metadata.rb:1
FC068: Ensure license is set in metadata: gce/resources/metadata.rb:1
FC069: Ensure standardized license defined in metadata: gce/metadata.rb:1
FC069: Ensure standardized license defined in metadata: gce/providers/metadata.rb:1
FC069: Ensure standardized license defined in metadata: gce/resources/metadata.rb:1
FC072: Metadata should not contain "attribute" keyword: gce/resources/metadata.rb:1
FC074: LWRP should use DSL to define resource's default action: gce/resources/disk.rb:1
FC074: LWRP should use DSL to define resource's default action: gce/resources/firewall.rb:1
FC074: LWRP should use DSL to define resource's default action: gce/resources/instance.rb:1
FC074: LWRP should use DSL to define resource's default action: gce/resources/lb_forwardingrule.rb:1
FC074: LWRP should use DSL to define resource's default action: gce/resources/lb_healthcheck.rb:1
FC074: LWRP should use DSL to define resource's default action: gce/resources/lb_targetpool.rb:1
FC074: LWRP should use DSL to define resource's default action: gce/resources/metadata.rb:1
FC074: LWRP should use DSL to define resource's default action: gce/resources/network.rb:1
FC074: LWRP should use DSL to define resource's default action: gce/resources/snapshot.rb:1
FC074: LWRP should use DSL to define resource's default action: gce/resources/tags.rb:1
Run with Foodcritic Version 16.3.0 with tags metadata,correctness ~FC031 ~FC045 and failure tags any

No Binaries Metric
            

0.3.0 passed this metric

Testing File Metric
            

0.3.0 failed this metric

Failure: To pass this metric, your cookbook metadata must include a source url, the source url must be in the form of https://github.com/user/repo, and your repo must contain a TESTING.md file

Version Tag Metric
            

0.3.0 failed this metric

Failure: To pass this metric, your cookbook metadata must include a source url, the source url must be in the form of https://github.com/user/repo, and your repo must include a tag that matches this cookbook version number