Skip to content

Instantly share code, notes, and snippets.

@rmoriz

rmoriz/test.rb Secret

Last active August 29, 2015 14:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rmoriz/f293ca1402591c5469ae to your computer and use it in GitHub Desktop.
Save rmoriz/f293ca1402591c5469ae to your computer and use it in GitHub Desktop.
Chef-Provisioning example
# see: https://github.com/chef/chef-provisioning-google
# bundle exec chef-client -z provisioning/example.rb
# SSL ISSUES?
# => https://github.com/chef/chef-provisioning/issues/343
require 'chef/provisioning/google_driver'
repo_directory = File.expand_path('../..', __FILE__)
with_chef_local_server(
chef_repo_path: repo_directory,
cookbook_path: File.join(repo_directory, 'cookbooks')
)
# Accounts/Project-IDs of @rmoriz
#
# project_id is autogenerated by google, NOT the user set project name!
project_id = 'core-xxxxxx-xxxxx'
# zones: https://cloud.google.com/compute/docs/zones
with_driver "google:europe-west1-d:#{project_id}",
google_credentials: {
p12_path: '/Users/rmoriz/xxxxxxxxxxxxxx.p12',
issuer: 'xxxxxxxxxxxxxx@developer.gserviceaccount.com',
passphrase: 'xxxxxxxxxxxxxx'
}
# ssh keys, will be loaded from .chef/keys/<name> + deployed on servers
# ssh -i .chef/keys/google_default <gce-server-ip>
# see also: https://github.com/chef/chef-provisioning-google/issues/1
google_key_pair 'google_default' do
private_key_path 'google_default'
public_key_path 'google_default.pub'
end
machine 'testnode01' do
# see https://github.com/chef/chef-provisioning-google#supplying-insert_options-for-machine-creation
# https://cloud.google.com/compute/docs/reference/latest/instances#resource
machine_options(
insert_options: {
machineType: 'zones/europe-west1-d/machineTypes/f1-micro',
scheduling: {
preemptible: true # save money while testing
}
},
key_name: 'google_default'
)
# example runlist
recipe 'apt'
recipe 'build-essential::default'
# attributes
attribute %w(apt compile_time_update), true
action [:converge]
# action [:converge, :destroy]
end
machine 'testnginx01' do
# see https://github.com/chef/chef-provisioning-google#supplying-insert_options-for-machine-creation
# https://cloud.google.com/compute/docs/reference/latest/instances#resource
machine_options(
insert_options: {
machineType: 'zones/europe-west1-d/machineTypes/f1-micro',
scheduling: {
preemptible: true # save money while testing
}
},
key_name: 'google_default'
)
# example runlist
recipe 'apt'
recipe 'build-essential'
recipe 'nginx'
# attributes
attribute %w(apt compile_time_update), true
action [:converge]
# action [:converge, :destroy]
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment