Skip to content

Instantly share code, notes, and snippets.

@wernerb
Last active August 29, 2015 14:04
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 wernerb/35a06e08a4d4e6cb02aa to your computer and use it in GitHub Desktop.
Save wernerb/35a06e08a4d4e6cb02aa to your computer and use it in GitHub Desktop.
---
clusters:
#Static website running nginx and displaying the
smallweb:
state:
provider: private
instance-template: small-centos-6.5
nodes: 3
dependencies: []
cluster-groups: []
lifecycle:
- start
# It may seem weird but this means that nodes will terminate immediately after loading state.
- terminate
# Run a script at any point, it is also templateable!
- script: |-
echo "Hi, I am {{my.name}}. What do I have running?"
# Installs chef
- runner: chef@0.0.3/install
# A barrier, nodes will only continue to the next steps if they all reached the barrier.
# This can be used to make sure the next step is processed at the same time. Barrier is not necessary for small web, but for demonstration purposes.
- barrier
# Each node will serially run the steps. Not necessary for smallweb, but for demonstration purposes.
- serial:
#Runs chef-solo
- runner: chef@0.0.3/run
variables:
CHEF_ALWAYS_INSTALL_CHEF: "false"
CHEF_COOKBOOKS_TAR_PATH: bootstrap-chef-test-cookbooks-App/cookbooks
CHEF_COOKBOOKS_URL: "https://github.com/ozone-io/bootstrap-chef-test-cookbooks/archive/App.tar.gz"
CHEF_COOKBOOK_PATH: /var/chef/cookbooks
CHEF_INSTALL_SCRIPT: "https://www.opscode.com/chef/install.sh"
CHEF_INSTALL_SCRIPT_ARGS: "-v11.10.4"
files:
#a suffix with .mustache indicates it is a template that must be compiled with the mustache engine
# When compiled the suffix is removed and uploaded.
node.json.mustache:
#Defines node.json, a chef-solo configuration file.
value: |
{
"app": {
"name": "mysite",
"web_dir": "/var/data/www/apps/mysite",
"instance_name": "{{my.node_name}}"
},
"user": {
"name": "nobody"
},
"nginx": {
"default_site_enabled": false
},
"run_list": [
"apt::default",
"recipe[nginx]",
"recipe[ntp]",
"recipe[web]",
"recipe[iptables-ng::install]"
],
"ntp": {
"is_server": false,
"servers": [
"0.pool.ntp.org",
"1.pool.ntp.org"
]
}
}
#Nginx loadbalancer. Started when smallweb cluster is up and running.
lb:
state:
provider: private
instance-template: small-ubuntu
nodes: 1
dependencies:
- smallweb
cluster-groups: []
lifecycle:
- start
- runner: chef@0.0.3/install
- runner: chef@0.0.3/run
# Terminate at the end means that even the nodes that are set to be terminated will run through all the previous steps.
- terminate
variables:
CHEF_ALWAYS_INSTALL_CHEF: "false"
CHEF_COOKBOOKS_TAR_PATH: bootstrap-chef-test-cookbooks-LoadBalancer/cookbooks
CHEF_COOKBOOKS_URL: "https://github.com/ozone-io/bootstrap-chef-test-cookbooks/archive/LoadBalancer.tar.gz"
CHEF_COOKBOOK_PATH: /var/chef/cookbooks
CHEF_INSTALL_SCRIPT: "https://www.opscode.com/chef/install.sh"
CHEF_INSTALL_SCRIPT_ARGS: "-v11.10.4"
files:
node.json.mustache:
value: |
{
"app": {
"name": "mylb",
"web_dir": "/var/data/www/apps/mylb",
"upstreams":
{{#js_array}}
{{#clusters.smallweb}}
{{private_ip}}||
{{/clusters.smallweb}}
{{/js_array}}
},
"user": {
"name": "nobody"
},
"nginx": {
"default_site_enabled": false
},
"run_list": [
"apt::default",
"recipe[nginx]",
"recipe[ntp]",
"recipe[lb]",
"recipe[iptables-ng::install]"
],
"ntp": {
"is_server": false,
"servers": [
"0.pool.ntp.org",
"1.pool.ntp.org"
]
}
}
providers:
public:
provider: aws-ec2
credentials:
credential: id
identity: secret
instanceProfiles:
medium-centos:
hardwareId: m1.small
imageId: eu-west-1/ami-d1bea1a5
locationId: eu-west-1a
small-centos:
hardwareId: t1.micro
imageId: eu-west-1/ami-d1bea1a5
locationId: eu-west-1a
private:
provider: openstack-nova
credentials:
credential: nova
identity: "admin:admin"
endpoint: "http://192.168.75.137:5000/v2.0/"
instanceProfiles:
#Official Centos 6.5
small-centos:
hardwareId: RegionOne/55da1e54-6650-4fc0-a42b-ad79263fb5c1
imageId: RegionOne/88a09c56-c1f5-4c9d-a258-bcee14f9c607
locationId: RegionOne
#The image username is cloud-user
overrideLoginUser: cloud-user
#This image needs to authenticate with sudo for root operations.
overrideAuthenticateSudo: true
novaOptions:
# centos by default has requiretty enabled. This disables it so we can provision it.
userData: |
#cloud-config
runcmd:
- echo 'Defaults:cloud-user !requiretty' > /etc/sudoers.d/888-ozone-cloud-init-requiretty
keyPairName: atlas
securityGroupNames:
#Defined the 'fullaccess' security group as allowing all ports for testing purposes
#Future feature: Specify additional security groups to either overwrite or merge per cluster.
- fullaccess
#Rightscale Centos 6.3 image
small-centos-rightscale:
hardwareId: RegionOne/2ad6d75b-131b-477e-b9b1-58fbe23196e5
imageId: RegionOne/df43168b-f6e6-492d-baf5-829f8480cd4c
locationId: RegionOne
novaOptions:
keyPairName: atlas
securityGroupNames:
- fullaccess
#Saucy ubuntu 13.10 with 12 GB drive and 512Mb memory
small-ubuntu:
hardwareId: RegionOne/2ad6d75b-131b-477e-b9b1-58fbe23196e5
imageId: RegionOne/4a8ec612-31ee-483f-8df3-634baa94377d
locationId: RegionOne
overrideAuthenticateSudo: true
novaOptions:
keyPairName: atlas
securityGroupNames:
- fullaccess
#Saucy ubuntu 13.10 with more memory
medium-ubuntu:
hardwareId: RegionOne/395a8f14-aeeb-496b-bfda-736d17bbeea0
imageId: RegionOne/dbe90162-ef25-4aef-8ecd-8906fc5d49fb
locationId: RegionOne
novaOptions:
keyPairName: atlas
securityGroupNames:
- fullaccess
jcloudsOverrides:
jclouds.openstack-nova.auto-create-floating-ips: "true"
jclouds.openstack-nova.auto-generate-keypairs: "false"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment