The pe-easy-agent.sh script mentioned in the instance_defaults hash is available at pe-easy-agent.sh
Last active
August 29, 2015 14:02
-
-
Save adamcrews/b762f75c2f88fda395a9 to your computer and use it in GitHub Desktop.
GCE setup
This file contains hidden or 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
gce::instance_defaults: | |
ensure: present | |
machine_type: 'n1-highcpu-2' | |
puppet_master: 'puppet.example.com' | |
puppet_service: present | |
on_host_maintenance: migrate | |
network: default | |
image: 'projects/centos-cloud/global/images/centos-6-v20140605' | |
startupscript: 'pe-easy-agent.sh' | |
metadata: | |
pe_master: 'puppet.example.com' | |
gce::servers: | |
'monitor-uscentral02': | |
description: 'monitor-uscentral02' | |
zone: 'us-central1-a' | |
'monitor-uscentral03': | |
description: 'monitor-uscentral03' | |
zone: 'us-central1-b' | |
'monitor-asia02': | |
description: 'monitor-asia02' | |
zone: 'asia-east1-a' | |
'monitor-europe02': | |
description: 'monitor-europe02' | |
zone: 'europe-west1-b' | |
# A hash of proxyserver -> gce project mappings | |
gce::project_name: | |
'puppet.example.com': 'pd-monitors' |
This file contains hidden or 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
# This file is managed with puppet | |
# | |
<% @gce_project.each do |server, project| -%> | |
[<%= server %>] | |
type gce | |
url [/dev/null]:<%= project %> | |
<% end -%> |
This file contains hidden or 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
class profile::gce { | |
$gce_project = hiera('gce::project_name') | |
$gce_servers = hiera('gce::servers') | |
$gce_instance_defaults = hiera('gce::instance_defaults') | |
# We need the GCE utils installed. This is a manual step at this point. | |
# To find the tools we need to alter the PATH for root: | |
file { '/etc/profile.d/gce.sh': | |
ensure => file, | |
owner => 'root', | |
group => 'root', | |
mode => '0644', | |
source => "puppet:///modules/${module_name}/gce_profile.sh", | |
notify => Service['pe-httpd'], | |
} | |
# We need to adjust the path setting in the puppetmaster | |
# so that the provider for gce can find the tools. | |
# the above modification is not working when the daemon starts | |
# when the system boots. | |
# Note: Service['pe-httpd'] is managed by some other puppet module | |
# that comes stock with PE. We are just assuming it's there. | |
# We are also assuming that this class is applied to a puppetmaster | |
# that's a lot of assumptions that may not always be true. | |
ini_setting { "Add path in puppet": | |
ensure => present, | |
path => $settings::config, | |
section => 'main', | |
setting => 'path', | |
value => '/bin:/usr/bin:/usr/local/bin:/sbin:/usr/sbin:/usr/local/sbin:/opt/puppet/bin:/opt/puppet/sbin:/usr/local/gce/google-cloud-sdk/bin', | |
notify => Service['pe-httpd'], | |
} | |
# setup device.conf | |
# gce_project is a hash of device/proxy servers (currently only the puppetmaster) to gce project names | |
file { $settings::deviceconfig: | |
ensure => file, | |
owner => 'root', | |
group => $settings::group, | |
mode => '0644', | |
content => template("${module_name}/device.conf.erb"), | |
} | |
Gce_instance { | |
require => File[$settings::deviceconfig], | |
} | |
# Boom, instant infrastructure. This is the most awesome saucy thing ever | |
create_resources(gce_instance, $gce_servers, $gce_instance_defaults) | |
} |
This file contains hidden or 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
if [ -d /usr/local/gce/google-cloud-sdk/bin ]; then | |
pathmunge /usr/local/gce/google-cloud-sdk/bin after | |
export CLOUDSDK_PYTHON_SITEPACKAGES=1 | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment