Skip to content

Commit

Permalink
Merge pull request #23 from maratoid/cf_support
Browse files Browse the repository at this point in the history
Cf support
  • Loading branch information
maratoid committed Mar 14, 2014
2 parents 2160b08 + 32fab54 commit 2bbe076
Show file tree
Hide file tree
Showing 17 changed files with 659 additions and 4 deletions.
219 changes: 219 additions & 0 deletions test_tasks/cf.ke
Original file line number Diff line number Diff line change
@@ -0,0 +1,219 @@
{
"num_instances": 1,
"vm": {
"driver": {
"drivertype": "cloudformation",
"driveroptions": [
{
"access_key_id": "ENV['AWS_ACCESS_KEY_ID']",
"secret_access_key": "ENV['AWS_SECRET_ACCESS_KEY']",
"template": {
"AWSTemplateFormatVersion": "2010-09-09",
"Description": "AWS CloudFormation Sample Template EC2ChooseAMI: Example to show how to chose an AMI based on the region and the architecture type. **WARNING** This template creates an Amazon EC2 instance. You will be billed for the AWS resources used if you create a stack from this template.",
"Mappings": {
"AWSInstanceType2Arch": {
"c1.medium": {
"Arch": "64"
},
"c1.xlarge": {
"Arch": "64"
},
"cc1.4xlarge": {
"Arch": "64HVM"
},
"cc2.8xlarge": {
"Arch": "64HVM"
},
"cg1.4xlarge": {
"Arch": "64HVM"
},
"m1.large": {
"Arch": "64"
},
"m1.medium": {
"Arch": "64"
},
"m1.small": {
"Arch": "64"
},
"m1.xlarge": {
"Arch": "64"
},
"m2.2xlarge": {
"Arch": "64"
},
"m2.4xlarge": {
"Arch": "64"
},
"m2.xlarge": {
"Arch": "64"
},
"m3.2xlarge": {
"Arch": "64"
},
"m3.xlarge": {
"Arch": "64"
},
"t1.micro": {
"Arch": "64"
}
},
"AWSRegionArch2AMI": {
"ap-northeast-1": {
"32": "ami-0644f007",
"64": "ami-0a44f00b",
"64HVM": "NOT_YET_SUPPORTED"
},
"ap-southeast-1": {
"32": "ami-b4b0cae6",
"64": "ami-beb0caec",
"64HVM": "NOT_YET_SUPPORTED"
},
"ap-southeast-2": {
"32": "ami-b3990e89",
"64": "ami-bd990e87",
"64HVM": "NOT_YET_SUPPORTED"
},
"eu-west-1": {
"32": "ami-973b06e3",
"64": "ami-953b06e1",
"64HVM": "NOT_YET_SUPPORTED"
},
"sa-east-1": {
"32": "ami-3e3be423",
"64": "ami-3c3be421",
"64HVM": "NOT_YET_SUPPORTED"
},
"us-east-1": {
"32": "ami-31814f58",
"64": "ami-1b814f72",
"64HVM": "ami-0da96764"
},
"us-west-1": {
"32": "ami-11d68a54",
"64": "ami-1bd68a5e",
"64HVM": "NOT_YET_SUPPORTED"
},
"us-west-2": {
"32": "ami-38fe7308",
"64": "ami-30fe7300",
"64HVM": "NOT_YET_SUPPORTED"
}
}
},
"Outputs": {
"Instance": {
"Description": "DNS Name of the newly created EC2 instance",
"Value": {
"Fn::GetAtt": [
"Ec2Instance",
"PublicDnsName"
]
}
}
},
"Parameters": {
"InstanceType": {
"AllowedValues": [
"t1.micro",
"m1.small",
"m1.medium",
"m1.large",
"m1.xlarge",
"m2.xlarge",
"m2.2xlarge",
"m2.4xlarge",
"m3.xlarge",
"m3.2xlarge",
"c1.medium",
"c1.xlarge",
"cc1.4xlarge",
"cc2.8xlarge",
"cg1.4xlarge"
],
"ConstraintDescription": "must be a valid EC2 instance type.",
"Default": "m1.small",
"Description": "WebServer EC2 instance type",
"Type": "String"
},
"KeyName": {
"AllowedPattern": "[\\x20-\\x7E]*",
"ConstraintDescription": "can contain only ASCII characters.",
"Description": "Name of an existing EC2 KeyPair to enable SSH access to the web server",
"MaxLength": "255",
"MinLength": "1",
"Type": "String"
},
"SSHLocation": {
"AllowedPattern": "(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})/(\\d{1,2})",
"ConstraintDescription": "must be a valid IP CIDR range of the form x.x.x.x/x.",
"Default": "0.0.0.0/0",
"Description": "The IP address range that can be used to SSH to the EC2 instances",
"MaxLength": "18",
"MinLength": "9",
"Type": "String"
}
},
"Resources": {
"Ec2Instance": {
"Properties": {
"ImageId": {
"Fn::FindInMap": [
"AWSRegionArch2AMI",
{
"Ref": "AWS::Region"
},
{
"Fn::FindInMap": [
"AWSInstanceType2Arch",
{
"Ref": "InstanceType"
},
"Arch"
]
}
]
},
"InstanceType": {
"Ref": "InstanceType"
},
"KeyName": {
"Ref": "KeyName"
},
"SecurityGroups": [
{
"Ref": "Ec2SecurityGroup"
}
]
},
"Type": "AWS::EC2::Instance"
},
"Ec2SecurityGroup": {
"Properties": {
"GroupDescription": "HTTP and SSH access",
"SecurityGroupIngress": [
{
"CidrIp": {
"Ref": "SSHLocation"
},
"FromPort": "22",
"IpProtocol": "tcp",
"ToPort": "22"
}
]
},
"Type": "AWS::EC2::SecurityGroup"
}
}
},
"template_parameters": {
"InstanceType": "t1.micro",
"KeyName": "ENV['AWS_KEY_PAIR']",
"SSHLocation": "0.0.0.0/0"
}
}
]
},
"instances": []
}
}
2 changes: 0 additions & 2 deletions zerg/data/ke.schema
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
},
"instances": {
"type": "array",
"minItems": 1,
"items": {
"properties": {
"basebox": {
Expand All @@ -44,7 +43,6 @@
},
"tasks": {
"type": "array",
"minItems": 1,
"items": {
"properties": { <%= driver_tasks_schema %> }
}
Expand Down
2 changes: 1 addition & 1 deletion zerg/lib/zerg/gem_plugin.rb
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ def load(needs = {})
end
end
}

return nil
end

Expand Down
1 change: 1 addition & 0 deletions zerg/lib/zerg/runner.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ def self.rush(task, debug)
begin
pmgr = ZergGemPlugin::Manager.instance
pmgr.load
puts "/driver/#{Zerg::Hive.instance.hive[task]["vm"]["driver"]["drivertype"]}"
driver = pmgr.create("/driver/#{Zerg::Hive.instance.hive[task]["vm"]["driver"]["drivertype"]}")
driver.rush Zerg::Hive.instance.load_path, task, Zerg::Hive.instance.hive[task], debug
rescue ZergGemPlugin::PluginNotLoaded
Expand Down
2 changes: 1 addition & 1 deletion zerg/lib/zerg/version.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,5 @@
#++

module Zerg
VERSION = "0.0.7"
VERSION = "0.0.8"
end
1 change: 1 addition & 0 deletions zerg/zerg.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ Gem::Specification.new do |s|
s.add_dependency "thor"
s.add_dependency "highline"
s.add_dependency "zergrush_vagrant", ">= 0.0.4"
s.add_dependency "zergrush_cf", ">= 0.0.1"

s.files = `git ls-files`.split("\n")
s.executables = `git ls-files`.split("\n").map{|f| f =~ /^bin\/(.*)/ ? $1 : nil}.compact
Expand Down
2 changes: 2 additions & 0 deletions zerg_plugins/zergrush_cf/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
pkg
tmp
1 change: 1 addition & 0 deletions zerg_plugins/zergrush_cf/COPYING
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
No copying restrictions/license given.
1 change: 1 addition & 0 deletions zerg_plugins/zergrush_cf/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
No license given.
113 changes: 113 additions & 0 deletions zerg_plugins/zergrush_cf/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
Vagrant driver for Zerg
===

Dependencies
--------------

- [vagrant-aws](https://github.com/mitchellh/vagrant-aws)
- [vagrant-libvirt](https://github.com/pradels/vagrant-libvirt)
- [vagrant-omnibus](https://github.com/schisamo/vagrant-omnibus)
- [vagrant-berkshelf](https://github.com/berkshelf/vagrant-berkshelf)

Additional properties defined
--------------

######[Synchronized folders](resources/folder_schema.template)

Defined by [Vagrant synced folders](http://docs.vagrantup.com/v2/synced-folders/)

Example use:
```
...
"create": true,
"mount_options": ["rw", "vers=3", "tcp"]
...
```

######[Networks](resources/networks_schema.template)

Defined by [Vagrant networking](http://docs.vagrantup.com/v2/networking/index.html)

Example use:
```
...
"type": "public_network",
"bridge": "en1: Wi-Fi (AirPort)"
...
```

######[Driver options](resources/option_schema.template)

- providertype - One of the supported Vagrant providers. Currenlty supported providers are: virtualbox, libvirt, aws
- provider_options - hash of provider specific options.
- raw_options - if some of the provider options do not map to a hash format - you can specify them as an array of strings. Each string should start with '[provider].'

Example use:
```
...
"driver": {
"drivertype": "vagrant",
"driveroptions": [
{
"providertype": "aws",
"provider_options" : {
"instance_type": "t1.micro",
"access_key_id": "blah blah blah",
"secret_access_key": "yadda yadda",
"keypair_name": "HURGHBURGHLGHRL",
"ami": "ami-3fec7956",
"region": "us-east-1"
}
},
{
"providertype": "virtualbox",
"provider_options" : {
"gui": false,
"memory": 256
},
"raw_options": [
"virtualbox.customize [\"modifyvm\", :id, \"--natdnsproxy1\", \"off\"]",
"virtualbox.customize [\"modifyvm\", :id, \"--natdnshostresolver1\", \"off\"]"
]
}
]
}
...
```

######[Forwarded ports](resources/ports_schema.template)

Defined by [Vagrant forwarded ports](http://docs.vagrantup.com/v2/networking/forwarded_ports.html)

Example use:
```
...
"guest_port": 8080,
"host_port": 80,
"protocol": "tcp"
...
```

######[SSH](resources/ssh_schema.template)

Defined by [Vagrant SSH](http://docs.vagrantup.com/v2/vagrantfile/ssh_settings.html)

Example use:
```
...
"username": "ubuntu",
"private_key_path": "PATH_TO_YOUR_PK",
"shell": "bash -l"
...
```

######[Tasks](resources/tasks_schema.template)

Describes what tasks a VM should run at provisioning step

- type - Type of task payload. 'shell', 'chef_client' or 'chef_solo'
- shell task parameters are defined by [Vagrant shell provisioner](http://docs.vagrantup.com/v2/provisioning/shell.html)
- chef_client and chef_solo task parameters map directly to Vagrant provisioner docs, **EXCEPT the node_name parameter**:
- [chef_solo provisioner](http://docs.vagrantup.com/v2/provisioning/chef_solo.html)
- [chef_client provisioner](https://docs.vagrantup.com/v2/provisioning/chef_client.html)
- [chef common options](http://docs.vagrantup.com/v2/provisioning/chef_common.html)
1 change: 1 addition & 0 deletions zerg_plugins/zergrush_cf/Rakefile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
require "bundler/gem_tasks"
Loading

0 comments on commit 2bbe076

Please sign in to comment.