forked from cloudfoundry-community/bosh-lite-demo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbosh-lite-cloudfoundry-demo
executable file
·189 lines (151 loc) · 4.61 KB
/
bosh-lite-cloudfoundry-demo
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
#!/usr/bin/env bash
##
## This script boots up bosh-lite in a local Vagrant/Virtualbox VM,
## then uploads and deploys Cloud Foundry into it.
## Finally, it logs into Cloud Foundry as an admin user,
## creates an initial organization and space,
## then deploys an example application.
##
set +x
##
## Dependency locations
##
BOSH_LITE_REPO=${BOSH_LITE_REPO:-https://github.com/cloudfoundry/bosh-lite.git}
RELEASE_VERSION=${RELEASE_VERSION:-154}
RELEASE_TGZ_URL=${RELEASE_TGZ:-https://github.com/cloudfoundry/cf-release/archive/v$RELEASE_VERSION.tar.gz}
STEMCELL_NAME=${STEMCELL_NAME:-bosh-stemcell-24-warden-boshlite-ubuntu.tgz}
APPLICATION_URL=${APPLICATION_URL:-https://github.com/cloudfoundry-community/cf-env.git}
APPLICATION_NAME=${APPLICATION_NAME:-cf-env}
WORKSPACE_DIR=${WORKSPACE_DIR:-$HOME/bosh-lite-tutorial}
PROJECT_NAME=cf-release
RELEASE_NAME=cf
RELEASE_DIR=$WORKSPACE_DIR/$PROJECT_NAME-$RELEASE_VERSION
SOURCE_RELEASE_TGZ=$WORKSPACE_DIR/$PROJECT_NAME-v$RELEASE_VERSION.tar.gz
FINAL_RELEASE_TGZ=$RELEASE_DIR/releases/$RELEASE_NAME-$RELEASE_VERSION.tgz
##
## Verify local requirements
##
if [[ "${SKIP_VERIFY}X" == "X" ]]; then
set +e
echo Required dependencies: ruby 1.9.3, vagrant 1.4+, git 1.7+, wget, spiff 0.3+, gcf 6.0+
echo
ruby_installed=$(which ruby)
ruby -v
echo
vagrant_installed=$(which vagrant)
vagrant -v
echo
git_installed=$(which git)
git --version
echo
wget_installed=$(which wget)
wget --version | head -n1
echo
spiff_installed=$(which spiff)
spiff --version
echo
cf_installed=$(which gcf)
gcf --version
echo
if [[ "${ruby_installed}X" == "X" || "${vagrant_installed}X" == "X" || "${git_installed}X" == "X" || "${wget_installed}" == "X" || "${spiff_installed}X" == "X" || "${cf_installed}X" == "X" ]]; then
echo Please install the missing dependencies above.
echo
if [[ "${ruby_installed}X" == "X" ]]; then
echo ruby - http://rvm.io
fi
if [[ "${vagrant_installed}X" == "X" ]]; then
echo vagrant - http://www.vagrantup.com/downloads.html
fi
if [[ "${spiff_installed}X" == "X" ]]; then
echo spiff - https://github.com/cloudfoundry-incubator/spiff/releases
fi
if [[ "${cf_installed}X" == "X" ]]; then
echo gcf - https://github.com/cloudfoundry/cli#downloading-edge
fi
exit 1
fi
echo Press [ENTER] if your versions are ok, else Ctrl-C to cancel and manually install them.
read
##
## Workspace setup
##
echo Will use $WORKSPACE_DIR for this demo. Press [ENTER] or re-run with \$WORKSPACE_DIR set.
read
fi
set -e # exit on error
set -x # show commands being run
mkdir -p $WORKSPACE_DIR
cd $WORKSPACE_DIR
cd $WORKSPACE_DIR
if [[ ! -f Gemfile ]]; then
echo "source 'https://rubygems.org'; gem 'bosh_cli'" > Gemfile
bundle install
fi
if [[ ! -f $SOURCE_RELEASE_TGZ ]]; then
wget $RELEASE_TGZ_URL -O $SOURCE_RELEASE_TGZ
fi
if [[ ! -d $RELEASE_DIR ]]; then
tar xfz $SOURCE_RELEASE_TGZ
cd $RELEASE_DIR
bundle install
fi
if [[ ! -f $FINAL_RELEASE_TGZ ]]; then
cd $RELEASE_DIR
rm -f Gemfile*
bundle exec bosh create release --force --with-tarball releases/cf-$RELEASE_VERSION.yml
fi
cd $WORKSPACE_DIR
if [[ ! -d bosh-lite ]]; then
set -x
git clone $BOSH_LITE_REPO bosh-lite
cd bosh-lite
rm -f Gemfile*
set +x
fi
cd $WORKSPACE_DIR
if [[ ! -f $STEMCELL_NAME ]]; then
bundle exec bosh download public stemcell $STEMCELL_NAME
fi
cd $WORKSPACE_DIR/bosh-lite
if [[ "${NO_REBUILD}X" == "X" ]]; then
vagrant destroy -f
fi
vagrant up
set +e # do not exit on error; allow these to fail if already performed
yes admin | bosh target https://192.168.50.4:25555
bosh upload release $FINAL_RELEASE_TGZ
bosh upload stemcell $WORKSPACE_DIR/$STEMCELL_NAME
set -e # exit on error
# specifically for cf-release/bosh-lite need to setup $CF_RELEASE_DIR
export CF_RELEASE_DIR=${RELEASE_DIR}
scripts/make_manifest_spiff
# Parallelise the deployment!
echo " serial: false" >> manifests/cf-manifest.yml
##
## Deploy Cloud Foundry into our BOSH (bosh-lite)
##
bosh -n deploy
bosh status
bosh vms
##
## Setup Cloud Foundry
##
cd $WORKSPACE_DIR/bosh-lite
./scripts/add-route # to access 10.244.0.34 via host machine
gcf api https://api.10.244.0.34.xip.io
gcf auth admin admin
gcf create-org me
gcf target -o me
gcf create-space test
gcf target -s test
##
## Deploy example application
##
cd $WORKSPACE_DIR
if [[ ! -d $APPLICATION_NAME ]]; then
git clone $APPLICATION_URL $APPLICATION_NAME
fi
cd $APPLICATION_NAME
bundle
gcf push $APPLICATION_NAME
gcf apps