bosh-bootstrap 0.9.0 → 0.10.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.travis.yml +2 -2
- data/ChangeLog.md +11 -0
- data/CleanupCi.md +8 -0
- data/README.md +1 -1
- data/docs/README.md +3 -0
- data/docs/devstack-openstack-tutorial.md +215 -0
- data/lib/bosh-bootstrap/cli.rb +41 -27
- data/lib/bosh-bootstrap/commander/remote_server.rb +4 -0
- data/lib/bosh-bootstrap/helpers/settings.rb +1 -0
- data/lib/bosh-bootstrap/stages/stage_micro_bosh_deploy.rb +0 -6
- data/lib/bosh-bootstrap/stages/{stage_micro_bosh_deploy → stage_micro_bosh_download}/download_micro_bosh_stemcell +11 -4
- data/lib/bosh-bootstrap/stages/stage_micro_bosh_download.rb +139 -0
- data/lib/bosh-bootstrap/stages.rb +1 -0
- data/lib/bosh-bootstrap/version.rb +1 -1
- data/spec/unit/aws_spec.rb +3 -3
- data/spec/unit/cli_spec.rb +10 -8
- data/vendor/cache/builder-3.2.0.gem +0 -0
- data/vendor/cache/excon-0.20.1.gem +0 -0
- data/vendor/cache/highline-1.6.18.gem +0 -0
- data/vendor/cache/mime-types-1.22.gem +0 -0
- data/vendor/cache/nokogiri-1.5.9.gem +0 -0
- metadata +13 -10
- data/vendor/cache/builder-3.1.4.gem +0 -0
- data/vendor/cache/excon-0.17.0.gem +0 -0
- data/vendor/cache/highline-1.6.15.gem +0 -0
- data/vendor/cache/mime-types-1.21.gem +0 -0
- data/vendor/cache/nokogiri-1.5.6-java.gem +0 -0
- data/vendor/cache/nokogiri-1.5.6.gem +0 -0
data/.travis.yml
CHANGED
@@ -15,8 +15,8 @@ env:
|
|
15
15
|
matrix:
|
16
16
|
- SUITE=unit
|
17
17
|
# - SUITE=integration:aws:basic
|
18
|
-
- SUITE=integration:aws:edge
|
19
|
-
|
18
|
+
# - SUITE=integration:aws:edge
|
19
|
+
- SUITE=integration:aws:edge_prebuilt
|
20
20
|
# - SUITE=integration:aws:edge_prebuilt_ami
|
21
21
|
global:
|
22
22
|
- secure: "OS3pnXOAVRP0QPDl/Nn/0iBPZbrnn9irFYwEbMJ2fGPsV00u4IYDwoIN5Gzb\nX+cXyiPZB0jdQlbiCMaQEYjYig3fgnDhiLj/MnxkVYtILm+0uPSrX2Zf7jvR\nmxCT5jfTSZoPXQeNi9h8rEqvaqKv4z930xp/Z0QNoZLPWdwY5wk="
|
data/ChangeLog.md
CHANGED
@@ -2,6 +2,17 @@
|
|
2
2
|
|
3
3
|
`bosh-bootstrap` is a command line tool that you can run on your laptop and automatically get a microbosh (and an inception VM) deployed on either AWS or OpenStack.
|
4
4
|
|
5
|
+
gem install bosh-bootstrap
|
6
|
+
bosh-bootstrap deploy
|
7
|
+
|
8
|
+
## v0.10
|
9
|
+
|
10
|
+
* Only using latest pre-release bosh gems & stemcells/amis - do not upgrade if you want the old 2012 gems
|
11
|
+
* AWS us-east-1 uses a pre-built AMI for extra speed
|
12
|
+
* AWS all regions are working (using pre-created stemcell)
|
13
|
+
* OpenStack is now working (using pre-created stemcell)
|
14
|
+
* `deploy --create-inception` chooses to create an inception VM
|
15
|
+
|
5
16
|
## v0.9
|
6
17
|
|
7
18
|
* v0.8 wasn't working for many people; and neither will v0.9; but its a move in the right direction.
|
data/CleanupCi.md
ADDED
@@ -0,0 +1,8 @@
|
|
1
|
+
# Clean up Ci
|
2
|
+
|
3
|
+
Currently, the travis runs are not self-destroying the servers. If CI fails, ask @drnic to run:
|
4
|
+
|
5
|
+
```
|
6
|
+
fog = Fog::Compute::AWS.new(Fog.credentials.merge(region: 'us-east-1'))
|
7
|
+
fog.security_groups.select {|sg| p sg.name =~ /inception-vm/}.each {|sg| fog.servers.select {|s| s.security_group_ids.include? sg.group_id}.each {|s| puts s; s.destroy}}; nil
|
8
|
+
```
|
data/README.md
CHANGED
@@ -48,7 +48,7 @@ Stage 1: Choose infrastructure
|
|
48
48
|
Found infrastructure API credentials at ~/.fog (override with --fog)
|
49
49
|
1. AWS (default)
|
50
50
|
2. AWS (bosh)
|
51
|
-
3.
|
51
|
+
3. Openstack (default)
|
52
52
|
Choose infrastructure: 1
|
53
53
|
|
54
54
|
Confirming: using AWS infrastructure.
|
data/docs/README.md
ADDED
@@ -0,0 +1,215 @@
|
|
1
|
+
#Deploy bosh-bootstrap on OpenStack (Using DevStack)
|
2
|
+
|
3
|
+
|
4
|
+
This tutorial is intended for developers/testers without prior experience with OpenStack. However, it is also useful for OpenStack users as it provides interesting insights into this highly popular project.
|
5
|
+
It is mainly designed to run bosh-bootstrap with minimum hardware requirements.
|
6
|
+
|
7
|
+
######Note:
|
8
|
+
DevStack is only used for development/testing purposes. It is not for suitable for production mode.
|
9
|
+
However, this tutorial still holds good for production scale OpenStack setup as there is hardly anything you have to do on your own,whatever the underlying IaaS is :)
|
10
|
+
|
11
|
+
##Prerequisities
|
12
|
+
|
13
|
+
###Hardware (Minimum)
|
14
|
+
|
15
|
+
```
|
16
|
+
|
17
|
+
4GB RAM (8 GB Preferred), 2 CPU Cores (4 Cores Preferred), 160GB Hard Disk
|
18
|
+
|
19
|
+
```
|
20
|
+
|
21
|
+
######Note:
|
22
|
+
The hardware requirements will scale up when you move towards deploying bosh-cloudfoundry (It's not covered in this tutorial)
|
23
|
+
|
24
|
+
###Software
|
25
|
+
|
26
|
+
```
|
27
|
+
|
28
|
+
1. OS - Ubuntu 12.04 Server
|
29
|
+
2. VM Image - Ubuntu 10.04 Server
|
30
|
+
3. IaaS - OpenStack (DevStack in this case)
|
31
|
+
|
32
|
+
```
|
33
|
+
|
34
|
+
##Preparation
|
35
|
+
|
36
|
+
#####Download devstack
|
37
|
+
|
38
|
+
```
|
39
|
+
|
40
|
+
git clone https://github.com/openstack-dev/devstack.git
|
41
|
+
|
42
|
+
```
|
43
|
+
#####Modify end-points in devstack/files/keystone_data.sh
|
44
|
+
|
45
|
+
Change
|
46
|
+
|
47
|
+
```
|
48
|
+
|
49
|
+
keystone endpoint-create \
|
50
|
+
--region RegionOne \
|
51
|
+
--service_id $GLANCE_SERVICE \
|
52
|
+
--publicurl "http://$SERVICE_HOST:9292" \
|
53
|
+
--adminurl "http://$SERVICE_HOST:9292" \
|
54
|
+
--internalurl "http://$SERVICE_HOST:9292"
|
55
|
+
|
56
|
+
```
|
57
|
+
|
58
|
+
to
|
59
|
+
|
60
|
+
```
|
61
|
+
|
62
|
+
keystone endpoint-create \
|
63
|
+
--region RegionOne \
|
64
|
+
--service_id $GLANCE_SERVICE \
|
65
|
+
--publicurl "http://$SERVICE_HOST:9292/v1.0" \
|
66
|
+
--adminurl "http://$SERVICE_HOST:9292/v1.0" \
|
67
|
+
--internalurl "http://$SERVICE_HOST:9292/v1.0"
|
68
|
+
|
69
|
+
```
|
70
|
+
|
71
|
+
#####DevStack has a 5GB volume limit. However, you can increase it by modifying the following line in devstack/stackrc
|
72
|
+
|
73
|
+
```
|
74
|
+
|
75
|
+
VOLUME_BACKING_FILE_SIZE=${VOLUME_BACKING_FILE_SIZE:-5130M}
|
76
|
+
|
77
|
+
```
|
78
|
+
|
79
|
+
######Note :
|
80
|
+
This tutorial is based on 5GB volume limit only. But in general, having atleast 10GB volume for
|
81
|
+
each instance is preferred. Feel free to play with volume limit.
|
82
|
+
|
83
|
+
#####Install devstack
|
84
|
+
|
85
|
+
```
|
86
|
+
|
87
|
+
cd devstack & ./stack.sh
|
88
|
+
|
89
|
+
```
|
90
|
+
|
91
|
+
Define OpenStack env - OS_USERNAME,OS_PASSWORD,OS_TENANT_NAME,OS_AUTH_URL
|
92
|
+
|
93
|
+
#####Download Ubuntu 10.04 server cloud image from http://cloud-images.ubuntu.com
|
94
|
+
|
95
|
+
```
|
96
|
+
|
97
|
+
wget http://cloud-images.ubuntu.com/lucid/current/lucid-server-cloudimg-amd64-disk1.img
|
98
|
+
|
99
|
+
```
|
100
|
+
|
101
|
+
#####Add image in OpenStack
|
102
|
+
|
103
|
+
```
|
104
|
+
|
105
|
+
$ name=Ubuntu_10.04
|
106
|
+
$ image=lucid-server-cloudimg-amd64-disk1.img
|
107
|
+
$ glance image-create --name=$name --is-public=true --container-format=bare --disk-format=qcow2 < $image
|
108
|
+
|
109
|
+
```
|
110
|
+
|
111
|
+
#####Add flavor [Make sure to add ephemeral disk as shown]
|
112
|
+
|
113
|
+
```
|
114
|
+
|
115
|
+
$ nova flavor-create m1.bosh 6 2048 20 2 --ephemeral 20 --rxtx-factor 1 --is-public true
|
116
|
+
|
117
|
+
```
|
118
|
+
|
119
|
+
#####Also, install ruby 1.9.3. Use rvm or any other method.
|
120
|
+
|
121
|
+
#####Generate keypair (OPTIONAL)
|
122
|
+
######Note :
|
123
|
+
As of 0.8+ bosh-bootstrap deploy uses openstack/aws to create a dedicated keypair and its stored in ~/.bosh_bootstrap/ssh/inception
|
124
|
+
|
125
|
+
```
|
126
|
+
|
127
|
+
ssh-keygen
|
128
|
+
|
129
|
+
```
|
130
|
+
#####Set up git
|
131
|
+
|
132
|
+
```
|
133
|
+
|
134
|
+
git config --global user.name "Your Name Here"
|
135
|
+
git config --global user.email "your_email@example.com"
|
136
|
+
|
137
|
+
```
|
138
|
+
|
139
|
+
We are done preparing the IaaS(OpenStack) part. Now lets move up the stack.
|
140
|
+
|
141
|
+
##Play with bosh-bootstrap
|
142
|
+
|
143
|
+
#####Download Gem
|
144
|
+
|
145
|
+
```
|
146
|
+
|
147
|
+
gem install bosh-bootstrap
|
148
|
+
|
149
|
+
```
|
150
|
+
|
151
|
+
#####bosh-bootstrap is designed to boot instance with 32GB inception VM and 16GB for BOSH server.
|
152
|
+
For testing/development purpose, we will scale down the requirements(for devstack) to 3GB and 2GB respectively. Or change as per your requirements
|
153
|
+
|
154
|
+
```
|
155
|
+
|
156
|
+
export BOSH_VOLUME_SIZE=2 OR export MICROBOSH_VOLUME_SIZE=2 OR export MICRO_BOSH_VOLUME_SIZE=2
|
157
|
+
|
158
|
+
```
|
159
|
+
|
160
|
+
Run
|
161
|
+
|
162
|
+
```
|
163
|
+
|
164
|
+
INCEPTION_VOLUME_SIZE=3 bosh-bootstrap deploy
|
165
|
+
|
166
|
+
```
|
167
|
+
|
168
|
+
#####Start bootstrapping
|
169
|
+
Deploy
|
170
|
+
|
171
|
+
```
|
172
|
+
|
173
|
+
bosh-bootstrap deploy
|
174
|
+
|
175
|
+
```
|
176
|
+
|
177
|
+
Answer few questions asked by bosh-bootstrap in the initial stages and then, sit back and relax (hopefully!)
|
178
|
+
|
179
|
+
```
|
180
|
+
|
181
|
+
Stage 1: Choose infrastructure
|
182
|
+
Stage 2: BOSH configuration
|
183
|
+
Stage 3: Create/Allocate the Inception VM
|
184
|
+
Stage 4: Preparing the Inception VM
|
185
|
+
Stage 5: Deploying micro BOSH
|
186
|
+
Stage 6: Setup bosh
|
187
|
+
|
188
|
+
```
|
189
|
+
|
190
|
+
######Notes:
|
191
|
+
|
192
|
+
a) If the process fails in between due to some reason, you can restart bootstrapping after correcting the error, bootstrapping will continue from the point where it failed instead of from the beginning.
|
193
|
+
|
194
|
+
b) If you want to start the process from the beginning, delete "~/.bosh-boostrap/manifest.yml" file.
|
195
|
+
|
196
|
+
c) In case, the Inception VM fails to connect to internet or bosh-bootstrap is unable to mount volume to the instance, then the most probable reason is due to floating ip.Then
|
197
|
+
|
198
|
+
```
|
199
|
+
|
200
|
+
Disassociate floating IP from the OpenStack dashboard.
|
201
|
+
|
202
|
+
Edit "~/.bosh-bootstrap/manifest.yml" file and change the public IP to fixed IP of the instance.
|
203
|
+
|
204
|
+
Redeploy bosh-bootstrap
|
205
|
+
|
206
|
+
```
|
207
|
+
|
208
|
+
#####Finishing bootstrap
|
209
|
+
|
210
|
+
i) If everything goes fine, you can see the list of VMs created by bosh-bootstrap. Also you can ssh into the inception VM by "bosh-bootstrap ssh". Check BOSH status and so on.
|
211
|
+
|
212
|
+
ii) You can see the list of commands by executing "bosh-bootstrap help"
|
213
|
+
|
214
|
+
iii) In case, you face any issue please raise a [ticket](https://github.com/StarkAndWayne/bosh-bootstrap/issues).
|
215
|
+
|
data/lib/bosh-bootstrap/cli.rb
CHANGED
@@ -28,6 +28,7 @@ module Bosh::Bootstrap
|
|
28
28
|
method_option :"edge", :type => :boolean, :desc => "Use pre-built gems; create microbosh from source [temporary default]"
|
29
29
|
method_option :fog, :type => :string, :desc => "fog config file (default: ~/.fog)"
|
30
30
|
method_option :"upgrade-deps", :type => :boolean, :desc => "Force upgrade dependencies, packages & gems"
|
31
|
+
method_option :"create-inception", :type => :boolean, :desc => "Choose to create an inception VM"
|
31
32
|
def deploy
|
32
33
|
migrate_old_settings
|
33
34
|
load_deploy_options # from method_options above
|
@@ -39,8 +40,9 @@ module Bosh::Bootstrap
|
|
39
40
|
deploy_stage_3_create_allocate_inception_vm
|
40
41
|
deploy_stage_4_prepare_inception_vm
|
41
42
|
deploy_stage_5_salted_password
|
42
|
-
|
43
|
-
|
43
|
+
deploy_stage_6_download_micro_bosh
|
44
|
+
deploy_stage_7_deploy_micro_bosh
|
45
|
+
deploy_stage_8_setup_new_bosh
|
44
46
|
end
|
45
47
|
|
46
48
|
desc "upgrade-inception", "Upgrade inception VM with latest packages, gems, security group ports"
|
@@ -102,6 +104,13 @@ module Bosh::Bootstrap
|
|
102
104
|
DEFAULT_MICROBOSH_VOLUME_SIZE = 16 # Gb
|
103
105
|
|
104
106
|
def deploy_stage_1_choose_infrastructure_provider
|
107
|
+
settings["git"] ||= {}
|
108
|
+
settings["git"]["name"] ||= `git config user.name`.strip
|
109
|
+
settings["git"]["email"] ||= `git config user.email`.strip
|
110
|
+
if settings["git"]["name"].empty? || settings["git"]["email"].empty?
|
111
|
+
error "Checking for git identity....Cannot find your git identity. Please set git user.name and user.email before deploying"
|
112
|
+
end
|
113
|
+
|
105
114
|
header "Stage 1: Choose infrastructure"
|
106
115
|
unless settings[:fog_credentials]
|
107
116
|
choose_fog_provider
|
@@ -298,30 +307,40 @@ module Bosh::Bootstrap
|
|
298
307
|
end
|
299
308
|
end
|
300
309
|
|
301
|
-
def
|
302
|
-
header "Stage 6:
|
310
|
+
def deploy_stage_6_download_micro_bosh
|
311
|
+
header "Stage 6: Download micro BOSH"
|
303
312
|
recreate_local_ssh_keys_for_inception_vm
|
304
313
|
switch_to_prebuilt_microbosh_ami_if_available
|
305
314
|
|
306
|
-
unless run_server(Bosh::Bootstrap::Stages::
|
307
|
-
error "Failed to complete Stage 6:
|
315
|
+
unless run_server(Bosh::Bootstrap::Stages::MicroBoshDownload.new(settings).commands)
|
316
|
+
error "Failed to complete Stage 6: Downloading micro BOSH"
|
308
317
|
end
|
309
318
|
# Settings are updated by this stage
|
310
|
-
#
|
311
|
-
# and stores it in settings.bosh.salted_password
|
319
|
+
# It may update the micro_bosh_stemcell_name
|
312
320
|
save_settings!
|
313
321
|
|
314
322
|
confirm "Successfully built micro BOSH"
|
315
323
|
end
|
316
324
|
|
317
|
-
def
|
325
|
+
def deploy_stage_7_deploy_micro_bosh
|
326
|
+
header "Stage 7: Deploying micro BOSH"
|
327
|
+
recreate_local_ssh_keys_for_inception_vm
|
328
|
+
|
329
|
+
unless run_server(Bosh::Bootstrap::Stages::MicroBoshDeploy.new(settings).commands)
|
330
|
+
error "Failed to complete Stage 7: Deploying micro BOSH"
|
331
|
+
end
|
332
|
+
|
333
|
+
confirm "Successfully built micro BOSH"
|
334
|
+
end
|
335
|
+
|
336
|
+
def deploy_stage_8_setup_new_bosh
|
318
337
|
# TODO change to a polling test of director being available
|
319
338
|
say "Pausing to wait for BOSH Director..."
|
320
339
|
sleep 5
|
321
340
|
|
322
|
-
header "Stage
|
341
|
+
header "Stage 8: Setup bosh"
|
323
342
|
unless run_server(Bosh::Bootstrap::Stages::SetupNewBosh.new(settings).commands)
|
324
|
-
error "Failed to complete Stage
|
343
|
+
error "Failed to complete Stage 7: Setup bosh"
|
325
344
|
end
|
326
345
|
|
327
346
|
say "Locally targeting and login to new BOSH..."
|
@@ -495,30 +514,25 @@ module Bosh::Bootstrap
|
|
495
514
|
else
|
496
515
|
settings.delete("upgrade_deps")
|
497
516
|
end
|
517
|
+
|
518
|
+
if options["create-inception"]
|
519
|
+
settings["inception"] = {"create_new" => true}
|
520
|
+
end
|
498
521
|
save_settings!
|
499
522
|
end
|
500
523
|
|
501
524
|
def load_provider_specific_options
|
502
525
|
# before deploy stage - need to change type => ami if AWS us-east-1?
|
503
526
|
if options[:"edge-prebuilt"] || settings.delete("edge-prebuilt")
|
504
|
-
|
505
|
-
|
506
|
-
settings["micro_bosh_stemcell_name"] = "edge-prebuilt"
|
507
|
-
else
|
508
|
-
error "Currently --edge-prebuilt is not available for #{bosh_provider} :("
|
509
|
-
end
|
527
|
+
settings["micro_bosh_stemcell_type"] = "edge-prebuilt"
|
528
|
+
settings["micro_bosh_stemcell_name"] = "edge-prebuilt"
|
510
529
|
elsif options[:"edge"] || settings.delete("edge")
|
511
530
|
settings["micro_bosh_stemcell_type"] = "custom"
|
512
531
|
settings["micro_bosh_stemcell_name"] = "custom"
|
513
532
|
else
|
514
|
-
|
515
|
-
|
516
|
-
|
517
|
-
settings["micro_bosh_stemcell_name"] = "edge-prebuilt"
|
518
|
-
else
|
519
|
-
settings["micro_bosh_stemcell_type"] = "custom"
|
520
|
-
settings["micro_bosh_stemcell_name"] = "custom"
|
521
|
-
end
|
533
|
+
# currently defaulting to latest prebuilt stemcells/amis until 1.5.0 is released
|
534
|
+
settings["micro_bosh_stemcell_type"] = "edge-prebuilt"
|
535
|
+
settings["micro_bosh_stemcell_name"] = "edge-prebuilt"
|
522
536
|
end
|
523
537
|
end
|
524
538
|
|
@@ -657,9 +671,9 @@ module Bosh::Bootstrap
|
|
657
671
|
menu.choice("OpenStack") do
|
658
672
|
creds[:provider] = "OpenStack"
|
659
673
|
creds[:openstack_username] = hl.ask("Username: ")
|
660
|
-
creds[:openstack_api_key] = hl.ask("
|
674
|
+
creds[:openstack_api_key] = hl.ask("Password: ")
|
661
675
|
creds[:openstack_tenant] = hl.ask("Tenant: ")
|
662
|
-
creds[:openstack_auth_url] = hl.ask("Authorization URL: ")
|
676
|
+
creds[:openstack_auth_url] = hl.ask("Authorization Token URL: ")
|
663
677
|
end
|
664
678
|
end
|
665
679
|
@fog_credentials = creds
|
@@ -54,6 +54,9 @@ class Bosh::Bootstrap::Commander::RemoteServer
|
|
54
54
|
last_line = $1
|
55
55
|
# store output into a settings field, if requested
|
56
56
|
# TODO replace this with SettingsSetting#setting(settings_key, last_line.strip)
|
57
|
+
|
58
|
+
puts "Last line of script: #{last_line}"
|
59
|
+
puts "Storing to settings_key #{settings_key}" if settings_key
|
57
60
|
if settings_key
|
58
61
|
settings_key_portions = settings_key.split(".")
|
59
62
|
parent_key_portions, final_key = settings_key_portions[0..-2], settings_key_portions[-1]
|
@@ -64,6 +67,7 @@ class Bosh::Bootstrap::Commander::RemoteServer
|
|
64
67
|
end
|
65
68
|
target_settings_field[final_key] = last_line.strip
|
66
69
|
end
|
70
|
+
|
67
71
|
status
|
68
72
|
rescue StandardError => e
|
69
73
|
logfile.puts e.message
|
@@ -5,6 +5,7 @@ module Bosh; module Bootstrap; module Helpers; end; end; end
|
|
5
5
|
|
6
6
|
# Helper methods for loading/saving settings
|
7
7
|
module Bosh::Bootstrap::Helpers::Settings
|
8
|
+
|
8
9
|
# Previously selected settings are stored in a YAML manifest
|
9
10
|
# Protects the manifest file with user-only priveleges
|
10
11
|
def settings
|
@@ -13,12 +13,6 @@ module Bosh::Bootstrap::Stages
|
|
13
13
|
settings[:bosh_name] ||= "unnamed_bosh"
|
14
14
|
|
15
15
|
@commands ||= Bosh::Bootstrap::Commander::Commands.new do |server|
|
16
|
-
server.download "micro-bosh stemcell", script("download_micro_bosh_stemcell",
|
17
|
-
"MICRO_BOSH_STEMCELL_NAME" => settings.micro_bosh_stemcell_name,
|
18
|
-
"MICRO_BOSH_STEMCELL_TYPE" => settings.micro_bosh_stemcell_type,
|
19
|
-
"PROVIDER" => settings.bosh_provider),
|
20
|
-
:settings => settings,
|
21
|
-
:save_output_to_settings_key => "micro_bosh_stemcell_name"
|
22
16
|
server.upload_file \
|
23
17
|
"/var/vcap/store/microboshes/deployments/#{settings.bosh_name}/micro_bosh.yml",
|
24
18
|
micro_bosh_manifest
|
@@ -6,9 +6,9 @@
|
|
6
6
|
# * $MICRO_BOSH_STEMCELL_NAME - public stemcell name to be downloaded
|
7
7
|
# - if 'custom' the create stemcell from BOSH source
|
8
8
|
# * $MICRO_BOSH_STEMCELL_TYPE - what type of stemcell (ami vs tgz)
|
9
|
+
# * $PROVIDER - e.g. aws, openstack
|
9
10
|
#
|
10
11
|
# Optional:
|
11
|
-
# * $PROVIDER - required for 'custom' $MICRO_BOSH_STEMCELL_NAME; e.g. aws, openstack
|
12
12
|
# * $ISO_NAME - defaults to ubuntu-10.04.4-server-amd64.iso for creating stemcell
|
13
13
|
|
14
14
|
set -e # exit immediately if a simple command exits with a non-zero status
|
@@ -20,7 +20,7 @@ if [[ "${MICRO_BOSH_STEMCELL_NAME}X" == "X" ]]; then
|
|
20
20
|
fi
|
21
21
|
|
22
22
|
STEMCELLS_DIR=/var/vcap/store/stemcells
|
23
|
-
LAST_SUCCESSFUL_MICROBOSH_STEMCELL_URL=http://bosh-jenkins-artifacts.s3.amazonaws.com/last_successful_micro-bosh-stemcell.tgz
|
23
|
+
LAST_SUCCESSFUL_MICROBOSH_STEMCELL_URL=http://bosh-jenkins-artifacts.s3.amazonaws.com/last_successful_micro-bosh-stemcell-$PROVIDER.tgz
|
24
24
|
|
25
25
|
if [[ "${MICRO_BOSH_STEMCELL_NAME}" == "custom" ]]; then
|
26
26
|
|
@@ -66,8 +66,15 @@ if [[ "${MICRO_BOSH_STEMCELL_NAME}" == "custom" ]]; then
|
|
66
66
|
|
67
67
|
elif [[ "${MICRO_BOSH_STEMCELL_TYPE}" == "edge-prebuilt" ]]; then
|
68
68
|
cd $STEMCELLS_DIR
|
69
|
-
|
70
|
-
|
69
|
+
echo Looking for latest microbosh stemcell at $LAST_SUCCESSFUL_MICROBOSH_STEMCELL_URL
|
70
|
+
etag=$(curl -I $LAST_SUCCESSFUL_MICROBOSH_STEMCELL_URL 2>&1 | awk '/^ETag/ {print $2}' | sed -e 's/"//g')
|
71
|
+
MICRO_BOSH_STEMCELL_NAME="micro_bosh-${etag}-latest.tgz"
|
72
|
+
if [[ ! -f $MICRO_BOSH_STEMCELL_NAME ]]; then
|
73
|
+
echo "Downloading latest microbosh stemcell, etag $etag..."
|
74
|
+
curl -o $MICRO_BOSH_STEMCELL_NAME $LAST_SUCCESSFUL_MICROBOSH_STEMCELL_URL
|
75
|
+
else
|
76
|
+
echo "Latest microbosh stemcell with etag $etag already downloaded, skipping."
|
77
|
+
fi
|
71
78
|
|
72
79
|
elif [[ "${MICRO_BOSH_STEMCELL_TYPE}" == "ami" ]]; then
|
73
80
|
echo "Using AMI ${MICRO_BOSH_STEMCELL_NAME}, so there is nothing to download."
|
@@ -0,0 +1,139 @@
|
|
1
|
+
require "json" # for inline hashes within YAML
|
2
|
+
|
3
|
+
module Bosh::Bootstrap::Stages
|
4
|
+
class MicroBoshDownload
|
5
|
+
attr_reader :settings
|
6
|
+
|
7
|
+
def initialize(settings)
|
8
|
+
@settings = settings
|
9
|
+
end
|
10
|
+
|
11
|
+
# TODO "aws_us_east_1" should come from settings.bosh_name
|
12
|
+
def commands
|
13
|
+
settings[:bosh_name] ||= "unnamed_bosh"
|
14
|
+
|
15
|
+
@commands ||= Bosh::Bootstrap::Commander::Commands.new do |server|
|
16
|
+
server.download "micro-bosh stemcell", script("download_micro_bosh_stemcell",
|
17
|
+
"MICRO_BOSH_STEMCELL_NAME" => settings.micro_bosh_stemcell_name,
|
18
|
+
"MICRO_BOSH_STEMCELL_TYPE" => settings.micro_bosh_stemcell_type,
|
19
|
+
"PROVIDER" => settings.bosh_provider),
|
20
|
+
:settings => settings,
|
21
|
+
:save_output_to_settings_key => "micro_bosh_stemcell_name"
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def stage_name
|
26
|
+
"stage_micro_bosh_download"
|
27
|
+
end
|
28
|
+
|
29
|
+
# Loads local script
|
30
|
+
# If +variables+, then injects KEY=VALUE environment
|
31
|
+
# variables into bash scripts.
|
32
|
+
def script(segment_name, variables={})
|
33
|
+
path = File.expand_path("../#{stage_name}/#{segment_name}", __FILE__)
|
34
|
+
if File.exist?(path)
|
35
|
+
script = File.read(path)
|
36
|
+
if variables.keys.size > 0
|
37
|
+
env_variables = variables.reject { |var| var.is_a?(Symbol) }
|
38
|
+
|
39
|
+
# inject variables into script if its bash script
|
40
|
+
inline_variables = "#!/usr/bin/env bash\n\n"
|
41
|
+
env_variables.each { |name, value| inline_variables << "#{name}='#{value}'\n" }
|
42
|
+
script.gsub!("#!/usr/bin/env bash", inline_variables)
|
43
|
+
|
44
|
+
# inject variables into script if its ruby script
|
45
|
+
inline_variables = "#!/usr/bin/env ruby\n\n"
|
46
|
+
env_variables.each { |name, value| inline_variables << "ENV['#{name}'] = '#{value}'\n" }
|
47
|
+
script.gsub!("#!/usr/bin/env ruby", inline_variables)
|
48
|
+
end
|
49
|
+
script
|
50
|
+
else
|
51
|
+
Thor::Base.shell.new.say_status "error", "Missing script lib/bosh-bootstrap/stages/#{stage_name}/#{segment_name}", :red
|
52
|
+
exit 1
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
def micro_bosh_manifest
|
57
|
+
name = settings.bosh_name
|
58
|
+
salted_password = settings.bosh.salted_password
|
59
|
+
ipaddress = settings.bosh.ip_address
|
60
|
+
persistent_disk = settings.bosh.persistent_disk
|
61
|
+
resources_cloud_properties = settings.bosh_resources_cloud_properties
|
62
|
+
cloud_plugin = settings.bosh_provider
|
63
|
+
|
64
|
+
# aws:
|
65
|
+
# access_key_id: #{access_key}
|
66
|
+
# secret_access_key: #{secret_key}
|
67
|
+
# ec2_endpoint: ec2.#{region}.amazonaws.com
|
68
|
+
# default_key_name: #{key_name}
|
69
|
+
# default_security_groups: ["#{security_group}"]
|
70
|
+
# ec2_private_key: /home/vcap/.ssh/#{key_name}.pem
|
71
|
+
cloud_properties = settings.bosh_cloud_properties
|
72
|
+
|
73
|
+
manifest = {
|
74
|
+
"name" => name,
|
75
|
+
"env" => { "bosh" => {"password" => salted_password}},
|
76
|
+
"logging" => { "level" => "DEBUG" },
|
77
|
+
"network" => { "type" => "dynamic", "vip" => ipaddress },
|
78
|
+
"resources" => {
|
79
|
+
"persistent_disk" => persistent_disk,
|
80
|
+
"cloud_properties" => resources_cloud_properties
|
81
|
+
},
|
82
|
+
"cloud" => {
|
83
|
+
"plugin" => cloud_plugin,
|
84
|
+
"properties" => cloud_properties
|
85
|
+
},
|
86
|
+
"apply_spec" => {
|
87
|
+
"agent" => {
|
88
|
+
"blobstore" => { "address" => ipaddress },
|
89
|
+
"nats" => { "address" => ipaddress }
|
90
|
+
},
|
91
|
+
"properties" => {
|
92
|
+
"#{cloud_plugin.downcase}_registry" => { "address" => ipaddress }
|
93
|
+
}
|
94
|
+
}
|
95
|
+
}
|
96
|
+
|
97
|
+
# Openstack settings
|
98
|
+
if cloud_plugin.downcase == "openstack"
|
99
|
+
# Delete OpenStack registry IP address
|
100
|
+
manifest["apply_spec"]["properties"].delete("openstack_registry")
|
101
|
+
|
102
|
+
# OpenStack private network label
|
103
|
+
if settings.network_label
|
104
|
+
manifest["network"]["label"] = settings.network_label
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
108
|
+
manifest.to_yaml.gsub(/\s![^ ]+$/, '')
|
109
|
+
|
110
|
+
# /![^ ]+\s/ removes object notation from the YAML which appears to cause problems when being interpretted by the
|
111
|
+
# Ruby running on the inception vm. A before and after example would look like;
|
112
|
+
#
|
113
|
+
# properties: !map:Settingslogic
|
114
|
+
# openstack: !map:Settingslogic
|
115
|
+
# username: admin
|
116
|
+
# api_key: xxxxxxxxxxxxxxxxxxx
|
117
|
+
# tenant: CloudFoundry
|
118
|
+
# auth_url: http://192.168.1.2:5000/v2.0/tokens
|
119
|
+
# default_security_groups:
|
120
|
+
# - !str:HighLine::String microbosh-openstack
|
121
|
+
# default_key_name: !str:HighLine::String microbosh-openstack
|
122
|
+
# private_key: /home/vcap/.ssh/microbosh-openstack.pem
|
123
|
+
#
|
124
|
+
# The regex strips the !Module::ClassName notation out and the result looks as it should
|
125
|
+
#
|
126
|
+
# properties:
|
127
|
+
# openstack:
|
128
|
+
# username: admin
|
129
|
+
# api_key: xxxxxxxxxxxxxxxxxxx
|
130
|
+
# tenant: CloudFoundry
|
131
|
+
# auth_url: http://192.168.1.2:5000/v2.0/tokens
|
132
|
+
# default_security_groups:
|
133
|
+
# - microbosh-openstack
|
134
|
+
# default_key_name: microbosh-openstack
|
135
|
+
# private_key: /home/vcap/.ssh/microbosh-openstack.pem
|
136
|
+
|
137
|
+
end
|
138
|
+
end
|
139
|
+
end
|
@@ -3,6 +3,7 @@ end
|
|
3
3
|
|
4
4
|
require "bosh-bootstrap/stages/stage_validate_inception_vm"
|
5
5
|
require "bosh-bootstrap/stages/stage_prepare_inception_vm"
|
6
|
+
require "bosh-bootstrap/stages/stage_micro_bosh_download"
|
6
7
|
require "bosh-bootstrap/stages/stage_micro_bosh_deploy"
|
7
8
|
require "bosh-bootstrap/stages/stage_setup_new_bosh"
|
8
9
|
require "bosh-bootstrap/stages/stage_salted_password"
|
data/spec/unit/aws_spec.rb
CHANGED
@@ -64,7 +64,7 @@ describe "AWS deployment" do
|
|
64
64
|
@cmd.should_receive(:provision_and_mount_volume)
|
65
65
|
@cmd.stub(:run_server).and_return(true)
|
66
66
|
@cmd.stub(:sleep)
|
67
|
-
@cmd.should_receive(:
|
67
|
+
@cmd.should_receive(:deploy_stage_8_setup_new_bosh)
|
68
68
|
@cmd.deploy
|
69
69
|
|
70
70
|
fog.addresses.should have(1).item # assigned to inception VM
|
@@ -118,7 +118,7 @@ describe "AWS deployment" do
|
|
118
118
|
@cmd.should_receive(:provision_and_mount_volume)
|
119
119
|
@cmd.stub(:run_server).and_return(true)
|
120
120
|
@cmd.stub(:sleep)
|
121
|
-
@cmd.should_receive(:
|
121
|
+
@cmd.should_receive(:deploy_stage_8_setup_new_bosh)
|
122
122
|
@cmd.deploy
|
123
123
|
@settings = nil # reload settings file
|
124
124
|
|
@@ -161,7 +161,7 @@ describe "AWS deployment" do
|
|
161
161
|
@cmd.should_receive(:provision_and_mount_volume)
|
162
162
|
@cmd.stub(:run_server).and_return(true)
|
163
163
|
@cmd.stub(:sleep)
|
164
|
-
@cmd.should_receive(:
|
164
|
+
@cmd.should_receive(:deploy_stage_8_setup_new_bosh)
|
165
165
|
@cmd.should_receive(:latest_prebuilt_microbosh_ami).and_return("ami-123456")
|
166
166
|
|
167
167
|
setting "edge-prebuilt", true
|
data/spec/unit/cli_spec.rb
CHANGED
@@ -21,8 +21,9 @@ describe Bosh::Bootstrap do
|
|
21
21
|
deploy_stage_3_create_allocate_inception_vm
|
22
22
|
deploy_stage_4_prepare_inception_vm
|
23
23
|
deploy_stage_5_salted_password
|
24
|
-
|
25
|
-
|
24
|
+
deploy_stage_6_download_micro_bosh
|
25
|
+
deploy_stage_7_deploy_micro_bosh
|
26
|
+
deploy_stage_8_setup_new_bosh
|
26
27
|
]
|
27
28
|
stage_methods.each do |method|
|
28
29
|
unless method =~ /#{stage}/
|
@@ -43,8 +44,9 @@ describe Bosh::Bootstrap do
|
|
43
44
|
@cmd.should_receive(:deploy_stage_3_create_allocate_inception_vm)
|
44
45
|
@cmd.should_receive(:deploy_stage_4_prepare_inception_vm)
|
45
46
|
@cmd.should_receive(:deploy_stage_5_salted_password)
|
46
|
-
@cmd.should_receive(:
|
47
|
-
@cmd.should_receive(:
|
47
|
+
@cmd.should_receive(:deploy_stage_6_download_micro_bosh)
|
48
|
+
@cmd.should_receive(:deploy_stage_7_deploy_micro_bosh)
|
49
|
+
@cmd.should_receive(:deploy_stage_8_setup_new_bosh)
|
48
50
|
@cmd.deploy
|
49
51
|
end
|
50
52
|
|
@@ -68,8 +70,8 @@ describe Bosh::Bootstrap do
|
|
68
70
|
@cmd.deploy
|
69
71
|
end
|
70
72
|
|
71
|
-
it "stage
|
72
|
-
testing_stage(
|
73
|
+
it "stage 7 - deploy microbosh" do
|
74
|
+
testing_stage(7)
|
73
75
|
@cmd.should_receive(:recreate_local_ssh_keys_for_inception_vm)
|
74
76
|
setting "bosh_provider", "aws"
|
75
77
|
setting "micro_bosh_stemcell_name", "micro-bosh-stemcell-aws-0.8.1.tgz"
|
@@ -86,8 +88,8 @@ describe Bosh::Bootstrap do
|
|
86
88
|
@cmd.deploy
|
87
89
|
end
|
88
90
|
|
89
|
-
it "stage
|
90
|
-
testing_stage(
|
91
|
+
it "stage 8 - sets up new microbosh" do
|
92
|
+
testing_stage(8)
|
91
93
|
setting "bosh_name", "microbosh-aws-us-east-1"
|
92
94
|
setting "bosh_username", "drnic"
|
93
95
|
setting "bosh_password", "password"
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bosh-bootstrap
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.10.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-04-
|
12
|
+
date: 2013-04-20 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: thor
|
@@ -231,6 +231,7 @@ files:
|
|
231
231
|
- .rspec
|
232
232
|
- .travis.yml
|
233
233
|
- ChangeLog.md
|
234
|
+
- CleanupCi.md
|
234
235
|
- Gemfile
|
235
236
|
- Guardfile
|
236
237
|
- LICENSE.txt
|
@@ -238,6 +239,8 @@ files:
|
|
238
239
|
- Rakefile
|
239
240
|
- bin/bosh-bootstrap
|
240
241
|
- bosh-bootstrap.gemspec
|
242
|
+
- docs/README.md
|
243
|
+
- docs/devstack-openstack-tutorial.md
|
241
244
|
- lib/bosh-bootstrap.rb
|
242
245
|
- lib/bosh-bootstrap/cli.rb
|
243
246
|
- lib/bosh-bootstrap/commander.rb
|
@@ -257,8 +260,9 @@ files:
|
|
257
260
|
- lib/bosh-bootstrap/stages/stage_micro_bosh_delete/bosh_micro_delete
|
258
261
|
- lib/bosh-bootstrap/stages/stage_micro_bosh_deploy.rb
|
259
262
|
- lib/bosh-bootstrap/stages/stage_micro_bosh_deploy/bosh_micro_deploy
|
260
|
-
- lib/bosh-bootstrap/stages/stage_micro_bosh_deploy/download_micro_bosh_stemcell
|
261
263
|
- lib/bosh-bootstrap/stages/stage_micro_bosh_deploy/install_key_pair_for_user
|
264
|
+
- lib/bosh-bootstrap/stages/stage_micro_bosh_download.rb
|
265
|
+
- lib/bosh-bootstrap/stages/stage_micro_bosh_download/download_micro_bosh_stemcell
|
262
266
|
- lib/bosh-bootstrap/stages/stage_prepare_inception_vm.rb
|
263
267
|
- lib/bosh-bootstrap/stages/stage_prepare_inception_vm/configure_git
|
264
268
|
- lib/bosh-bootstrap/stages/stage_prepare_inception_vm/create_vcap_user
|
@@ -308,16 +312,16 @@ files:
|
|
308
312
|
- vendor/cache/blobstore_client-0.4.0.gem
|
309
313
|
- vendor/cache/bosh_cli-1.0.3.gem
|
310
314
|
- vendor/cache/bosh_common-0.5.4.gem
|
311
|
-
- vendor/cache/builder-3.
|
315
|
+
- vendor/cache/builder-3.2.0.gem
|
312
316
|
- vendor/cache/coderay-1.0.8.gem
|
313
317
|
- vendor/cache/diff-lcs-1.1.3.gem
|
314
318
|
- vendor/cache/escape-0.0.4.gem
|
315
|
-
- vendor/cache/excon-0.
|
319
|
+
- vendor/cache/excon-0.20.1.gem
|
316
320
|
- vendor/cache/fog-1.8.0.gem
|
317
321
|
- vendor/cache/formatador-0.2.4.gem
|
318
322
|
- vendor/cache/guard-1.6.2.gem
|
319
323
|
- vendor/cache/guard-rspec-2.4.0.gem
|
320
|
-
- vendor/cache/highline-1.6.
|
324
|
+
- vendor/cache/highline-1.6.18.gem
|
321
325
|
- vendor/cache/httpclient-2.2.4.gem
|
322
326
|
- vendor/cache/i18n-0.6.1.gem
|
323
327
|
- vendor/cache/json_pure-1.6.8.gem
|
@@ -325,14 +329,13 @@ files:
|
|
325
329
|
- vendor/cache/log4r-1.1.10.gem
|
326
330
|
- vendor/cache/lumberjack-1.0.2.gem
|
327
331
|
- vendor/cache/method_source-0.8.1.gem
|
328
|
-
- vendor/cache/mime-types-1.
|
332
|
+
- vendor/cache/mime-types-1.22.gem
|
329
333
|
- vendor/cache/multi_json-1.1.0.gem
|
330
334
|
- vendor/cache/net-scp-1.0.4.gem
|
331
335
|
- vendor/cache/net-ssh-2.2.2.gem
|
332
336
|
- vendor/cache/net-ssh-gateway-1.1.0.gem
|
333
337
|
- vendor/cache/netaddr-1.5.0.gem
|
334
|
-
- vendor/cache/nokogiri-1.5.
|
335
|
-
- vendor/cache/nokogiri-1.5.6.gem
|
338
|
+
- vendor/cache/nokogiri-1.5.9.gem
|
336
339
|
- vendor/cache/open4-1.3.0.gem
|
337
340
|
- vendor/cache/progressbar-0.9.2.gem
|
338
341
|
- vendor/cache/pry-0.9.11.4-java.gem
|
@@ -373,7 +376,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
373
376
|
version: '0'
|
374
377
|
segments:
|
375
378
|
- 0
|
376
|
-
hash:
|
379
|
+
hash: 1266362034070709822
|
377
380
|
requirements: []
|
378
381
|
rubyforge_project:
|
379
382
|
rubygems_version: 1.8.25
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|