vmbuilder 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +5 -0
- data/LICENCE +357 -0
- data/Manifest.txt +17 -0
- data/README.txt +57 -0
- data/Rakefile +18 -0
- data/lib/vmbuilder/files/aliases +13 -0
- data/lib/vmbuilder/files/common-session +10 -0
- data/lib/vmbuilder/files/ec2_ami_patch +39 -0
- data/lib/vmbuilder/files/rc_local_patch +57 -0
- data/lib/vmbuilder/files/sources.list +3 -0
- data/lib/vmbuilder/files/update-exim4.conf.conf +30 -0
- data/lib/vmbuilder/recipes.rb +22 -0
- data/lib/vmbuilder/recipes/config.rb +87 -0
- data/lib/vmbuilder/recipes/ec2.rb +87 -0
- data/lib/vmbuilder/recipes/pki.rb +113 -0
- data/lib/vmbuilder/recipes/show_vars.rb +25 -0
- data/lib/vmbuilder/recipes/vm.rb +74 -0
- metadata +88 -0
data/History.txt
ADDED
data/LICENCE
ADDED
@@ -0,0 +1,357 @@
|
|
1
|
+
Virtual Machine Builder
|
2
|
+
Copyright (C) 2007, Neil Wilson, Aldur Systems Ltd
|
3
|
+
|
4
|
+
This program is free software; you can redistribute it and/or modify
|
5
|
+
it under the terms of the GNU General Public License as published by
|
6
|
+
the Free Software Foundation; either version 2 of the License, or
|
7
|
+
(at your option) any later version.
|
8
|
+
|
9
|
+
This program is distributed in the hope that it will be useful,
|
10
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
11
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
12
|
+
GNU General Public License for more details.
|
13
|
+
|
14
|
+
You should have received a copy of the GNU General Public License
|
15
|
+
along with this program; if not, write to the Free Software
|
16
|
+
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
17
|
+
|
18
|
+
GNU GENERAL PUBLIC LICENSE
|
19
|
+
Version 2, June 1991
|
20
|
+
|
21
|
+
Copyright (C) 1989, 1991 Free Software Foundation, Inc.
|
22
|
+
51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
23
|
+
Everyone is permitted to copy and distribute verbatim copies
|
24
|
+
of this license document, but changing it is not allowed.
|
25
|
+
|
26
|
+
Preamble
|
27
|
+
|
28
|
+
The licenses for most software are designed to take away your
|
29
|
+
freedom to share and change it. By contrast, the GNU General Public
|
30
|
+
License is intended to guarantee your freedom to share and change free
|
31
|
+
software--to make sure the software is free for all its users. This
|
32
|
+
General Public License applies to most of the Free Software
|
33
|
+
Foundation's software and to any other program whose authors commit to
|
34
|
+
using it. (Some other Free Software Foundation software is covered by
|
35
|
+
the GNU Library General Public License instead.) You can apply it to
|
36
|
+
your programs, too.
|
37
|
+
|
38
|
+
When we speak of free software, we are referring to freedom, not
|
39
|
+
price. Our General Public Licenses are designed to make sure that you
|
40
|
+
have the freedom to distribute copies of free software (and charge for
|
41
|
+
this service if you wish), that you receive source code or can get it
|
42
|
+
if you want it, that you can change the software or use pieces of it
|
43
|
+
in new free programs; and that you know you can do these things.
|
44
|
+
|
45
|
+
To protect your rights, we need to make restrictions that forbid
|
46
|
+
anyone to deny you these rights or to ask you to surrender the rights.
|
47
|
+
These restrictions translate to certain responsibilities for you if you
|
48
|
+
distribute copies of the software, or if you modify it.
|
49
|
+
|
50
|
+
For example, if you distribute copies of such a program, whether
|
51
|
+
gratis or for a fee, you must give the recipients all the rights that
|
52
|
+
you have. You must make sure that they, too, receive or can get the
|
53
|
+
source code. And you must show them these terms so they know their
|
54
|
+
rights.
|
55
|
+
|
56
|
+
We protect your rights with two steps: (1) copyright the software, and
|
57
|
+
(2) offer you this license which gives you legal permission to copy,
|
58
|
+
distribute and/or modify the software.
|
59
|
+
|
60
|
+
Also, for each author's protection and ours, we want to make certain
|
61
|
+
that everyone understands that there is no warranty for this free
|
62
|
+
software. If the software is modified by someone else and passed on, we
|
63
|
+
want its recipients to know that what they have is not the original, so
|
64
|
+
that any problems introduced by others will not reflect on the original
|
65
|
+
authors' reputations.
|
66
|
+
|
67
|
+
Finally, any free program is threatened constantly by software
|
68
|
+
patents. We wish to avoid the danger that redistributors of a free
|
69
|
+
program will individually obtain patent licenses, in effect making the
|
70
|
+
program proprietary. To prevent this, we have made it clear that any
|
71
|
+
patent must be licensed for everyone's free use or not licensed at all.
|
72
|
+
|
73
|
+
The precise terms and conditions for copying, distribution and
|
74
|
+
modification follow.
|
75
|
+
|
76
|
+
GNU GENERAL PUBLIC LICENSE
|
77
|
+
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
78
|
+
|
79
|
+
0. This License applies to any program or other work which contains
|
80
|
+
a notice placed by the copyright holder saying it may be distributed
|
81
|
+
under the terms of this General Public License. The "Program", below,
|
82
|
+
refers to any such program or work, and a "work based on the Program"
|
83
|
+
means either the Program or any derivative work under copyright law:
|
84
|
+
that is to say, a work containing the Program or a portion of it,
|
85
|
+
either verbatim or with modifications and/or translated into another
|
86
|
+
language. (Hereinafter, translation is included without limitation in
|
87
|
+
the term "modification".) Each licensee is addressed as "you".
|
88
|
+
|
89
|
+
Activities other than copying, distribution and modification are not
|
90
|
+
covered by this License; they are outside its scope. The act of
|
91
|
+
running the Program is not restricted, and the output from the Program
|
92
|
+
is covered only if its contents constitute a work based on the
|
93
|
+
Program (independent of having been made by running the Program).
|
94
|
+
Whether that is true depends on what the Program does.
|
95
|
+
|
96
|
+
1. You may copy and distribute verbatim copies of the Program's
|
97
|
+
source code as you receive it, in any medium, provided that you
|
98
|
+
conspicuously and appropriately publish on each copy an appropriate
|
99
|
+
copyright notice and disclaimer of warranty; keep intact all the
|
100
|
+
notices that refer to this License and to the absence of any warranty;
|
101
|
+
and give any other recipients of the Program a copy of this License
|
102
|
+
along with the Program.
|
103
|
+
|
104
|
+
You may charge a fee for the physical act of transferring a copy, and
|
105
|
+
you may at your option offer warranty protection in exchange for a fee.
|
106
|
+
|
107
|
+
2. You may modify your copy or copies of the Program or any portion
|
108
|
+
of it, thus forming a work based on the Program, and copy and
|
109
|
+
distribute such modifications or work under the terms of Section 1
|
110
|
+
above, provided that you also meet all of these conditions:
|
111
|
+
|
112
|
+
a) You must cause the modified files to carry prominent notices
|
113
|
+
stating that you changed the files and the date of any change.
|
114
|
+
|
115
|
+
b) You must cause any work that you distribute or publish, that in
|
116
|
+
whole or in part contains or is derived from the Program or any
|
117
|
+
part thereof, to be licensed as a whole at no charge to all third
|
118
|
+
parties under the terms of this License.
|
119
|
+
|
120
|
+
c) If the modified program normally reads commands interactively
|
121
|
+
when run, you must cause it, when started running for such
|
122
|
+
interactive use in the most ordinary way, to print or display an
|
123
|
+
announcement including an appropriate copyright notice and a
|
124
|
+
notice that there is no warranty (or else, saying that you provide
|
125
|
+
a warranty) and that users may redistribute the program under
|
126
|
+
these conditions, and telling the user how to view a copy of this
|
127
|
+
License. (Exception: if the Program itself is interactive but
|
128
|
+
does not normally print such an announcement, your work based on
|
129
|
+
the Program is not required to print an announcement.)
|
130
|
+
|
131
|
+
These requirements apply to the modified work as a whole. If
|
132
|
+
identifiable sections of that work are not derived from the Program,
|
133
|
+
and can be reasonably considered independent and separate works in
|
134
|
+
themselves, then this License, and its terms, do not apply to those
|
135
|
+
sections when you distribute them as separate works. But when you
|
136
|
+
distribute the same sections as part of a whole which is a work based
|
137
|
+
on the Program, the distribution of the whole must be on the terms of
|
138
|
+
this License, whose permissions for other licensees extend to the
|
139
|
+
entire whole, and thus to each and every part regardless of who wrote it.
|
140
|
+
|
141
|
+
Thus, it is not the intent of this section to claim rights or contest
|
142
|
+
your rights to work written entirely by you; rather, the intent is to
|
143
|
+
exercise the right to control the distribution of derivative or
|
144
|
+
collective works based on the Program.
|
145
|
+
|
146
|
+
In addition, mere aggregation of another work not based on the Program
|
147
|
+
with the Program (or with a work based on the Program) on a volume of
|
148
|
+
a storage or distribution medium does not bring the other work under
|
149
|
+
the scope of this License.
|
150
|
+
|
151
|
+
3. You may copy and distribute the Program (or a work based on it,
|
152
|
+
under Section 2) in object code or executable form under the terms of
|
153
|
+
Sections 1 and 2 above provided that you also do one of the following:
|
154
|
+
|
155
|
+
a) Accompany it with the complete corresponding machine-readable
|
156
|
+
source code, which must be distributed under the terms of Sections
|
157
|
+
1 and 2 above on a medium customarily used for software interchange; or,
|
158
|
+
|
159
|
+
b) Accompany it with a written offer, valid for at least three
|
160
|
+
years, to give any third party, for a charge no more than your
|
161
|
+
cost of physically performing source distribution, a complete
|
162
|
+
machine-readable copy of the corresponding source code, to be
|
163
|
+
distributed under the terms of Sections 1 and 2 above on a medium
|
164
|
+
customarily used for software interchange; or,
|
165
|
+
|
166
|
+
c) Accompany it with the information you received as to the offer
|
167
|
+
to distribute corresponding source code. (This alternative is
|
168
|
+
allowed only for noncommercial distribution and only if you
|
169
|
+
received the program in object code or executable form with such
|
170
|
+
an offer, in accord with Subsection b above.)
|
171
|
+
|
172
|
+
The source code for a work means the preferred form of the work for
|
173
|
+
making modifications to it. For an executable work, complete source
|
174
|
+
code means all the source code for all modules it contains, plus any
|
175
|
+
associated interface definition files, plus the scripts used to
|
176
|
+
control compilation and installation of the executable. However, as a
|
177
|
+
special exception, the source code distributed need not include
|
178
|
+
anything that is normally distributed (in either source or binary
|
179
|
+
form) with the major components (compiler, kernel, and so on) of the
|
180
|
+
operating system on which the executable runs, unless that component
|
181
|
+
itself accompanies the executable.
|
182
|
+
|
183
|
+
If distribution of executable or object code is made by offering
|
184
|
+
access to copy from a designated place, then offering equivalent
|
185
|
+
access to copy the source code from the same place counts as
|
186
|
+
distribution of the source code, even though third parties are not
|
187
|
+
compelled to copy the source along with the object code.
|
188
|
+
|
189
|
+
4. You may not copy, modify, sublicense, or distribute the Program
|
190
|
+
except as expressly provided under this License. Any attempt
|
191
|
+
otherwise to copy, modify, sublicense or distribute the Program is
|
192
|
+
void, and will automatically terminate your rights under this License.
|
193
|
+
However, parties who have received copies, or rights, from you under
|
194
|
+
this License will not have their licenses terminated so long as such
|
195
|
+
parties remain in full compliance.
|
196
|
+
|
197
|
+
5. You are not required to accept this License, since you have not
|
198
|
+
signed it. However, nothing else grants you permission to modify or
|
199
|
+
distribute the Program or its derivative works. These actions are
|
200
|
+
prohibited by law if you do not accept this License. Therefore, by
|
201
|
+
modifying or distributing the Program (or any work based on the
|
202
|
+
Program), you indicate your acceptance of this License to do so, and
|
203
|
+
all its terms and conditions for copying, distributing or modifying
|
204
|
+
the Program or works based on it.
|
205
|
+
|
206
|
+
6. Each time you redistribute the Program (or any work based on the
|
207
|
+
Program), the recipient automatically receives a license from the
|
208
|
+
original licensor to copy, distribute or modify the Program subject to
|
209
|
+
these terms and conditions. You may not impose any further
|
210
|
+
restrictions on the recipients' exercise of the rights granted herein.
|
211
|
+
You are not responsible for enforcing compliance by third parties to
|
212
|
+
this License.
|
213
|
+
|
214
|
+
7. If, as a consequence of a court judgment or allegation of patent
|
215
|
+
infringement or for any other reason (not limited to patent issues),
|
216
|
+
conditions are imposed on you (whether by court order, agreement or
|
217
|
+
otherwise) that contradict the conditions of this License, they do not
|
218
|
+
excuse you from the conditions of this License. If you cannot
|
219
|
+
distribute so as to satisfy simultaneously your obligations under this
|
220
|
+
License and any other pertinent obligations, then as a consequence you
|
221
|
+
may not distribute the Program at all. For example, if a patent
|
222
|
+
license would not permit royalty-free redistribution of the Program by
|
223
|
+
all those who receive copies directly or indirectly through you, then
|
224
|
+
the only way you could satisfy both it and this License would be to
|
225
|
+
refrain entirely from distribution of the Program.
|
226
|
+
|
227
|
+
If any portion of this section is held invalid or unenforceable under
|
228
|
+
any particular circumstance, the balance of the section is intended to
|
229
|
+
apply and the section as a whole is intended to apply in other
|
230
|
+
circumstances.
|
231
|
+
|
232
|
+
It is not the purpose of this section to induce you to infringe any
|
233
|
+
patents or other property right claims or to contest validity of any
|
234
|
+
such claims; this section has the sole purpose of protecting the
|
235
|
+
integrity of the free software distribution system, which is
|
236
|
+
implemented by public license practices. Many people have made
|
237
|
+
generous contributions to the wide range of software distributed
|
238
|
+
through that system in reliance on consistent application of that
|
239
|
+
system; it is up to the author/donor to decide if he or she is willing
|
240
|
+
to distribute software through any other system and a licensee cannot
|
241
|
+
impose that choice.
|
242
|
+
|
243
|
+
This section is intended to make thoroughly clear what is believed to
|
244
|
+
be a consequence of the rest of this License.
|
245
|
+
|
246
|
+
8. If the distribution and/or use of the Program is restricted in
|
247
|
+
certain countries either by patents or by copyrighted interfaces, the
|
248
|
+
original copyright holder who places the Program under this License
|
249
|
+
may add an explicit geographical distribution limitation excluding
|
250
|
+
those countries, so that distribution is permitted only in or among
|
251
|
+
countries not thus excluded. In such case, this License incorporates
|
252
|
+
the limitation as if written in the body of this License.
|
253
|
+
|
254
|
+
9. The Free Software Foundation may publish revised and/or new versions
|
255
|
+
of the General Public License from time to time. Such new versions will
|
256
|
+
be similar in spirit to the present version, but may differ in detail to
|
257
|
+
address new problems or concerns.
|
258
|
+
|
259
|
+
Each version is given a distinguishing version number. If the Program
|
260
|
+
specifies a version number of this License which applies to it and "any
|
261
|
+
later version", you have the option of following the terms and conditions
|
262
|
+
either of that version or of any later version published by the Free
|
263
|
+
Software Foundation. If the Program does not specify a version number of
|
264
|
+
this License, you may choose any version ever published by the Free Software
|
265
|
+
Foundation.
|
266
|
+
|
267
|
+
10. If you wish to incorporate parts of the Program into other free
|
268
|
+
programs whose distribution conditions are different, write to the author
|
269
|
+
to ask for permission. For software which is copyrighted by the Free
|
270
|
+
Software Foundation, write to the Free Software Foundation; we sometimes
|
271
|
+
make exceptions for this. Our decision will be guided by the two goals
|
272
|
+
of preserving the free status of all derivatives of our free software and
|
273
|
+
of promoting the sharing and reuse of software generally.
|
274
|
+
|
275
|
+
NO WARRANTY
|
276
|
+
|
277
|
+
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
|
278
|
+
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
|
279
|
+
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
|
280
|
+
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
|
281
|
+
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
282
|
+
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
|
283
|
+
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
|
284
|
+
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
|
285
|
+
REPAIR OR CORRECTION.
|
286
|
+
|
287
|
+
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
288
|
+
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
|
289
|
+
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
|
290
|
+
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
|
291
|
+
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
|
292
|
+
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
|
293
|
+
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
|
294
|
+
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
|
295
|
+
POSSIBILITY OF SUCH DAMAGES.
|
296
|
+
|
297
|
+
END OF TERMS AND CONDITIONS
|
298
|
+
|
299
|
+
How to Apply These Terms to Your New Programs
|
300
|
+
|
301
|
+
If you develop a new program, and you want it to be of the greatest
|
302
|
+
possible use to the public, the best way to achieve this is to make it
|
303
|
+
free software which everyone can redistribute and change under these terms.
|
304
|
+
|
305
|
+
To do so, attach the following notices to the program. It is safest
|
306
|
+
to attach them to the start of each source file to most effectively
|
307
|
+
convey the exclusion of warranty; and each file should have at least
|
308
|
+
the "copyright" line and a pointer to where the full notice is found.
|
309
|
+
|
310
|
+
<one line to give the program's name and a brief idea of what it does.>
|
311
|
+
Copyright (C) <year> <name of author>
|
312
|
+
|
313
|
+
This program is free software; you can redistribute it and/or modify
|
314
|
+
it under the terms of the GNU General Public License as published by
|
315
|
+
the Free Software Foundation; either version 2 of the License, or
|
316
|
+
(at your option) any later version.
|
317
|
+
|
318
|
+
This program is distributed in the hope that it will be useful,
|
319
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
320
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
321
|
+
GNU General Public License for more details.
|
322
|
+
|
323
|
+
You should have received a copy of the GNU General Public License
|
324
|
+
along with this program; if not, write to the Free Software
|
325
|
+
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
326
|
+
|
327
|
+
|
328
|
+
Also add information on how to contact you by electronic and paper mail.
|
329
|
+
|
330
|
+
If the program is interactive, make it output a short notice like this
|
331
|
+
when it starts in an interactive mode:
|
332
|
+
|
333
|
+
Gnomovision version 69, Copyright (C) year name of author
|
334
|
+
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
335
|
+
This is free software, and you are welcome to redistribute it
|
336
|
+
under certain conditions; type `show c' for details.
|
337
|
+
|
338
|
+
The hypothetical commands `show w' and `show c' should show the appropriate
|
339
|
+
parts of the General Public License. Of course, the commands you use may
|
340
|
+
be called something other than `show w' and `show c'; they could even be
|
341
|
+
mouse-clicks or menu items--whatever suits your program.
|
342
|
+
|
343
|
+
You should also get your employer (if you work as a programmer) or your
|
344
|
+
school, if any, to sign a "copyright disclaimer" for the program, if
|
345
|
+
necessary. Here is a sample; alter the names:
|
346
|
+
|
347
|
+
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
|
348
|
+
`Gnomovision' (which makes passes at compilers) written by James Hacker.
|
349
|
+
|
350
|
+
<signature of Ty Coon>, 1 April 1989
|
351
|
+
Ty Coon, President of Vice
|
352
|
+
|
353
|
+
This General Public License does not permit incorporating your program into
|
354
|
+
proprietary programs. If your program is a subroutine library, you may
|
355
|
+
consider it more useful to permit linking proprietary applications with the
|
356
|
+
library. If this is what you want to do, use the GNU Library General
|
357
|
+
Public License instead of this License.
|
data/Manifest.txt
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
History.txt
|
2
|
+
LICENCE
|
3
|
+
Manifest.txt
|
4
|
+
README.txt
|
5
|
+
Rakefile
|
6
|
+
lib/vmbuilder/files/aliases
|
7
|
+
lib/vmbuilder/files/common-session
|
8
|
+
lib/vmbuilder/files/ec2_ami_patch
|
9
|
+
lib/vmbuilder/files/rc_local_patch
|
10
|
+
lib/vmbuilder/files/sources.list
|
11
|
+
lib/vmbuilder/files/update-exim4.conf.conf
|
12
|
+
lib/vmbuilder/recipes.rb
|
13
|
+
lib/vmbuilder/recipes/config.rb
|
14
|
+
lib/vmbuilder/recipes/ec2.rb
|
15
|
+
lib/vmbuilder/recipes/pki.rb
|
16
|
+
lib/vmbuilder/recipes/show_vars.rb
|
17
|
+
lib/vmbuilder/recipes/vm.rb
|
data/README.txt
ADDED
@@ -0,0 +1,57 @@
|
|
1
|
+
vmbuilder
|
2
|
+
http://rubyforge.org/projects/vmbuilder
|
3
|
+
neil |at| aldur.co.uk
|
4
|
+
Neil Wilson
|
5
|
+
|
6
|
+
== DESCRIPTION:
|
7
|
+
|
8
|
+
Capistrano tasks to install the necessary packages onto a blank Debian
|
9
|
+
machine to run Rails applications.
|
10
|
+
|
11
|
+
This version is specifically tailored to build Debian Etch on the Amazon
|
12
|
+
EC2 servers.
|
13
|
+
|
14
|
+
== FEATURES/PROBLEMS:
|
15
|
+
|
16
|
+
Installs Apache, MySQL and Mongrel onto a blank EC2 server.
|
17
|
+
|
18
|
+
* Std. Contains commands that enhance the facilities available in Capistrano.
|
19
|
+
* Apt. Used to control the Debian 'apt' package manager
|
20
|
+
* Gem. Used to control the automated installation of Gems.
|
21
|
+
|
22
|
+
Look at the rdoc for each module for a full run down of the features
|
23
|
+
|
24
|
+
== SYNOPSIS:
|
25
|
+
|
26
|
+
require 'vmbuilder_plugins/all'
|
27
|
+
|
28
|
+
== REQUIREMENTS:
|
29
|
+
|
30
|
+
* capistrano
|
31
|
+
|
32
|
+
== INSTALL:
|
33
|
+
|
34
|
+
* sudo gem install vmbuilder_plugins
|
35
|
+
|
36
|
+
== ACKNOWLEDGMENTS:
|
37
|
+
|
38
|
+
My grateful thanks to Ruby community for its help and assistance.
|
39
|
+
|
40
|
+
== LICENCE:
|
41
|
+
|
42
|
+
Capistrano Plugins - abstracted from the vmbuilder project
|
43
|
+
Copyright (C) 2007, Neil Wilson, Aldur Systems Ltd
|
44
|
+
|
45
|
+
This program is free software; you can redistribute it and/or modify
|
46
|
+
it under the terms of the GNU General Public License as published by
|
47
|
+
the Free Software Foundation; either version 2 of the License, or
|
48
|
+
(at your option) any later version.
|
49
|
+
|
50
|
+
This program is distributed in the hope that it will be useful,
|
51
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
52
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
53
|
+
GNU General Public License for more details.
|
54
|
+
|
55
|
+
You should have received a copy of the GNU General Public License
|
56
|
+
along with this program; if not, write to the Free Software
|
57
|
+
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
data/Rakefile
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
# -*- ruby -*-
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'hoe'
|
5
|
+
|
6
|
+
Hoe.new('vmbuilder', '0.0.1') do |p|
|
7
|
+
p.rubyforge_name = 'vmbuilder'
|
8
|
+
p.summary = 'Virtual Machine Builder'
|
9
|
+
p.author = 'Neil Wilson'
|
10
|
+
p.email = 'neil@aldur.co.uk'
|
11
|
+
p.description = p.paragraphs_of('README.txt', 2..5).join("\n\n")
|
12
|
+
p.url = p.paragraphs_of('README.txt', 0).first.split(/\n/)[1..-1]
|
13
|
+
p.changes = p.paragraphs_of('History.txt', 0..1).join("\n\n")
|
14
|
+
p.extra_deps << ['capistrano', '>=1.3.0']
|
15
|
+
p.extra_deps << ['vmbuilder_plugins', '>=0.1.0']
|
16
|
+
end
|
17
|
+
|
18
|
+
# vim: ft=ruby:
|
@@ -0,0 +1,10 @@
|
|
1
|
+
#
|
2
|
+
# /etc/pam.d/common-session - session-related modules common to all services
|
3
|
+
#
|
4
|
+
# This file is included from other service-specific PAM config files,
|
5
|
+
# and should contain a list of modules that define tasks to be performed
|
6
|
+
# at the start and end of sessions of *any* kind (both interactive and
|
7
|
+
# non-interactive). The default is pam_unix.
|
8
|
+
#
|
9
|
+
session required pam_unix.so
|
10
|
+
session optional pam_umask.so debug umask=077
|
@@ -0,0 +1,39 @@
|
|
1
|
+
--- usr/lib/site_ruby/aes/amiutil/image.rb 2006-12-28 14:11:44.000000000 +0000
|
2
|
+
+++ /usr/lib/site_ruby/aes/amiutil/image.rb 2007-01-01 12:22:57.000000000 +0000
|
3
|
+
@@ -138,15 +138,27 @@
|
4
|
+
#----------------------------------------------------------------------------#
|
5
|
+
|
6
|
+
def make_special_dirs
|
7
|
+
- # Make /proc and /sys.
|
8
|
+
- Dir.mkdir( IMG_MNT + '/mnt' )
|
9
|
+
- Dir.mkdir( IMG_MNT + '/proc' )
|
10
|
+
- Dir.mkdir( IMG_MNT + '/sys' )
|
11
|
+
-
|
12
|
+
- # Make device nodes.
|
13
|
+
- dev_dir = IMG_MNT + '/dev'
|
14
|
+
- Dir.mkdir( dev_dir )
|
15
|
+
- exec( 'for i in console null zero ; do /sbin/MAKEDEV -d ' + dev_dir + ' -x $i ; done' )
|
16
|
+
+ # Must exist directories
|
17
|
+
+ special_dirs = %w(mnt proc sys dev)
|
18
|
+
+ special_dirs.each do |special_dir|
|
19
|
+
+ FileUtils::mkdir_p( File::join( IMG_MNT, special_dir ) )
|
20
|
+
+ end
|
21
|
+
+
|
22
|
+
+ # Debian init script lock directory
|
23
|
+
+ lock_dir = File::join ( 'lib', 'init', 'rw')
|
24
|
+
+ if File::directory?( File::join( @volume, lock_dir ) )
|
25
|
+
+ FileUtils::mkdir_p( File::join( IMG_MNT, lock_dir ) )
|
26
|
+
+ end
|
27
|
+
+
|
28
|
+
+ # Look for udev static devices in source volume
|
29
|
+
+ # Copy them if they exist, else make a new minimal set
|
30
|
+
+ dev_dir = File::join( IMG_MNT, 'dev' )
|
31
|
+
+ static_device_dir = File::join (@volume, 'dev', '.static', 'dev')
|
32
|
+
+ if File::directory?( static_device_dir )
|
33
|
+
+ copy_rec( static_device_dir, dev_dir, Array.new )
|
34
|
+
+ else
|
35
|
+
+ exec( 'for i in console null zero ; do /sbin/MAKEDEV -d ' + dev_dir + ' -x $i ; done' )
|
36
|
+
+ end
|
37
|
+
end
|
38
|
+
|
39
|
+
#----------------------------------------------------------------------------#
|
@@ -0,0 +1,57 @@
|
|
1
|
+
--- etc/rc.local 2007-01-07 12:24:58.000000000 +0000
|
2
|
+
+++ /etc/rc.local 2007-01-07 12:33:14.000000000 +0000
|
3
|
+
@@ -9,6 +9,53 @@
|
4
|
+
# In order to enable or disable this script just change the execution
|
5
|
+
# bits.
|
6
|
+
#
|
7
|
+
-# By default this script does nothing.
|
8
|
+
+
|
9
|
+
+PATH="/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin"
|
10
|
+
+
|
11
|
+
+. /lib/lsb/init-functions
|
12
|
+
+
|
13
|
+
+keyurl=http://169.254.169.254/1.0//meta-data/public-keys/0/openssh-key/
|
14
|
+
+keyfile=~root/.ssh/openssh_id.pub
|
15
|
+
+
|
16
|
+
+rebuild_authorized_keys ()
|
17
|
+
+{
|
18
|
+
+ local authdir="$1"
|
19
|
+
+ if [ ! -d "${authdir}" ]; then
|
20
|
+
+ log_warning_msg "${authdir} not a directory."
|
21
|
+
+ return
|
22
|
+
+ fi
|
23
|
+
+ cat "${authdir}"/*.pub > "${authdir}"/authorized_keys ||true
|
24
|
+
+ chmod 600 ${authdir}/authorized_keys
|
25
|
+
+}
|
26
|
+
+
|
27
|
+
+log_action_begin_msg "Fetching EC2 public key"
|
28
|
+
+
|
29
|
+
+# Create the .ssh areas.
|
30
|
+
+mkdir -p -m 700 ~root/.ssh
|
31
|
+
+mkdir -p -m 700 /etc/skel/.ssh
|
32
|
+
+
|
33
|
+
+# Copy file if it exists
|
34
|
+
+if [ -e /mnt/openssh_id.pub ] ; then
|
35
|
+
+ cp -u /mnt/openssh_id.pub ${keyfile}
|
36
|
+
+ chmod 600 ${keyfile}
|
37
|
+
+fi
|
38
|
+
+
|
39
|
+
+# Fetch public key using HTTP
|
40
|
+
+curl -fsm 5 -o ${keyfile} ${keyurl} 2>/dev/null || true
|
41
|
+
+
|
42
|
+
+if [ -e ${keyfile} ]; then
|
43
|
+
+ chmod 600 ${keyfile}
|
44
|
+
+ log_action_end_msg $?
|
45
|
+
+ rebuild_authorized_keys ~root/.ssh
|
46
|
+
+else
|
47
|
+
+ log_action_end_msg $?
|
48
|
+
+fi
|
49
|
+
+
|
50
|
+
+# Ensure created users have access to the same public key.
|
51
|
+
+# Comment this out if you don't want this facility.
|
52
|
+
+if [ -e ${keyfile} ] ; then
|
53
|
+
+ log_action_msg "Added public key to user skeleton framework"
|
54
|
+
+ cp -u ${keyfile} /etc/skel/.ssh
|
55
|
+
+fi
|
56
|
+
|
57
|
+
exit 0
|
@@ -0,0 +1,30 @@
|
|
1
|
+
# /etc/exim4/update-exim4.conf.conf
|
2
|
+
#
|
3
|
+
# Edit this file and /etc/mailname by hand and execute update-exim4.conf
|
4
|
+
# yourself or use 'dpkg-reconfigure exim4-config'
|
5
|
+
#
|
6
|
+
# Please note that this is _not_ a dpkg-conffile and that automatic changes
|
7
|
+
# to this file might happen. The code handling this will honor your local
|
8
|
+
# changes, so this is usually fine, but will break local schemes that mess
|
9
|
+
# around with multiple versions of the file.
|
10
|
+
#
|
11
|
+
# update-exim4.conf uses this file to determine variable values to replace
|
12
|
+
# the DEBCONFsomethingDEBCONF strings in the configuration template files.
|
13
|
+
#
|
14
|
+
# Most settings found in here do have corresponding questions in the
|
15
|
+
# Debconf configuration, but not all of them.
|
16
|
+
#
|
17
|
+
# This is a Debian specific file
|
18
|
+
|
19
|
+
dc_eximconfig_configtype='local'
|
20
|
+
dc_local_interfaces='127.0.0.1'
|
21
|
+
dc_readhost=''
|
22
|
+
dc_relay_domains=''
|
23
|
+
dc_minimaldns='false'
|
24
|
+
dc_relay_nets=''
|
25
|
+
dc_smarthost=''
|
26
|
+
CFILEMODE='644'
|
27
|
+
dc_use_split_config='true'
|
28
|
+
dc_hide_mailname=''
|
29
|
+
dc_mailname_in_oh='true'
|
30
|
+
dc_localdelivery='mail_spool'
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# =recipes.rb: Load vmbuilder tasks
|
2
|
+
# Load all the vmbuilder Capistrano Recipes
|
3
|
+
#
|
4
|
+
# ----
|
5
|
+
# Copyright (c) 2007 Neil Wilson, Aldur Systems Ltd
|
6
|
+
#
|
7
|
+
# Licensed under the GNU Public License v2. No warranty is provided.
|
8
|
+
# ----
|
9
|
+
# = Purpose
|
10
|
+
# Loads all the vmbuilder recipes into Capistrano using the
|
11
|
+
# <tt>Capistrano.configuration(:must_exist).load</tt> guard.
|
12
|
+
#
|
13
|
+
# = Usage
|
14
|
+
#
|
15
|
+
# require 'vmbuilder/recipes'
|
16
|
+
#
|
17
|
+
|
18
|
+
require 'vmbuilder_plugins/all'
|
19
|
+
|
20
|
+
Dir["#{File.dirname(__FILE__)}/recipes/*.rb"].sort.each do |ext|
|
21
|
+
Capistrano.configuration(:must_exist).load ext
|
22
|
+
end
|
@@ -0,0 +1,87 @@
|
|
1
|
+
# =config.rb: Configuration settings
|
2
|
+
# vmbuilder configuration settings
|
3
|
+
#
|
4
|
+
# ----
|
5
|
+
# Copyright (c) 2007 Neil Wilson, Aldur Systems Ltd
|
6
|
+
#
|
7
|
+
# Licensed under the GNU Public License v2. No warranty is provided.
|
8
|
+
# ----
|
9
|
+
# = Purpose
|
10
|
+
# Adapts the machine builder tasks so that they will build an
|
11
|
+
# Amazon EC2 image with a Rails stack in place.
|
12
|
+
#
|
13
|
+
# Images contain the EC2 bundling tools and EC2 key management patches.
|
14
|
+
#
|
15
|
+
# = Usage
|
16
|
+
# Loads along with the rest of the vmbuilder recipes.
|
17
|
+
#
|
18
|
+
# require 'vmbuilder/recipes'
|
19
|
+
#
|
20
|
+
|
21
|
+
# Use direct root access and switch off 'sudo'
|
22
|
+
set :user, 'root'
|
23
|
+
set :use_sudo, false
|
24
|
+
|
25
|
+
# VIRTUAL MACHINE CONFIGURATION DETAILS
|
26
|
+
# =====================================
|
27
|
+
|
28
|
+
# Packages required for a debian VM machine
|
29
|
+
set :vm_debian, {
|
30
|
+
:base => %w(
|
31
|
+
bzip2 iproute less ntp perl python lsof info
|
32
|
+
manpages traceroute wget curl ruby rubygems rsync at
|
33
|
+
libc6-dev make gcc ruby rubygems irb ruby1.8-dev
|
34
|
+
linux-headers-2.6-xen-686 libmysql-ruby libpam-umask
|
35
|
+
libmysqlclient15-dev mysql-server
|
36
|
+
apache2
|
37
|
+
exim4-daemon-light mailx
|
38
|
+
subversion fail2ban
|
39
|
+
ssl-cert
|
40
|
+
)
|
41
|
+
}
|
42
|
+
|
43
|
+
set :gem_packages, %w(rake fastthread mongrel mongrel_cluster rails)
|
44
|
+
|
45
|
+
# EC2 AMI SETTINGS
|
46
|
+
# ================
|
47
|
+
|
48
|
+
# Ensure that the apt files are pointing at the right server.
|
49
|
+
task :before_vm_setup, :roles => :debian do
|
50
|
+
files=File.join(File.dirname(__FILE__), '..','files')
|
51
|
+
std.fput( File.join(files, 'sources.list'),
|
52
|
+
'/etc/apt/sources.list')
|
53
|
+
end
|
54
|
+
|
55
|
+
# Fix up the email configurations
|
56
|
+
task :after_vm_setup, :roles => :debian do
|
57
|
+
files=File.join(File.dirname(__FILE__), '..', 'files')
|
58
|
+
std.fput( File.join(files, 'aliases'), '/etc/aliases', :mode => 0644)
|
59
|
+
std.fput( File.join(files, 'update-exim4.conf.conf'), '/etc/exim4/update-exim4.conf.conf', :mode => 0644)
|
60
|
+
std.fput( File.join(files, 'common-session'), '/etc/pam.d/common-session', :mode => 0644)
|
61
|
+
std.patch( File.join(files, 'rc_local_patch'))
|
62
|
+
send(run_method, "chmod +x /etc/rc.local")
|
63
|
+
send(run_method, "crontab -r || true")
|
64
|
+
end
|
65
|
+
|
66
|
+
# EC2 MACHINE BUNDLE TOOLS
|
67
|
+
# ========================
|
68
|
+
|
69
|
+
set :rpm_packages, %w(https://s3.amazonaws.com/ec2-downloads/ec2-ami-tools.noarch.rpm)
|
70
|
+
|
71
|
+
# Patch up the EC2 bundler.
|
72
|
+
# The RPM package points site_ruby at the wrong place for Debian.
|
73
|
+
# Create a correcting symbolic link.
|
74
|
+
task :before_vm_rpm_install, :roles => :debian do
|
75
|
+
std.ruby %{
|
76
|
+
File.symlink($LOAD_PATH.grep(/site_ruby/).first, "/usr/lib/site_ruby") unless File.exists? "/usr/lib/site_ruby"
|
77
|
+
}
|
78
|
+
end
|
79
|
+
|
80
|
+
# Patch the 'image.rb' file so that it will create devices
|
81
|
+
# properly for Debian.
|
82
|
+
task :after_vm_rpm_install, :roles => :debian do
|
83
|
+
files=File.join(File.dirname(__FILE__), '..','files')
|
84
|
+
std.patch( File.join(files, 'ec2_ami_patch'))
|
85
|
+
end
|
86
|
+
|
87
|
+
# vim: nowrap sw=2 sts=2 ts=8 ff=unix ft=ruby:
|
@@ -0,0 +1,87 @@
|
|
1
|
+
# =ec2.rb: EC2 bundle management
|
2
|
+
# EC2 bundle management Capistrano Tasks
|
3
|
+
#
|
4
|
+
# ----
|
5
|
+
# Copyright (c) 2007 Neil Wilson, Aldur Systems Ltd
|
6
|
+
#
|
7
|
+
# Licensed under the GNU Public License v2. No warranty is provided.
|
8
|
+
# ----
|
9
|
+
# = Purpose
|
10
|
+
# Task to manage EC2 bundle management and storage of bundles
|
11
|
+
# on Amazon S3
|
12
|
+
#
|
13
|
+
# = Usage
|
14
|
+
# Load along with the rest of the vmbuilder recipes.
|
15
|
+
#
|
16
|
+
# require 'vmbuilder/recipes'
|
17
|
+
#
|
18
|
+
# Ensure that the EC2 and S3 environment variables are set before running
|
19
|
+
# these tasks.
|
20
|
+
#
|
21
|
+
# AWS_ACCESS_KEY_ID
|
22
|
+
# AWS_SECRET_ACCESS_KEY
|
23
|
+
# EC2_PRIVATE_KEY
|
24
|
+
# EC2_CERT
|
25
|
+
#
|
26
|
+
# Bear in mind that the key details will appear in the Capistrano output.
|
27
|
+
#
|
28
|
+
# Any bundles uploaded to S3 will need to be registered with EC2
|
29
|
+
# using 'ec2-register' before they can be booted.
|
30
|
+
#
|
31
|
+
# FIXME: Needs the key management refactoring out.
|
32
|
+
# FIXME: Stop the key details appearing in the Capistrano output.
|
33
|
+
|
34
|
+
desc "Store image files to S3"
|
35
|
+
task :ec2_store_image, :roles => :debian do
|
36
|
+
image_dir="/mnt/image"
|
37
|
+
send run_method, %{
|
38
|
+
ec2-upload-bundle --bucket #{ec2_bucket} --manifest #{File.join(image_dir, ec2_image_name + '.manifest.xml')} --access-key #{ENV['AWS_ACCESS_KEY_ID']} --secret-key #{ENV['AWS_SECRET_ACCESS_KEY']}
|
39
|
+
}
|
40
|
+
end
|
41
|
+
|
42
|
+
desc "Retrieve image files from S3"
|
43
|
+
task :ec2_retrieve_image, :roles => :debian do
|
44
|
+
image_dir="/mnt/image"
|
45
|
+
private_key=File.join(image_dir, 'keys', File.basename(ENV['EC2_PRIVATE_KEY']))
|
46
|
+
send run_method, %{
|
47
|
+
ec2-download-bundle --bucket #{ec2_bucket} --prefix #{ec2_image_name} --access-key #{ENV['AWS_ACCESS_KEY_ID']} --secret-key #{ENV['AWS_SECRET_ACCESS_KEY']} -k #{private_key} -d #{image_dir}
|
48
|
+
}
|
49
|
+
end
|
50
|
+
|
51
|
+
desc "Unbundle image"
|
52
|
+
task :ec2_unbundle_image, :roles => :debian do
|
53
|
+
image_dir="/mnt/image"
|
54
|
+
private_key=File.join(image_dir, 'keys', File.basename(ENV['EC2_PRIVATE_KEY']))
|
55
|
+
send run_method, %{
|
56
|
+
ec2-unbundle --manifest #{File.join(image_dir,ec2_image_name + '.manifest.xml')} -k #{private_key} -s #{image_dir} -d #{image_dir}
|
57
|
+
}
|
58
|
+
end
|
59
|
+
|
60
|
+
desc "Rebundle image"
|
61
|
+
task :ec2_rebundle_image, :roles => :debian do
|
62
|
+
key_dir="/mnt/image/keys"
|
63
|
+
image_size=2048
|
64
|
+
privatekey=File.join(key_dir, File.basename(ENV['EC2_PRIVATE_KEY']))
|
65
|
+
cert=File.join(key_dir, File.basename(ENV['EC2_CERT']))
|
66
|
+
image_dir=File.dirname(key_dir)
|
67
|
+
send run_method, "mkdir -p #{key_dir} -m 700"
|
68
|
+
send run_method, "mkdir -p /etc/skel/.ssh -m 700"
|
69
|
+
std.fput(ENV['EC2_PRIVATE_KEY'], privatekey, :mode => 0600)
|
70
|
+
std.fput(ENV['EC2_CERT'], cert, :mode => 0600)
|
71
|
+
delete File.join(image_dir, ec2_image_name)
|
72
|
+
send run_method, %{
|
73
|
+
ec2-bundle-vol --cert #{cert} --privatekey #{privatekey} --user #{ec2_user} -e ~root/.ssh,/etc/skel/.ssh --prefix #{ec2_image_name} -d #{image_dir} -s #{image_size}
|
74
|
+
}
|
75
|
+
delete key_dir, :recursive => true
|
76
|
+
end
|
77
|
+
|
78
|
+
desc "Delete image files from S3"
|
79
|
+
task :ec2_delete_image, :roles => :debian do
|
80
|
+
image_dir="/mnt/image"
|
81
|
+
private_key=File.join(image_dir, 'keys', File.basename(ENV['EC2_PRIVATE_KEY']))
|
82
|
+
send run_method, %{
|
83
|
+
ec2-delete-bundle --bucket #{ec2_bucket} --prefix #{ec2_image_name} --access-key #{ENV['AWS_ACCESS_KEY_ID']} --secret-key #{ENV['AWS_SECRET_ACCESS_KEY']} -y
|
84
|
+
}
|
85
|
+
end
|
86
|
+
|
87
|
+
|
@@ -0,0 +1,113 @@
|
|
1
|
+
# =pki.rb: PKI management tasks
|
2
|
+
# Capistrano task to manage a PKI infrastructure
|
3
|
+
#
|
4
|
+
# ----
|
5
|
+
# Copyright (c) 2007 Neil Wilson, Aldur Systems Ltd
|
6
|
+
#
|
7
|
+
# Licensed under the GNU Public License v2. No warranty is provided.
|
8
|
+
# ----
|
9
|
+
# = Purpose
|
10
|
+
# These Capistrano tasks allow you to automatically create users on
|
11
|
+
# target servers that use public keys for logon.
|
12
|
+
#
|
13
|
+
# The user created is given sudo capability on the target server.
|
14
|
+
#
|
15
|
+
# Assumes a Debian derived target machine.
|
16
|
+
#
|
17
|
+
# = Usage
|
18
|
+
# Load along with the rest of the vmbuilder recipes.
|
19
|
+
#
|
20
|
+
# require 'vmbuilder/recipes'
|
21
|
+
#
|
22
|
+
# View the tasks with
|
23
|
+
#
|
24
|
+
# cap show_tasks | egrep 'pki_'
|
25
|
+
#
|
26
|
+
# = To create a user
|
27
|
+
# - Create a key pair with <tt>ssh-keygen</tt>
|
28
|
+
# - Point the environment variable PUBKEY at the public key half of the file.
|
29
|
+
# - Run <tt>cap pki_create</tt> to install +sudo+ and create the user.
|
30
|
+
# - Enter the root password if required.
|
31
|
+
# - By default the user created uses the same id as the user running
|
32
|
+
# the command. Use <tt>cap -S user=xxxx pki_create</tt> if you want a
|
33
|
+
# different id.
|
34
|
+
# - Login using +ssh+ to check the PKI is working and run +sudo+ to check
|
35
|
+
# root access.
|
36
|
+
# - Switch off direct root access using <tt>cap pki_secure_root</tt>
|
37
|
+
|
38
|
+
set :keyfile, nil
|
39
|
+
set :authorized_keys, nil
|
40
|
+
|
41
|
+
desc "Install sudo and set up the PKI infrastructure"
|
42
|
+
task :pki_create do
|
43
|
+
pki_install_sudo
|
44
|
+
pki_create_user
|
45
|
+
end
|
46
|
+
|
47
|
+
#desc "Set up the PKI infrastructure on all servers"
|
48
|
+
task :pki_create_user do
|
49
|
+
set_pki_vars
|
50
|
+
std.connect_as_root do |real_user|
|
51
|
+
run "addgroup --system admin || true"
|
52
|
+
run "adduser --gecos \"#{gecos}\" --disabled-password #{real_user} || true"
|
53
|
+
run "usermod -G admin #{real_user}"
|
54
|
+
ssh_dir=File.dirname(authorized_keys)
|
55
|
+
loop_key=File.join(ssh_dir,"id_rsa")
|
56
|
+
run "mkdir -p -m 700 #{ssh_dir}"
|
57
|
+
put public_key, authorized_keys, :mode => 0600
|
58
|
+
run "rm -f #{loop_key} &&
|
59
|
+
ssh-keygen -q -t rsa -N '' -f #{loop_key} &&
|
60
|
+
cat #{loop_key}.pub >>#{authorized_keys}"
|
61
|
+
run "chown -R #{real_user}.#{real_user} #{ssh_dir}"
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
desc "Create or replace the PKI authorized keys file on all target machines"
|
66
|
+
task :pki_update_keys do
|
67
|
+
set_pki_vars
|
68
|
+
run "mkdir -p -m 700 #{File.dirname(authorized_keys)}"
|
69
|
+
put public_key, authorized_keys, :mode => 0600
|
70
|
+
ssh_dir=File.dirname(authorized_keys)
|
71
|
+
loop_key=File.join(ssh_dir,"id_rsa")
|
72
|
+
run "rm -f #{loop_key} &&
|
73
|
+
ssh-keygen -q -t rsa -N '' -f #{loop_key} &&
|
74
|
+
cat #{loop_key}.pub >>#{authorized_keys}"
|
75
|
+
end
|
76
|
+
|
77
|
+
#desc "Ensure that sudo is installed and 'sudoers' is setup appropriately"
|
78
|
+
task :pki_install_sudo do
|
79
|
+
set_pki_vars
|
80
|
+
std.connect_as_root do
|
81
|
+
run "apt-get -qy update && apt-get -qy install sudo"
|
82
|
+
sudoer= <<-SUDOER
|
83
|
+
Defaults:%admin !lecture,tty_tickets,!fqdn,!authenticate
|
84
|
+
root ALL=(ALL) ALL
|
85
|
+
%admin ALL=(ALL) ALL
|
86
|
+
SUDOER
|
87
|
+
put sudoer, "/etc/sudoers", :mode => 0440
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
desc "Switch off direct ssh root access"
|
92
|
+
task :pki_secure_root do
|
93
|
+
set_pki_vars
|
94
|
+
sudo "sed -i 's/^PermitRootLogin[ ]*yes$/PermitRootLogin no/' /etc/ssh/sshd_config"
|
95
|
+
sudo "nohup /etc/init.d/ssh restart >/dev/null 2>&1"
|
96
|
+
end
|
97
|
+
|
98
|
+
def set_pki_vars #:nodoc:
|
99
|
+
set :gecos, " "
|
100
|
+
set :user, ENV['USER'] unless user
|
101
|
+
File.open("/etc/passwd") do |file|
|
102
|
+
file.each do |line|
|
103
|
+
udata = /^([^:]*):(?:[^:]*:){3}([^:]*)/.match(line).captures
|
104
|
+
set :gecos, udata[1] if udata[0] == user
|
105
|
+
end
|
106
|
+
end
|
107
|
+
set :keyfile, ENV['PUBKEY'] || "/home/#{user}/.ssh/id_rsa.pub" unless keyfile
|
108
|
+
set :authorized_keys, "/home/#{user}/.ssh/authorized_keys" unless authorized_keys
|
109
|
+
set (:public_key) { File.open(keyfile).read }
|
110
|
+
end
|
111
|
+
|
112
|
+
|
113
|
+
# vim: nowrap sw=2 sts=2 ts=8 ff=unix ft=ruby:
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# =show_vars.rb: Show Variables Task
|
2
|
+
# Show Variables Capistrano Task
|
3
|
+
#
|
4
|
+
# ----
|
5
|
+
# Copyright (c) 2007 Neil Wilson, Aldur Systems Ltd
|
6
|
+
#
|
7
|
+
# Licensed under the GNU Public License v2. No warranty is provided.
|
8
|
+
# ----
|
9
|
+
# = Purpose
|
10
|
+
# Task that outputs the current crop of 'set' variables.
|
11
|
+
#
|
12
|
+
# = Usage
|
13
|
+
# Load along with the rest of the vmbuilder recipes.
|
14
|
+
#
|
15
|
+
# require 'vmbuilder/recipes'
|
16
|
+
#
|
17
|
+
|
18
|
+
desc "Pretty Print the current crop of 'set' variables"
|
19
|
+
task :show_vars do
|
20
|
+
require 'pp'
|
21
|
+
puts "Current 'set' variables"
|
22
|
+
puts "======================="
|
23
|
+
puts
|
24
|
+
pp variables
|
25
|
+
end
|
@@ -0,0 +1,74 @@
|
|
1
|
+
# =vm.rb: Build virtual machine
|
2
|
+
# Capistrano Tasks to build a Debian based virtual machine
|
3
|
+
#
|
4
|
+
# ----
|
5
|
+
# Copyright (c) 2007 Neil Wilson, Aldur Systems Ltd
|
6
|
+
#
|
7
|
+
# Licensed under the GNU Public License v2. No warranty is provided.
|
8
|
+
# ----
|
9
|
+
# = Purpose
|
10
|
+
# Upgrades the operating system packages and installs the necessary
|
11
|
+
# packages, gems and RPMs required so that the machine can support Rails
|
12
|
+
# applications.
|
13
|
+
#
|
14
|
+
# The tasks clear all the log files, cache files and history files as
|
15
|
+
# well as deactivating the automatic start of Mysql and Apache.
|
16
|
+
#
|
17
|
+
# = Usage
|
18
|
+
# Load along with the rest of the vmbuilder recipes.
|
19
|
+
#
|
20
|
+
# require 'vmbuilder/recipes'
|
21
|
+
#
|
22
|
+
# A machine is built by adding the name to the +debian+ role and running:
|
23
|
+
#
|
24
|
+
# cap vm_setup
|
25
|
+
|
26
|
+
desc "Setup all VMs"
|
27
|
+
task :vm_setup, :roles => :debian do
|
28
|
+
send(run_method, "depmod -a")
|
29
|
+
apt.update
|
30
|
+
apt.dist_upgrade
|
31
|
+
apt.update
|
32
|
+
apt.install(vm_debian, :base, :mode => 0644)
|
33
|
+
gem.update_system
|
34
|
+
gem_packages.each {|gem_name| gem.select(gem_name)}
|
35
|
+
gem.cleanup
|
36
|
+
vm_rpm_install
|
37
|
+
vm_deactivate
|
38
|
+
apt.clear_cache
|
39
|
+
vm_clear_logs
|
40
|
+
end
|
41
|
+
|
42
|
+
desc "Clean out log and history files"
|
43
|
+
task :vm_clear_logs, :roles => :debian do
|
44
|
+
std.su_delete '/var/log/*.[0-9]*'
|
45
|
+
std.ruby %q{
|
46
|
+
Dir.entries("/var/log").each do |log_entry|
|
47
|
+
log_entry = File.join("/var/log", log_entry)
|
48
|
+
if File.file?(log_entry)
|
49
|
+
puts "Clearing #{log_entry}"
|
50
|
+
original_directory_entry = File.stat(log_entry)
|
51
|
+
File.unlink(log_entry)
|
52
|
+
File.open(log_entry, File::CREAT|File::EXCL|File::WRONLY,
|
53
|
+
original_directory_entry.mode) do |log_file|
|
54
|
+
log_file.chown(original_directory_entry.uid, original_directory_entry.gid)
|
55
|
+
log_file.truncate(0)
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
}
|
60
|
+
delete "~/.bash_history"
|
61
|
+
std.su_delete "~root/.bash_history"
|
62
|
+
end
|
63
|
+
|
64
|
+
desc "Install EC2 RPMs"
|
65
|
+
task :vm_rpm_install, :roles => :debian do
|
66
|
+
apt.rpm_install(rpm_packages)
|
67
|
+
end
|
68
|
+
|
69
|
+
desc "Switch off services"
|
70
|
+
task :vm_deactivate, :roles => :debian do
|
71
|
+
send(run_method, "invoke-rc.d apache2 stop || true")
|
72
|
+
send(run_method, "invoke-rc.d mysql stop || true")
|
73
|
+
send(run_method, "chmod -x /etc/init.d/mysql* /etc/init.d/apache*")
|
74
|
+
end
|
metadata
ADDED
@@ -0,0 +1,88 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
rubygems_version: 0.9.1
|
3
|
+
specification_version: 1
|
4
|
+
name: vmbuilder
|
5
|
+
version: !ruby/object:Gem::Version
|
6
|
+
version: 0.0.1
|
7
|
+
date: 2007-01-23 00:00:00 +00:00
|
8
|
+
summary: Virtual Machine Builder
|
9
|
+
require_paths:
|
10
|
+
- lib
|
11
|
+
email: neil@aldur.co.uk
|
12
|
+
homepage: " http://rubyforge.org/projects/vmbuilder"
|
13
|
+
rubyforge_project: vmbuilder
|
14
|
+
description: "This version is specifically tailored to build Debian Etch on the Amazon EC2 servers. == FEATURES/PROBLEMS: Installs Apache, MySQL and Mongrel onto a blank EC2 server. * Std. Contains commands that enhance the facilities available in Capistrano. * Apt. Used to control the Debian 'apt' package manager * Gem. Used to control the automated installation of Gems."
|
15
|
+
autorequire:
|
16
|
+
default_executable:
|
17
|
+
bindir: bin
|
18
|
+
has_rdoc: true
|
19
|
+
required_ruby_version: !ruby/object:Gem::Version::Requirement
|
20
|
+
requirements:
|
21
|
+
- - ">"
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: 0.0.0
|
24
|
+
version:
|
25
|
+
platform: ruby
|
26
|
+
signing_key:
|
27
|
+
cert_chain:
|
28
|
+
post_install_message:
|
29
|
+
authors:
|
30
|
+
- Neil Wilson
|
31
|
+
files:
|
32
|
+
- History.txt
|
33
|
+
- LICENCE
|
34
|
+
- Manifest.txt
|
35
|
+
- README.txt
|
36
|
+
- Rakefile
|
37
|
+
- lib/vmbuilder/files/aliases
|
38
|
+
- lib/vmbuilder/files/common-session
|
39
|
+
- lib/vmbuilder/files/ec2_ami_patch
|
40
|
+
- lib/vmbuilder/files/rc_local_patch
|
41
|
+
- lib/vmbuilder/files/sources.list
|
42
|
+
- lib/vmbuilder/files/update-exim4.conf.conf
|
43
|
+
- lib/vmbuilder/recipes.rb
|
44
|
+
- lib/vmbuilder/recipes/config.rb
|
45
|
+
- lib/vmbuilder/recipes/ec2.rb
|
46
|
+
- lib/vmbuilder/recipes/pki.rb
|
47
|
+
- lib/vmbuilder/recipes/show_vars.rb
|
48
|
+
- lib/vmbuilder/recipes/vm.rb
|
49
|
+
test_files: []
|
50
|
+
|
51
|
+
rdoc_options: []
|
52
|
+
|
53
|
+
extra_rdoc_files: []
|
54
|
+
|
55
|
+
executables: []
|
56
|
+
|
57
|
+
extensions: []
|
58
|
+
|
59
|
+
requirements: []
|
60
|
+
|
61
|
+
dependencies:
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: capistrano
|
64
|
+
version_requirement:
|
65
|
+
version_requirements: !ruby/object:Gem::Version::Requirement
|
66
|
+
requirements:
|
67
|
+
- - ">="
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: 1.3.0
|
70
|
+
version:
|
71
|
+
- !ruby/object:Gem::Dependency
|
72
|
+
name: vmbuilder_plugins
|
73
|
+
version_requirement:
|
74
|
+
version_requirements: !ruby/object:Gem::Version::Requirement
|
75
|
+
requirements:
|
76
|
+
- - ">="
|
77
|
+
- !ruby/object:Gem::Version
|
78
|
+
version: 0.1.0
|
79
|
+
version:
|
80
|
+
- !ruby/object:Gem::Dependency
|
81
|
+
name: hoe
|
82
|
+
version_requirement:
|
83
|
+
version_requirements: !ruby/object:Gem::Version::Requirement
|
84
|
+
requirements:
|
85
|
+
- - ">="
|
86
|
+
- !ruby/object:Gem::Version
|
87
|
+
version: 1.1.7
|
88
|
+
version:
|