fhcap-cli 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +10 -0
- data/.rakeTasks +7 -0
- data/.rspec +1 -0
- data/CHANGELOG.md +15 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +150 -0
- data/Rakefile +2 -0
- data/bin/fhcap +6 -0
- data/fhcap-cli.gemspec +44 -0
- data/lib/cookbooks/provision/libraries/provision.rb +140 -0
- data/lib/cookbooks/provision/metadata.rb +7 -0
- data/lib/cookbooks/provision/recipes/aws.rb +15 -0
- data/lib/cookbooks/provision/recipes/aws_cluster_create.rb +59 -0
- data/lib/cookbooks/provision/recipes/aws_cluster_create_elb.rb +61 -0
- data/lib/cookbooks/provision/recipes/aws_cluster_destroy.rb +52 -0
- data/lib/cookbooks/provision/recipes/cluster_create.rb +2 -0
- data/lib/cookbooks/provision/recipes/cluster_destroy.rb +2 -0
- data/lib/cookbooks/provision/recipes/cluster_destroy_instances.rb +11 -0
- data/lib/cookbooks/provision/recipes/cluster_provision.rb +4 -0
- data/lib/cookbooks/provision/recipes/cluster_provision_instances.rb +55 -0
- data/lib/cookbooks/provision/recipes/cluster_status.rb +24 -0
- data/lib/cookbooks/provision/recipes/common.rb +9 -0
- data/lib/cookbooks/provision/recipes/default.rb +5 -0
- data/lib/cookbooks/provision/recipes/openstack.rb +11 -0
- data/lib/cookbooks/provision/recipes/openstack_cluster_create.rb +11 -0
- data/lib/cookbooks/provision/recipes/openstack_cluster_destroy.rb +4 -0
- data/lib/cookbooks/provision/recipes/reset_rabbitmq.rb +49 -0
- data/lib/cookbooks/provision/recipes/restart_services.rb +24 -0
- data/lib/extensions/chef/provisioning.rb +21 -0
- data/lib/extensions/chef/provisioning/aws_driver/driver.rb +46 -0
- data/lib/extensions/chef/provisioning/chef_run_data.rb +18 -0
- data/lib/extensions/cheffish/merged_config.rb +9 -0
- data/lib/fhcap.rb +14 -0
- data/lib/fhcap/chef-dk/chef_runner.rb +94 -0
- data/lib/fhcap/cli.rb +75 -0
- data/lib/fhcap/cluster.rb +112 -0
- data/lib/fhcap/config.rb +104 -0
- data/lib/fhcap/cookbook.rb +75 -0
- data/lib/fhcap/dummy_node.rb +80 -0
- data/lib/fhcap/fhcap_helper.rb +9 -0
- data/lib/fhcap/kitchen.rb +235 -0
- data/lib/fhcap/knife.rb +74 -0
- data/lib/fhcap/knife_helper.rb +38 -0
- data/lib/fhcap/misc.rb +103 -0
- data/lib/fhcap/provider.rb +41 -0
- data/lib/fhcap/providers_helper.rb +60 -0
- data/lib/fhcap/repo.rb +52 -0
- data/lib/fhcap/repos_helper.rb +217 -0
- data/lib/fhcap/tasks/chef/chef_task_base.rb +82 -0
- data/lib/fhcap/tasks/chef/cookbook/list.rb +37 -0
- data/lib/fhcap/tasks/chef/cookbook/update_changelog.rb +63 -0
- data/lib/fhcap/tasks/chef/cookbook/update_metadata.rb +57 -0
- data/lib/fhcap/tasks/chef/cookbook/update_readme.rb +30 -0
- data/lib/fhcap/tasks/chef/cookbook/update_version.rb +90 -0
- data/lib/fhcap/tasks/chef/environments/create.rb +115 -0
- data/lib/fhcap/tasks/chef/environments/destroy.rb +37 -0
- data/lib/fhcap/tasks/chef/environments/promote_cookbooks.rb +47 -0
- data/lib/fhcap/tasks/chef/provisioning/chef_provisioning_task.rb +27 -0
- data/lib/fhcap/tasks/chef/provisioning/chef_provisioning_task_base.rb +38 -0
- data/lib/fhcap/tasks/chef/provisioning/create.rb +22 -0
- data/lib/fhcap/tasks/chef/provisioning/destroy.rb +21 -0
- data/lib/fhcap/tasks/chef/provisioning/provision.rb +19 -0
- data/lib/fhcap/tasks/chef/server/bootstrap.rb +165 -0
- data/lib/fhcap/tasks/chef/server/create_user.rb +97 -0
- data/lib/fhcap/tasks/chef/server/info.rb +82 -0
- data/lib/fhcap/tasks/chef/server/provision.rb +45 -0
- data/lib/fhcap/tasks/clean.rb +34 -0
- data/lib/fhcap/tasks/cluster/cluster_task_base.rb +57 -0
- data/lib/fhcap/tasks/cluster/create.rb +243 -0
- data/lib/fhcap/tasks/cluster/create_environment.rb +171 -0
- data/lib/fhcap/tasks/cluster/destroy.rb +30 -0
- data/lib/fhcap/tasks/cluster/destroy_environment.rb +28 -0
- data/lib/fhcap/tasks/cluster/info.rb +67 -0
- data/lib/fhcap/tasks/cluster/list.rb +40 -0
- data/lib/fhcap/tasks/cluster/provision.rb +46 -0
- data/lib/fhcap/tasks/cluster/status.rb +17 -0
- data/lib/fhcap/tasks/cluster/test.rb +15 -0
- data/lib/fhcap/tasks/knife/add.rb +111 -0
- data/lib/fhcap/tasks/knife/list.rb +22 -0
- data/lib/fhcap/tasks/knife/remove.rb +39 -0
- data/lib/fhcap/tasks/misc/create_dns_record.rb +100 -0
- data/lib/fhcap/tasks/misc/create_ssl_cert.rb +82 -0
- data/lib/fhcap/tasks/provider/add.rb +136 -0
- data/lib/fhcap/tasks/provider/list.rb +31 -0
- data/lib/fhcap/tasks/provider/remove.rb +28 -0
- data/lib/fhcap/tasks/repo/add.rb +57 -0
- data/lib/fhcap/tasks/repo/checkout.rb +144 -0
- data/lib/fhcap/tasks/repo/list.rb +22 -0
- data/lib/fhcap/tasks/repo/remove.rb +34 -0
- data/lib/fhcap/tasks/setup.rb +59 -0
- data/lib/fhcap/tasks/task_base.rb +89 -0
- data/lib/fhcap/thor_base.rb +121 -0
- data/lib/fhcap/version.rb +3 -0
- data/spec/fhcap/cli_spec.rb +6 -0
- data/spec/fhcap/tasks/cluster/create_spec.rb +46 -0
- data/spec/fhcap/tasks/knife/add_spec.rb +35 -0
- data/spec/fhcap/tasks/knife/remove_spec.rb +25 -0
- data/spec/fhcap/tasks/provider/add_spec.rb +61 -0
- data/spec/fhcap/tasks/provider/remove_spec.rb +25 -0
- data/spec/fhcap/tasks/repo/add_spec.rb +32 -0
- data/spec/fhcap/tasks/repo/remove_spec.rb +25 -0
- data/spec/fhcap/tasks/task_base_spec.rb +51 -0
- data/spec/fhcap/thor_base_spec.rb +9 -0
- data/spec/spec_helper.rb +23 -0
- data/spec/support/dummy_config.rb +7 -0
- data/spec/support/dummy_thor.rb +3 -0
- data/templates/chef/cookbook/changelog.md.erb +12 -0
- data/templates/chef/cookbook/metadata.erb +45 -0
- data/templates/chef/environment_core.json.erb +278 -0
- data/templates/chef/environment_empty.json.erb +10 -0
- data/templates/chef/environment_mbaas.json.erb +120 -0
- data/templates/chef/environment_single.json.erb +300 -0
- data/templates/cluster/aws/common.json.erb +43 -0
- data/templates/cluster/aws/core-3node.json.erb +106 -0
- data/templates/cluster/aws/core-small-9node.json.erb +333 -0
- data/templates/cluster/aws/mbaas-3node.json.erb +116 -0
- data/templates/cluster/aws/nginx-test.json.erb +93 -0
- data/templates/cluster/aws/single-blank.json.erb +41 -0
- data/templates/cluster/aws/single.json.erb +88 -0
- data/templates/cluster/core-3node.json.erb +8 -0
- data/templates/cluster/core-mbaas-6node.json.erb +13 -0
- data/templates/cluster/core-small-9node.json.erb +8 -0
- data/templates/cluster/mbaas-3node.json.erb +9 -0
- data/templates/cluster/nginx-test.json.erb +8 -0
- data/templates/cluster/openstack/common.json.erb +7 -0
- data/templates/cluster/openstack/core-3node.json.erb +14 -0
- data/templates/cluster/openstack/core-small-9node.json.erb +32 -0
- data/templates/cluster/openstack/mbaas-3node.json.erb +14 -0
- data/templates/cluster/openstack/nginx-test.json.erb +11 -0
- data/templates/cluster/openstack/single-blank.json.erb +10 -0
- data/templates/cluster/openstack/single.json.erb +10 -0
- data/templates/cluster/single-blank.json.erb +8 -0
- data/templates/cluster/single.json.erb +8 -0
- data/templates/init/knife.rb.erb +13 -0
- data/templates/kitchen/Cheffile.erb +11 -0
- data/templates/kitchen/kitchen.aws.yml.erb +35 -0
- data/templates/kitchen/kitchen.docker.yml.erb +24 -0
- data/templates/kitchen/kitchen.generate.yml.erb +2 -0
- data/templates/kitchen/kitchen.openstack.yml.erb +31 -0
- metadata +506 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 65e3070c4f135cab4d5b55260bb771dc576defbc
|
4
|
+
data.tar.gz: 81209d137087b8cdb2053a5b9ec51812666fed32
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 0590064eade7da691bb7142e5e982009b6fe2e0e425db345f4395e869eba1220e4b719a798ee7f42bcb921be14413e6dcd7cd03045e0ad843827a75adc573ac6
|
7
|
+
data.tar.gz: c881d8f06f8b4d8819bec8b9a4a3bb62ce819dd49631c2528e2ad746209e858371b38cc05e8c66d83038c2c7400bd221a1f7e7bbb4e131170bb7421c0ff9f43a
|
data/.gitignore
ADDED
data/.rakeTasks
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<Settings><!--This file was automatically generated by Ruby plugin.
|
3
|
+
You are allowed to:
|
4
|
+
1. Remove rake task
|
5
|
+
2. Add existing rake tasks
|
6
|
+
To add existing rake tasks automatically delete this file and reload the project.
|
7
|
+
--><RakeGroup description="" fullCmd="" taksId="rake"><RakeTask description="Build fhcap-cli-0.1.0.gem into the pkg directory" fullCmd="build" taksId="build" /><RakeTask description="Build and install fhcap-cli-0.1.0.gem into system gems" fullCmd="install" taksId="install" /><RakeTask description="Create tag v0.1.0 and build and push fhcap-cli-0.1.0.gem to Rubygems" fullCmd="release" taksId="release" /></RakeGroup></Settings>
|
data/.rspec
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
-w --color
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
|
2
|
+
## 0.3.0
|
3
|
+
|
4
|
+
* Implemented cluster create using chef provisioning, supports aws and openstack
|
5
|
+
* Various new helper tasks added
|
6
|
+
|
7
|
+
## 0.2.0
|
8
|
+
|
9
|
+
* Add cluster provision task
|
10
|
+
* Support checking out a git-ref to provision
|
11
|
+
* Add support for dealing with multiple chef servers
|
12
|
+
|
13
|
+
## 0.1.0
|
14
|
+
* Initial release
|
15
|
+
* Initial work on setup task
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2015 FeedHenry Ltd
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,150 @@
|
|
1
|
+
# Fhcap::Cli
|
2
|
+
|
3
|
+
FHCAP Command Line Tool
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'fhcap-cli'
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install fhcap-cli
|
20
|
+
|
21
|
+
### Setup
|
22
|
+
|
23
|
+
```
|
24
|
+
$ fhcap setup
|
25
|
+
```
|
26
|
+
|
27
|
+
This creates a new fhcap config, clones required repos and sets up knife based on information in the config. By default it will create a structure similar to the following in your home directory:
|
28
|
+
|
29
|
+
```
|
30
|
+
/home/<user>/
|
31
|
+
|-- fhcap
|
32
|
+
| |-- .chef
|
33
|
+
| | |-- bob
|
34
|
+
| | |-- knife-bob.rb
|
35
|
+
| | `-- knife.rb -> /home/hadmin/fhcap/.chef/knife-bob.rb
|
36
|
+
| |-- repos
|
37
|
+
| | |-- fhcap
|
38
|
+
| | |-- fhcap-dev
|
39
|
+
|-- .fhcap
|
40
|
+
| `-- fhcap.json
|
41
|
+
```
|
42
|
+
|
43
|
+
If you want to specify a different repos directory, you can do this by passing it in as an option:
|
44
|
+
|
45
|
+
```
|
46
|
+
fhcap setup --repos-dir /Users/mnairn/src
|
47
|
+
```
|
48
|
+
|
49
|
+
or, run setup in interactive mode and change it when prompted:
|
50
|
+
|
51
|
+
```
|
52
|
+
fhcap setup -i
|
53
|
+
Local directory where repos will be checked out (/Users/mnairn/src) /Users/mnairn/some_other_repo_dir
|
54
|
+
```
|
55
|
+
|
56
|
+
#### knife setup (chef server)
|
57
|
+
|
58
|
+
After the initial setup, you will need to copy your own chef server credentials into the correct knife directories in order to gain proper access to a chef server.
|
59
|
+
|
60
|
+
During setup you will see output like this:
|
61
|
+
|
62
|
+
```
|
63
|
+
missing /home/hadmin/fhcap/.chef/bob/chef-validator.pem
|
64
|
+
missing /home/hadmin/fhcap/.chef/bob/hadmin.pem
|
65
|
+
```
|
66
|
+
|
67
|
+
This indicates that the required pem files for that particular knife configuration are missing. You need to retrieve these files form your chef server and copy them to the locations specified.
|
68
|
+
|
69
|
+
#### Add data repos (fhcap_prod etc..)
|
70
|
+
|
71
|
+
```
|
72
|
+
fhcap repo help add
|
73
|
+
```
|
74
|
+
|
75
|
+
Examples:
|
76
|
+
|
77
|
+
```
|
78
|
+
fhcap repo add --name fhcap_prod --url git@github.com:feedhenry-ops/fhcap_prod.git --clusters-dir organisations
|
79
|
+
```
|
80
|
+
|
81
|
+
#### Add chef servers (trigger etc..)
|
82
|
+
|
83
|
+
```
|
84
|
+
fhcap knife help add
|
85
|
+
```
|
86
|
+
|
87
|
+
Examples:
|
88
|
+
|
89
|
+
```
|
90
|
+
fhcap knife add --name trigger --url https://trigger.feedhenry.net
|
91
|
+
```
|
92
|
+
|
93
|
+
Add any required pem files listed as 'missing'
|
94
|
+
|
95
|
+
#### Add providers (aws,openstack etc..)
|
96
|
+
|
97
|
+
```
|
98
|
+
fhcap provider help add
|
99
|
+
```
|
100
|
+
|
101
|
+
Examples:
|
102
|
+
|
103
|
+
```
|
104
|
+
fhcap provider add --name os1internal --type openstack --credentials os-auth-url:'http://control.os1.phx2.redhat.com:5000/v2.0' os-tenant-id:aa6c957ba2aa4368a8c385d07b7ab9da os-tenant-name:'Red Hat Mobile'
|
105
|
+
```
|
106
|
+
|
107
|
+
```
|
108
|
+
fhcap provider add --name fheng --type aws
|
109
|
+
```
|
110
|
+
|
111
|
+
A prompt will be displayed for any credentaisl that are required but not passed to the command directly
|
112
|
+
|
113
|
+
## Usage
|
114
|
+
|
115
|
+
There is help included with the fhcap help subcommand which will list all subcommands and their usage:
|
116
|
+
|
117
|
+
```
|
118
|
+
fhcap help cluster
|
119
|
+
```
|
120
|
+
|
121
|
+
## Development
|
122
|
+
|
123
|
+
Install dependencies:
|
124
|
+
```
|
125
|
+
bundle install
|
126
|
+
```
|
127
|
+
|
128
|
+
Run commands in dev:
|
129
|
+
|
130
|
+
```
|
131
|
+
bundle exec fhcap setup
|
132
|
+
```
|
133
|
+
|
134
|
+
Run tests:
|
135
|
+
|
136
|
+
```
|
137
|
+
rspec
|
138
|
+
```
|
139
|
+
|
140
|
+
To install this gem onto your local machine, run `bundle exec rake install`.
|
141
|
+
|
142
|
+
To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release` to create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
143
|
+
|
144
|
+
## Contributing
|
145
|
+
|
146
|
+
1. Fork it ( https://github.com/[my-github-username]/fhcap-cli/fork )
|
147
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
148
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
149
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
150
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
data/bin/fhcap
ADDED
data/fhcap-cli.gemspec
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'fhcap/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "fhcap-cli"
|
8
|
+
spec.version = Fhcap::VERSION
|
9
|
+
spec.authors = ["Michael Nairn"]
|
10
|
+
spec.email = ["mnairn@redhat.com"]
|
11
|
+
spec.summary = 'FHCAP Command Line Tool'
|
12
|
+
spec.description = 'FHCAP Command Line Tool'
|
13
|
+
spec.homepage = "https://github.com/fheng/fhcap-cli"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_dependency "thor", "~> 0.19.1"
|
22
|
+
spec.add_dependency 'sshkey', '~> 1.6.1'
|
23
|
+
spec.add_dependency 'public_suffix', '~> 1.5.1'
|
24
|
+
spec.add_dependency 'launchy', '~> 2.4.2'
|
25
|
+
spec.add_dependency 'librarian-chef', '~> 0.0.3'
|
26
|
+
spec.add_dependency 'knife-block', '~> 0.2.1'
|
27
|
+
spec.add_dependency 'knife-cookbook-readme', '~> 0.2.1'
|
28
|
+
spec.add_dependency 'ruby-progressbar', '~> 1.7.5'
|
29
|
+
spec.add_dependency 'aws-sdk', '~> 2.1.23'
|
30
|
+
spec.add_dependency 'chef', '~> 12.4.3'
|
31
|
+
spec.add_dependency 'chef-provisioning', '~> 1.4.0'
|
32
|
+
spec.add_dependency 'chef-provisioning-aws', '~> 1.4.1'
|
33
|
+
spec.add_dependency 'chef-provisioning-vagrant', '~> 0.10.0'
|
34
|
+
spec.add_dependency 'chef-provisioning-fog', '~> 0.15.0'
|
35
|
+
spec.add_dependency 'test-kitchen', '~> 1.4.2'
|
36
|
+
spec.add_dependency 'kitchen-sync', '~> 1.1.1'
|
37
|
+
spec.add_dependency 'kitchen-vagrant', '~> 0.14.0'
|
38
|
+
spec.add_dependency 'kitchen-ec2', '~> 0.8.0'
|
39
|
+
spec.add_dependency 'kitchen-docker', '~> 2.1.0'
|
40
|
+
spec.add_dependency 'kitchen-openstack','~> 1.8.0'
|
41
|
+
|
42
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
43
|
+
spec.add_development_dependency "rspec", "~> 3.2"
|
44
|
+
end
|
@@ -0,0 +1,140 @@
|
|
1
|
+
def node_names_for(cluster_config)
|
2
|
+
org_name = cluster_config[:id]
|
3
|
+
#If we are using chef-client in local mode (-z) we can't search :-(
|
4
|
+
#node_names = search(:node, "chef_environment:*").map { |n| n.name }
|
5
|
+
cluster_config[:environments].collect do |env_name, env_cfg|
|
6
|
+
env_cfg[:instances].collect do |name, cfg|
|
7
|
+
instance_name_for(org_name, env_name, name)
|
8
|
+
end if env_cfg[:instances]
|
9
|
+
end.flatten
|
10
|
+
end
|
11
|
+
|
12
|
+
def inbound_rules_for(org_name, ingress)
|
13
|
+
ingress.collect do |ai|
|
14
|
+
sources = ai[:sources] || []
|
15
|
+
sources += ai[:groups].collect { |group| security_group_name_for(org_name, group) } if ai[:groups]
|
16
|
+
|
17
|
+
protocols = ai[:protocols].collect { |p| p }
|
18
|
+
if protocols.delete 'all'
|
19
|
+
protocols += ['tcp', 'udp']
|
20
|
+
end
|
21
|
+
protocols.uniq!
|
22
|
+
protocols.collect do |protocol|
|
23
|
+
{port: ai[:start]..ai[:end], protocol: protocol, sources: sources}
|
24
|
+
end
|
25
|
+
end.flatten
|
26
|
+
end
|
27
|
+
|
28
|
+
def machine_options_for(provider, org_name, environment, instance_options)
|
29
|
+
send(:"#{provider}_machine_options", org_name, environment, instance_options)
|
30
|
+
end
|
31
|
+
|
32
|
+
def bootstrap_options_for(provider, org_name, environment, instance_options)
|
33
|
+
send(:"#{provider}_bootstrap_options", org_name, environment, instance_options)
|
34
|
+
end
|
35
|
+
|
36
|
+
def converge_options_for(provider, org_name, environment, instance_options)
|
37
|
+
send(:"#{provider}_converge_options", org_name, environment, instance_options)
|
38
|
+
end
|
39
|
+
|
40
|
+
#AWS
|
41
|
+
|
42
|
+
def aws_machine_options(org_name, environment, instance_options)
|
43
|
+
{
|
44
|
+
:bootstrap_options => bootstrap_options_for('aws', org_name, environment, instance_options),
|
45
|
+
:convergence_options => converge_options_for('aws', org_name, environment, instance_options),
|
46
|
+
}
|
47
|
+
end
|
48
|
+
|
49
|
+
def aws_bootstrap_options(org_name, environment, instance_options)
|
50
|
+
bootstrap_options = {
|
51
|
+
image_id: instance_options[:image_id],
|
52
|
+
instance_type: instance_options[:instance_type],
|
53
|
+
key_name: key_pair_name_for(org_name)
|
54
|
+
#key_path: "~/.chef/keys/chef_default"
|
55
|
+
}
|
56
|
+
bootstrap_options[:subnet] = subnet_name_for(org_name, environment, instance_options[:subnet])
|
57
|
+
bootstrap_options[:security_group_ids] = instance_options[:security_groups].collect do |security_group|
|
58
|
+
security_group_name_for(org_name, security_group)
|
59
|
+
end
|
60
|
+
bootstrap_options[:block_device_mappings] = instance_options[:block_device_mappings]
|
61
|
+
bootstrap_options
|
62
|
+
end
|
63
|
+
|
64
|
+
def aws_converge_options(org_name, environment, instance_options)
|
65
|
+
{:chef_version => '11.10.4'}
|
66
|
+
end
|
67
|
+
|
68
|
+
#OpenStack
|
69
|
+
|
70
|
+
def openstack_machine_options(org_name, environment, instance_options)
|
71
|
+
{
|
72
|
+
:bootstrap_options => bootstrap_options_for('openstack', org_name, environment, instance_options),
|
73
|
+
:convergence_options => converge_options_for('openstack', org_name, environment, instance_options),
|
74
|
+
:floating_ip_pool => instance_options[:floating_ip_pool],
|
75
|
+
:ssh_username => "ubuntu"
|
76
|
+
}
|
77
|
+
end
|
78
|
+
|
79
|
+
def openstack_bootstrap_options(org_name, environment, instance_options)
|
80
|
+
{
|
81
|
+
flavor_ref: instance_options[:flavor_ref],
|
82
|
+
image_ref: instance_options[:image_ref],
|
83
|
+
key_name: key_pair_name_for(org_name),
|
84
|
+
user_id: "ubuntu"
|
85
|
+
}
|
86
|
+
end
|
87
|
+
|
88
|
+
def openstack_converge_options(org_name, environment, instance_options)
|
89
|
+
{:chef_version => '11.10.4', :ohai_hints => { :openstack => {} }}
|
90
|
+
end
|
91
|
+
|
92
|
+
def key_pair_name_for(name)
|
93
|
+
fh_name_for('fh-kp', name)
|
94
|
+
end
|
95
|
+
|
96
|
+
def internet_gateway_name_for(name)
|
97
|
+
fh_name_for('fh-igw', name)
|
98
|
+
end
|
99
|
+
|
100
|
+
def vpc_name_for(name)
|
101
|
+
fh_name_for('fh-vpc', name)
|
102
|
+
end
|
103
|
+
|
104
|
+
def security_group_name_for(name, environment)
|
105
|
+
fh_name_for('fh-sg', name, environment)
|
106
|
+
end
|
107
|
+
|
108
|
+
def route_table_name_for(org_name, environment)
|
109
|
+
fh_name_for('fh-rt', org_name, environment)
|
110
|
+
end
|
111
|
+
|
112
|
+
def subnet_name_for(name, environment, suffix)
|
113
|
+
fh_name_for('fh-net', name, environment, suffix)
|
114
|
+
end
|
115
|
+
|
116
|
+
def instance_name_for(org_name, environment, name)
|
117
|
+
fh_name_for(org_name, environment, name)
|
118
|
+
end
|
119
|
+
|
120
|
+
def volume_name_for(*args)
|
121
|
+
fh_name_for('fh-vol', *args)
|
122
|
+
end
|
123
|
+
|
124
|
+
def load_balancer_name_for(org_name, environment, lb_name)
|
125
|
+
fh_name_for('fh-lb', org_name, environment, lb_name)
|
126
|
+
end
|
127
|
+
|
128
|
+
def cert_name_for(org_name, environment, cert_name)
|
129
|
+
fh_name_for('fh-crt', org_name, environment, cert_name)
|
130
|
+
end
|
131
|
+
|
132
|
+
def fh_name_for(*args)
|
133
|
+
args.collect do |str|
|
134
|
+
str.to_s.split('-')
|
135
|
+
end.flatten.uniq.join('-')
|
136
|
+
end
|
137
|
+
|
138
|
+
def cluster_config_for(node)
|
139
|
+
JSON.parse(node.normal.to_json, {:symbolize_names => true})
|
140
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
raise "Missing aws credentials" unless node['provider_credentials']['aws-access-key'] && node['provider_credentials']['aws-secret-key']
|
2
|
+
|
3
|
+
require 'chef/provisioning/aws_driver'
|
4
|
+
require 'extensions/chef/provisioning/aws_driver/driver.rb'
|
5
|
+
|
6
|
+
cluster_config = cluster_config_for(node)
|
7
|
+
region = cluster_config[:vpc][:region]
|
8
|
+
with_driver("aws:default:#{region}", {
|
9
|
+
:aws_credentials => {
|
10
|
+
"default" => {
|
11
|
+
:aws_access_key_id => node['provider_credentials']['aws-access-key'],
|
12
|
+
:aws_secret_access_key => node['provider_credentials']['aws-secret-key']
|
13
|
+
}
|
14
|
+
}
|
15
|
+
})
|