stack-kicker 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/.rvmrc +48 -0
- data/Gemfile +1 -1
- data/LICENSE.txt +202 -22
- data/README.md +127 -10
- data/README.rdoc +5 -1
- data/bin/stack-kicker +84 -0
- data/doc/examples/Stackfile +41 -0
- data/features/stack-kicker.feature +27 -0
- data/features/step_definitions/{kicker_steps.rb → stack-kicker_steps.rb} +0 -0
- data/lib/stack-kicker/version.rb +5 -0
- data/lib/stack-kicker.rb +7 -0
- data/lib/stack.rb +733 -158
- data/stack-kicker.gemspec +26 -0
- metadata +37 -27
- data/bin/kicker +0 -77
- data/features/kicker.feature +0 -13
- data/kicker.gemspec +0 -32
- data/lib/kicker/version.rb +0 -3
- data/lib/kicker.rb +0 -5
data/.rvmrc
ADDED
@@ -0,0 +1,48 @@
|
|
1
|
+
#!/usr/bin/env bash
|
2
|
+
|
3
|
+
# This is an RVM Project .rvmrc file, used to automatically load the ruby
|
4
|
+
# development environment upon cd'ing into the directory
|
5
|
+
|
6
|
+
# First we specify our desired <ruby>[@<gemset>], the @gemset name is optional,
|
7
|
+
# Only full ruby name is supported here, for short names use:
|
8
|
+
# echo "rvm use 1.9.3" > .rvmrc
|
9
|
+
environment_id="ruby-1.9.3-p286@stack-kicker"
|
10
|
+
|
11
|
+
# Uncomment the following lines if you want to verify rvm version per project
|
12
|
+
# rvmrc_rvm_version="1.16.17 (stable)" # 1.10.1 seams as a safe start
|
13
|
+
# eval "$(echo ${rvm_version}.${rvmrc_rvm_version} | awk -F. '{print "[[ "$1*65536+$2*256+$3" -ge "$4*65536+$5*256+$6" ]]"}' )" || {
|
14
|
+
# echo "This .rvmrc file requires at least RVM ${rvmrc_rvm_version}, aborting loading."
|
15
|
+
# return 1
|
16
|
+
# }
|
17
|
+
|
18
|
+
# First we attempt to load the desired environment directly from the environment
|
19
|
+
# file. This is very fast and efficient compared to running through the entire
|
20
|
+
# CLI and selector. If you want feedback on which environment was used then
|
21
|
+
# insert the word 'use' after --create as this triggers verbose mode.
|
22
|
+
if [[ -d "${rvm_path:-$HOME/.rvm}/environments"
|
23
|
+
&& -s "${rvm_path:-$HOME/.rvm}/environments/$environment_id" ]]
|
24
|
+
then
|
25
|
+
\. "${rvm_path:-$HOME/.rvm}/environments/$environment_id"
|
26
|
+
[[ -s "${rvm_path:-$HOME/.rvm}/hooks/after_use" ]] &&
|
27
|
+
\. "${rvm_path:-$HOME/.rvm}/hooks/after_use" || true
|
28
|
+
else
|
29
|
+
# If the environment file has not yet been created, use the RVM CLI to select.
|
30
|
+
rvm --create "$environment_id" || {
|
31
|
+
echo "Failed to create RVM environment '${environment_id}'."
|
32
|
+
return 1
|
33
|
+
}
|
34
|
+
fi
|
35
|
+
|
36
|
+
# If you use bundler, this might be useful to you:
|
37
|
+
# if [[ -s Gemfile ]] && {
|
38
|
+
# ! builtin command -v bundle >/dev/null ||
|
39
|
+
# builtin command -v bundle | GREP_OPTIONS= \grep $rvm_path/bin/bundle >/dev/null
|
40
|
+
# }
|
41
|
+
# then
|
42
|
+
# printf "%b" "The rubygem 'bundler' is not installed. Installing it now.\n"
|
43
|
+
# gem install bundler
|
44
|
+
# fi
|
45
|
+
# if [[ -s Gemfile ]] && builtin command -v bundle >/dev/null
|
46
|
+
# then
|
47
|
+
# bundle install | GREP_OPTIONS= \grep -vE '^Using|Your bundle is complete'
|
48
|
+
# fi
|
data/Gemfile
CHANGED
data/LICENSE.txt
CHANGED
@@ -1,22 +1,202 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
1
|
+
|
2
|
+
Apache License
|
3
|
+
Version 2.0, January 2004
|
4
|
+
http://www.apache.org/licenses/
|
5
|
+
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
7
|
+
|
8
|
+
1. Definitions.
|
9
|
+
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
12
|
+
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
14
|
+
the copyright owner that is granting the License.
|
15
|
+
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
17
|
+
other entities that control, are controlled by, or are under common
|
18
|
+
control with that entity. For the purposes of this definition,
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
20
|
+
direction or management of such entity, whether by contract or
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
23
|
+
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
25
|
+
exercising permissions granted by this License.
|
26
|
+
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
28
|
+
including but not limited to software source code, documentation
|
29
|
+
source, and configuration files.
|
30
|
+
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
32
|
+
transformation or translation of a Source form, including but
|
33
|
+
not limited to compiled object code, generated documentation,
|
34
|
+
and conversions to other media types.
|
35
|
+
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
37
|
+
Object form, made available under the License, as indicated by a
|
38
|
+
copyright notice that is included in or attached to the work
|
39
|
+
(an example is provided in the Appendix below).
|
40
|
+
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
47
|
+
the Work and Derivative Works thereof.
|
48
|
+
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
50
|
+
the original version of the Work and any modifications or additions
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
62
|
+
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
65
|
+
subsequently incorporated within the Work.
|
66
|
+
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
73
|
+
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
79
|
+
where such license applies only to those patent claims licensable
|
80
|
+
by such Contributor that are necessarily infringed by their
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
83
|
+
institute patent litigation against any entity (including a
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
86
|
+
or contributory patent infringement, then any patent licenses
|
87
|
+
granted to You under this License for that Work shall terminate
|
88
|
+
as of the date such litigation is filed.
|
89
|
+
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
92
|
+
modifications, and in Source or Object form, provided that You
|
93
|
+
meet the following conditions:
|
94
|
+
|
95
|
+
(a) You must give any other recipients of the Work or
|
96
|
+
Derivative Works a copy of this License; and
|
97
|
+
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
99
|
+
stating that You changed the files; and
|
100
|
+
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
103
|
+
attribution notices from the Source form of the Work,
|
104
|
+
excluding those notices that do not pertain to any part of
|
105
|
+
the Derivative Works; and
|
106
|
+
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
109
|
+
include a readable copy of the attribution notices contained
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
112
|
+
of the following places: within a NOTICE text file distributed
|
113
|
+
as part of the Derivative Works; within the Source form or
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
115
|
+
within a display generated by the Derivative Works, if and
|
116
|
+
wherever such third-party notices normally appear. The contents
|
117
|
+
of the NOTICE file are for informational purposes only and
|
118
|
+
do not modify the License. You may add Your own attribution
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
121
|
+
that such additional attribution notices cannot be construed
|
122
|
+
as modifying the License.
|
123
|
+
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
125
|
+
may provide additional or different license terms and conditions
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
129
|
+
the conditions stated in this License.
|
130
|
+
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
134
|
+
this License, without any additional terms or conditions.
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
136
|
+
the terms of any separate license agreement you may have executed
|
137
|
+
with Licensor regarding such Contributions.
|
138
|
+
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
141
|
+
except as required for reasonable and customary use in describing the
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
143
|
+
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
153
|
+
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
159
|
+
incidental, or consequential damages of any character arising as a
|
160
|
+
result of this License or out of the use or inability to use the
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
163
|
+
other commercial damages or losses), even if such Contributor
|
164
|
+
has been advised of the possibility of such damages.
|
165
|
+
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
169
|
+
or other liability obligations and/or rights consistent with this
|
170
|
+
License. However, in accepting such obligations, You may act only
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
175
|
+
of your accepting any such warranty or additional liability.
|
176
|
+
|
177
|
+
END OF TERMS AND CONDITIONS
|
178
|
+
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
180
|
+
|
181
|
+
To apply the Apache License to your work, attach the following
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
183
|
+
replaced with your own identifying information. (Don't include
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
185
|
+
comment syntax for the file format. We also recommend that a
|
186
|
+
file or class name and description of purpose be included on the
|
187
|
+
same "printed page" as the copyright notice for easier
|
188
|
+
identification within third-party archives.
|
189
|
+
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
191
|
+
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
193
|
+
you may not use this file except in compliance with the License.
|
194
|
+
You may obtain a copy of the License at
|
195
|
+
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
197
|
+
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
201
|
+
See the License for the specific language governing permissions and
|
202
|
+
limitations under the License.
|
data/README.md
CHANGED
@@ -1,25 +1,142 @@
|
|
1
|
-
#
|
1
|
+
# stack-kicker
|
2
2
|
|
3
|
-
|
3
|
+
stack-kicker is a simple 'application stack' deployment tool, it's purpose in life
|
4
|
+
is to spin up a set of instances in a repeatable, controlled fashion, and optionally
|
5
|
+
run post-install scripts after each instance has been started.
|
4
6
|
|
5
|
-
|
7
|
+
stack-kicker has hooks to allow default & custom cloud-init templates to be built & passed to
|
8
|
+
your compute provider (we currently use ruby-openstack, so are limited to OpenStack providers,
|
9
|
+
however, a sister project, aws-kicker, uses fog.io, the interaction with the compute provider is
|
10
|
+
minimal, so it's on the roadmap to merge aws-kicker & stack-kicker, and use either an internal
|
11
|
+
abstraction layer or just fog.io for all compute provisioning requests)
|
12
|
+
|
13
|
+
## Stackfile
|
14
|
+
Normally, stack configurations are stored in a Stackfile, which is a ruby hash of configuration options.
|
15
|
+
Typically, the Stackfile contains the following sets of information
|
16
|
+
|
17
|
+
1. Credentials for your compute provider
|
18
|
+
2. Defaults for your Stack (compute flavor, image id, region/az, ssh-keys, instance name template)
|
19
|
+
1. roles
|
20
|
+
|
21
|
+
## Concepts
|
22
|
+
stack-kicker sequentially iterates over defined roles, creating the required number of nodes (nodes are the compute instances). If an instance already exists with the proposed name, it's skipped, assuming that this node has already been built.
|
23
|
+
|
24
|
+
Hostnames are generated from a customizable template, which is effectively:
|
25
|
+
|
26
|
+
config[:name_template] = '%s-%s-%s%04d'
|
27
|
+
config['global_service_name'] = 'myapp'
|
28
|
+
site = <derived from region/az, via config[:site_template]>
|
29
|
+
hostname = sprintf(config[:name_template], config['global_service_name'], site, role, position)
|
30
|
+
|
31
|
+
So hostnames will be myapp-az1-chef0001, myapp-az1-web0001, myapp-az1-web0002 etc.
|
6
32
|
|
7
|
-
|
33
|
+
post-install scripts are executed from the same host as stack-kicker is being used, using the same credentials as the current user. They are can be used to retrieve information from a freshly built node (like certificates from a chef server), so block progress until the chef-client run has completed (we use this to block percona/galera & rabbitmq cluster builds so that the first node is up & running correctly before we try and add another node to the cluster)
|
8
34
|
|
9
|
-
|
35
|
+
## Example workflows/models
|
36
|
+
stack-kicker was built with the following workflows in mind:
|
10
37
|
|
11
|
-
|
38
|
+
### private chef-server
|
39
|
+
This was the original requirement, a multi-role application stack build that started
|
40
|
+
with building a chef-server, uploading roles, environments, cookbooks & databags to it,
|
41
|
+
and then building the rest of the application-stack instances, using the freshly built chef-server
|
42
|
+
to drop the application on to the instances. In this setup we used vanilla images (Ubuntu 12.04 LTS,
|
43
|
+
but you could use any image, either vanilla or pre-populated with your software).
|
12
44
|
|
13
|
-
|
45
|
+
Here's an example Stackfile for this:
|
46
|
+
|
47
|
+
module StackConfig
|
48
|
+
Stacks = {
|
49
|
+
'web-w-chef-server' => {
|
50
|
+
# (we can access environment variable via ENV['foo'] instead of hard coding u/p here)
|
51
|
+
'REGION' => ENV['OS_REGION_NAME'],
|
52
|
+
'USERNAME' => ENV['OS_USERNAME'],
|
53
|
+
'PASSWORD' => ENV['OS_PASSWORD'],
|
54
|
+
'AUTH_URL' => ENV['OS_AUTH_URL'],
|
55
|
+
'TENANT_NAME' => ENV['OS_TENANT_NAME'],
|
56
|
+
|
57
|
+
# generic instance info
|
58
|
+
'flavor_id' => 103,
|
59
|
+
'image_id' => 75845,
|
60
|
+
:key_pair => 'ssh-keypair-name',
|
61
|
+
:key_public => '/path/to/id_rsa.pub',
|
62
|
+
:global_service_name => 'perconaconf',
|
63
|
+
|
64
|
+
# role details
|
65
|
+
:roles => {
|
66
|
+
# override the default cloud-init script & default bootstrap (which is a chef-client bootstrap)
|
67
|
+
:chef => {
|
68
|
+
# we are the chef server, so skip the chef-client steps
|
69
|
+
:chef_server => true, :skip_chef_prereg => true,
|
70
|
+
# override the default cloud-config with a chef-server template
|
71
|
+
:cloud_config_yaml => 'chef-cloud-config.yaml',
|
72
|
+
# skip the default chef-client bootstrap
|
73
|
+
:bootstrap => '',
|
74
|
+
# wait for the chef server to come up & download pem files & generate client account
|
75
|
+
:post_install_script => 'bootstrap/chef-post-install.sh',
|
76
|
+
# our post install script dumps out .pem files in the CWD
|
77
|
+
:post_install_cwd => '.chef',
|
78
|
+
# The post-install script needs to know the public IP of the just built instance so that this station can access it
|
79
|
+
:post_install_args => '%PUBLIC_IP%'
|
80
|
+
},
|
81
|
+
# much simpler role, just build 3 of these, chef-client will do the rest on boot
|
82
|
+
:web => { :count => 3 }
|
83
|
+
}
|
84
|
+
}
|
85
|
+
}
|
86
|
+
end
|
87
|
+
|
14
88
|
|
15
|
-
|
89
|
+
### simple roles
|
90
|
+
There is no requirement that stack-kicker do anything other than spin up your instances, your requirements
|
91
|
+
may be such that you just need a number of instances started with certain images, region & flavor requirements.
|
16
92
|
|
17
|
-
|
93
|
+
### masterless puppet
|
94
|
+
aws-kicker (a sister project) had an original requirement of starting a simple 2-tier web application in multiple
|
95
|
+
locations/environments (prod, stage, dev etc), to do this we configured the instances by bootrapping puppet,
|
96
|
+
git clonig /etc/puppet and running "puppet apply", a simple pattern used in many places, this was all achievd with a
|
97
|
+
carefully crafted cloud-init template (incidentally, this also allowed for simple prototyping using vagrant to
|
98
|
+
provide local instances using the exact same '/etc/puppet' git repo.
|
99
|
+
|
100
|
+
### Other workflows
|
101
|
+
These are only the workflows I've used, there is no reason a puppet master couldn't be built & used, or
|
102
|
+
hosted/external puppet & chef servers. (pull requests accepted etc, including salt, ansible, cfengine etc..)
|
103
|
+
|
104
|
+
## Installation
|
105
|
+
|
106
|
+
$ gem install stack-kicker
|
107
|
+
|
108
|
+
## Requirements
|
109
|
+
In addition to the the ruby dependencies which gem will install for you, access to python-novaclient is currently required to attach floating-ips to instances.
|
18
110
|
|
19
111
|
## Usage
|
20
112
|
|
21
|
-
|
113
|
+
Usage: stack-kicker [options] task
|
114
|
+
|
115
|
+
Options:
|
116
|
+
-h, --help Show command line help
|
117
|
+
--stackfile Stackfile Specify an alternative Stackfile
|
118
|
+
(default: Stackfile)
|
119
|
+
--stack mystack Specify the stack in Stackfile that you want to work with
|
120
|
+
--ssh-user USER User to be used for SSH access
|
121
|
+
--version Show help/version info
|
122
|
+
--log-level LEVEL Set the logging level
|
123
|
+
(debug|info|warn|error|fatal)
|
124
|
+
(Default: info)
|
125
|
+
|
126
|
+
Arguments:
|
127
|
+
|
128
|
+
task
|
129
|
+
task to be performed validate|configure-knife|show-stacks|show-stack|show-running|build|replace|delete|secgroup-sync|ssh
|
130
|
+
|
131
|
+
## TODO
|
22
132
|
|
133
|
+
1. Clean up provider logic
|
134
|
+
2. Remove dependency on python-novaclient for floating-ip attach
|
135
|
+
3. Remove dependency on a full chef gem install
|
136
|
+
4. Better docs & examples
|
137
|
+
5. Support for AWS EC2 (from aws-kicker)
|
138
|
+
5. Support for DNS Updates on instance creation (from aws-kicker)
|
139
|
+
6.
|
23
140
|
## Contributing
|
24
141
|
|
25
142
|
1. Fork it
|
data/README.rdoc
CHANGED
data/bin/stack-kicker
ADDED
@@ -0,0 +1,84 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# Copyright 2012 Hewlett-Packard Development Company, L.P.
|
3
|
+
# All Rights Reserved.
|
4
|
+
#
|
5
|
+
# Author: Simon McCartney <simon.mccartney@hp.com>
|
6
|
+
#
|
7
|
+
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
8
|
+
# not use this file except in compliance with the License. You may obtain
|
9
|
+
# a copy of the License at
|
10
|
+
#
|
11
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
12
|
+
#
|
13
|
+
# Unless required by applicable law or agreed to in writing, software
|
14
|
+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
15
|
+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
16
|
+
# License for the specific language governing permissions and limitations
|
17
|
+
# under the License.
|
18
|
+
#
|
19
|
+
|
20
|
+
require 'bundler'
|
21
|
+
require 'optparse'
|
22
|
+
require 'methadone'
|
23
|
+
require 'stack-kicker'
|
24
|
+
require 'stack'
|
25
|
+
|
26
|
+
class App
|
27
|
+
include Methadone::Main
|
28
|
+
include Methadone::CLILogging
|
29
|
+
|
30
|
+
main do |task|
|
31
|
+
debug { "#{options}" }
|
32
|
+
# pass the logger.level into the Stack module
|
33
|
+
Stack.log_level(logger.level)
|
34
|
+
|
35
|
+
if (task != 'show-stacks')
|
36
|
+
config = Stack.select_stack(options[:stackfile], options['stack'])
|
37
|
+
end
|
38
|
+
|
39
|
+
case task
|
40
|
+
when 'validate'
|
41
|
+
Stack.validate(config)
|
42
|
+
when 'configure-knife'
|
43
|
+
Stack.generate_knife_rb(config)
|
44
|
+
when 'show-stacks'
|
45
|
+
Stack.show_stacks(options[:stackfile])
|
46
|
+
when 'show-stack'
|
47
|
+
Stack.show_stack(config)
|
48
|
+
when 'show-running'
|
49
|
+
Stack.show_running(config)
|
50
|
+
when 'build'
|
51
|
+
Stack.deploy_all(config)
|
52
|
+
when 'delete'
|
53
|
+
Stack.delete_all(config)
|
54
|
+
else
|
55
|
+
error "Sorry, #{task} hasn't been implemented yet"
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
# supplemental methods here
|
60
|
+
|
61
|
+
# Declare command-line interface here
|
62
|
+
|
63
|
+
description "create application stacks in the cloud from fundamental building blocks"
|
64
|
+
#
|
65
|
+
# Accept flags via:
|
66
|
+
# on("--flag VAL","Some flag")
|
67
|
+
# options[flag] will contain VAL
|
68
|
+
#
|
69
|
+
# Specify switches via:
|
70
|
+
# on("--[no-]switch","Some switch")
|
71
|
+
#
|
72
|
+
|
73
|
+
options[:stackfile] = 'Stackfile'
|
74
|
+
on("--stackfile Stackfile", "Specify an alternative Stackfile")
|
75
|
+
on("--stack mystack", "Specify the stack in Stackfile that you want to work with")
|
76
|
+
on("--ssh-user USER", "User to be used for SSH access")
|
77
|
+
|
78
|
+
arg :task, "task to be performed validate|configure-knife|show-stacks|show-stack|show-running|build|replace|delete|secgroup-sync|ssh"
|
79
|
+
version Stack::Kicker::VERSION
|
80
|
+
|
81
|
+
use_log_level_option
|
82
|
+
|
83
|
+
go!
|
84
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
module StackConfig
|
2
|
+
Stacks = {
|
3
|
+
'web-w-chef-server' => {
|
4
|
+
# (we can access environment variable via ENV['foo'] instead of hard coding u/p here)
|
5
|
+
'REGION' => ENV['OS_REGION_NAME'],
|
6
|
+
'USERNAME' => ENV['OS_USERNAME'],
|
7
|
+
'PASSWORD' => ENV['OS_PASSWORD'],
|
8
|
+
'AUTH_URL' => ENV['OS_AUTH_URL'],
|
9
|
+
'TENANT_NAME' => ENV['OS_TENANT_NAME'],
|
10
|
+
|
11
|
+
# generic instance info
|
12
|
+
'flavor_id' => 103,
|
13
|
+
'image_id' => 75845,
|
14
|
+
:key_pair => 'ssh-keypair-name',
|
15
|
+
:key_public => '/path/to/id_rsa.pub',
|
16
|
+
:global_service_name => 'perconaconf',
|
17
|
+
|
18
|
+
# role details
|
19
|
+
:roles => {
|
20
|
+
# override the default cloud-init script & default bootstrap (which is a chef-client bootstrap)
|
21
|
+
:chef => {
|
22
|
+
# we are the chef server, so skip the chef-client steps
|
23
|
+
:chef_server => true, :skip_chef_prereg => true,
|
24
|
+
# override the default cloud-config with a chef-server template
|
25
|
+
:cloud_config_yaml => 'chef-cloud-config.yaml',
|
26
|
+
# skip the default chef-client bootstrap
|
27
|
+
:bootstrap => '',
|
28
|
+
# wait for the chef server to come up & download pem files & generate client account
|
29
|
+
:post_install_script => 'bootstrap/chef-post-install.sh',
|
30
|
+
# our post install script dumps out .pem files in the CWD
|
31
|
+
:post_install_cwd => '.chef',
|
32
|
+
# The post-install script needs to know the public IP of the just built instance so that this station can access it
|
33
|
+
:post_install_args => '%PUBLIC_IP%'
|
34
|
+
},
|
35
|
+
# much simpler role, just build 3 of these, chef-client will do the rest on boot
|
36
|
+
:web => { :count => 3 }
|
37
|
+
}
|
38
|
+
}
|
39
|
+
}
|
40
|
+
end
|
41
|
+
|
@@ -0,0 +1,27 @@
|
|
1
|
+
Feature: Build application stacks in the cloud using Chef
|
2
|
+
|
3
|
+
Scenario: App just runs
|
4
|
+
When I get help for "stack-kicker"
|
5
|
+
Then the exit status should be 0
|
6
|
+
And the banner should be present
|
7
|
+
And the banner should document that this app takes options
|
8
|
+
And the following options should be documented:
|
9
|
+
|--version|
|
10
|
+
And the banner should document that this app's arguments are:
|
11
|
+
|task|which is required|
|
12
|
+
|
13
|
+
Scenario: show-stacks shows the stacks defined in the current Stackfile
|
14
|
+
Given a 2 stack Stackfile
|
15
|
+
When I successfully run "stack-kicker show-stacks"
|
16
|
+
Then both stacks are listed by show-stack
|
17
|
+
|
18
|
+
Scenario: show-stack shows the stacks defined in the current Stackfile
|
19
|
+
Given a 2 stack Stackfile
|
20
|
+
When I successfully run "stack-kicker show-stack"
|
21
|
+
Then the nodes in both stacks are listed by show-stack
|
22
|
+
|
23
|
+
Scenario: show-stack shows the stack defined in the current Stackfile
|
24
|
+
Given a single stack Stackfile
|
25
|
+
When I successfully run "stack-kicker show-stack"
|
26
|
+
Then the nodes in both stacks are listed by show-stack
|
27
|
+
|
File without changes
|