cucumber-chef 1.0.3 → 2.0.0.pre
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +8 -35
- data/.rspec +1 -0
- data/.rvmrc.template +2 -0
- data/.travis.yml +22 -0
- data/Gemfile +2 -15
- data/LICENSE +202 -201
- data/NOTICE +9 -0
- data/README.md +696 -92
- data/Rakefile +39 -25
- data/TODO.md +28 -0
- data/bin/cc-knife +32 -0
- data/bin/cucumber-chef +409 -79
- data/chef_repo/cookbooks/cucumber-chef/LICENSE +202 -0
- data/chef_repo/cookbooks/cucumber-chef/README.md +69 -0
- data/chef_repo/cookbooks/cucumber-chef/attributes/default.rb +27 -0
- data/chef_repo/cookbooks/cucumber-chef/metadata.rb +13 -0
- data/chef_repo/cookbooks/cucumber-chef/recipes/default.rb +23 -0
- data/chef_repo/cookbooks/cucumber-chef/recipes/lxc.rb +315 -0
- data/chef_repo/cookbooks/cucumber-chef/recipes/test_lab.rb +146 -0
- data/chef_repo/cookbooks/cucumber-chef/templates/default/db-168-192.erb +15 -0
- data/chef_repo/cookbooks/cucumber-chef/templates/default/db-test-lab.erb +15 -0
- data/chef_repo/cookbooks/cucumber-chef/templates/default/dhcpd-conf.erb +44 -0
- data/chef_repo/cookbooks/cucumber-chef/templates/default/gemrc.erb +10 -0
- data/{cookbooks/cucumber-chef/files/default/cucumber-net → chef_repo/cookbooks/cucumber-chef/templates/default/lxc-initializer-config.erb} +1 -1
- data/chef_repo/cookbooks/cucumber-chef/templates/default/lxc-install-chef.erb +3 -0
- data/chef_repo/cookbooks/cucumber-chef/templates/default/motd.erb +10 -0
- data/chef_repo/cookbooks/cucumber-chef/templates/default/named-conf-local.erb +25 -0
- data/{cookbooks/cucumber-chef/files/default/permissive-ssh-config → chef_repo/cookbooks/cucumber-chef/templates/default/ssh-config.erb} +3 -1
- data/chef_repo/roles/test_lab.rb +24 -0
- data/cucumber-chef.gemspec +50 -123
- data/examples/README.md +7 -0
- data/examples/users_add.feature +51 -0
- data/examples/users_auto_remove.feature +50 -0
- data/features/support/env.rb +3 -2
- data/lib/cucumber/chef/bootstrap.rb +94 -0
- data/lib/cucumber/chef/command.rb +78 -0
- data/lib/cucumber/chef/config.rb +143 -93
- data/lib/cucumber/chef/helpers/chef_client.rb +87 -0
- data/lib/cucumber/chef/helpers/chef_server.rb +90 -0
- data/lib/cucumber/chef/helpers/command.rb +57 -0
- data/lib/cucumber/chef/helpers/container.rb +154 -0
- data/lib/cucumber/chef/helpers/minitest.rb +35 -0
- data/lib/cucumber/chef/helpers/server.rb +81 -0
- data/lib/cucumber/chef/helpers/test_lab.rb +46 -0
- data/lib/cucumber/chef/helpers/utility.rb +73 -0
- data/lib/cucumber/chef/helpers.rb +56 -0
- data/lib/cucumber/chef/logger.rb +90 -0
- data/lib/cucumber/chef/provisioner.rb +275 -69
- data/lib/cucumber/chef/ssh.rb +190 -0
- data/lib/cucumber/chef/steps/chef_steps.rb +32 -0
- data/lib/cucumber/chef/steps/minitest_steps.rb +29 -0
- data/lib/cucumber/chef/steps/provision_steps.rb +60 -0
- data/lib/cucumber/chef/steps/ssh_steps.rb +95 -0
- data/lib/cucumber/chef/steps.rb +27 -0
- data/lib/cucumber/chef/tcp_socket.rb +83 -0
- data/lib/cucumber/chef/template.rb +57 -0
- data/lib/cucumber/chef/templates/bootstrap/ubuntu-precise-test-lab.erb +99 -0
- data/lib/cucumber/chef/templates/cucumber/env.rb +56 -0
- data/lib/cucumber/chef/templates/cucumber/example_feature.erb +49 -0
- data/lib/cucumber/chef/templates/cucumber/example_steps.erb +11 -0
- data/lib/cucumber/chef/templates/cucumber/readme-data_bags.erb +1 -0
- data/lib/cucumber/chef/templates/cucumber/readme-keys.erb +1 -0
- data/lib/cucumber/chef/templates/cucumber/readme-roles.erb +1 -0
- data/lib/cucumber/chef/templates/cucumber/readme.erb +18 -0
- data/lib/cucumber/chef/templates/cucumber-chef/config-rb.erb +33 -0
- data/lib/cucumber/chef/templates/cucumber-chef/cucumber-yml.erb +2 -0
- data/lib/cucumber/chef/templates/cucumber-chef/knife-rb.erb +18 -0
- data/lib/cucumber/chef/test_lab.rb +308 -52
- data/lib/cucumber/chef/test_runner.rb +86 -15
- data/lib/cucumber/chef/utility.rb +128 -0
- data/lib/cucumber/chef/version.rb +30 -1
- data/lib/cucumber/chef.rb +53 -20
- data/lib/cucumber-chef.rb +24 -1
- data/spec/cucumber/chef/config_spec.rb +144 -78
- data/spec/cucumber/chef/provisioner_spec.rb +60 -16
- data/spec/cucumber/chef/test_lab_spec.rb +62 -19
- data/spec/spec_helper.rb +30 -26
- data/todo.org +17 -0
- metadata +267 -163
- data/.document +0 -5
- data/VERSION +0 -1
- data/cookbooks/cucumber-chef/README.rdoc +0 -8
- data/cookbooks/cucumber-chef/files/default/add-git-identity +0 -2
- data/cookbooks/cucumber-chef/files/default/controller-first-boot +0 -1
- data/cookbooks/cucumber-chef/files/default/cucumber-private-key +0 -27
- data/cookbooks/cucumber-chef/files/default/cucumber-run_list +0 -1
- data/cookbooks/cucumber-chef/files/default/git-private-key +0 -27
- data/cookbooks/cucumber-chef/files/default/install-chef +0 -1
- data/cookbooks/cucumber-chef/files/default/lxc-controller-network-config +0 -5
- data/cookbooks/cucumber-chef/files/default/lxc-lucid-chef +0 -378
- data/cookbooks/cucumber-chef/metadata.rb +0 -6
- data/cookbooks/cucumber-chef/recipes/controller.rb +0 -51
- data/cookbooks/cucumber-chef/recipes/lxc.rb +0 -35
- data/cookbooks/cucumber-chef/recipes/test_lab.rb +0 -23
- data/cookbooks/cucumber-chef/recipes/testrunner.rb +0 -46
- data/cookbooks/cucumber-chef/roles/controller.rb +0 -7
- data/cookbooks/cucumber-chef/roles/test_lab_test.rb +0 -9
- data/cookbooks/cucumber-chef/templates/default/controller-client.erb +0 -5
- data/cookbooks/cucumber-chef/templates/default/lxc-lucid-chef +0 -385
- data/lib/cucumber/chef/handy.rb +0 -90
- data/lib/cucumber/chef/templates/controller.erb +0 -35
- data/lib/cucumber/chef/templates/env.rb +0 -16
- data/lib/cucumber/chef/templates/example_feature.erb +0 -11
- data/lib/cucumber/chef/templates/example_step.erb +0 -19
- data/lib/cucumber/chef/templates/readme.erb +0 -14
- data/lib/cucumber/chef/templates/ubuntu10.04-gems.erb +0 -43
- data/lib/cucumber/ec2_server_create.rb +0 -99
- data/website/website.html +0 -385
@@ -1,378 +0,0 @@
|
|
1
|
-
|
2
|
-
#!/bin/bash
|
3
|
-
|
4
|
-
configure_ubuntu()
|
5
|
-
{
|
6
|
-
rootfs=$1
|
7
|
-
hostname=$2
|
8
|
-
|
9
|
-
# disable selinux in ubuntu
|
10
|
-
mkdir -p $rootfs/selinux
|
11
|
-
echo 0 > $rootfs/selinux/enforce
|
12
|
-
|
13
|
-
# set the hostname
|
14
|
-
cat <<EOF > $rootfs/etc/hostname
|
15
|
-
$hostname
|
16
|
-
EOF
|
17
|
-
# set minimal hosts
|
18
|
-
cat <<EOF > $rootfs/etc/hosts
|
19
|
-
127.0.0.1 localhost $hostname
|
20
|
-
EOF
|
21
|
-
|
22
|
-
# provide the lxc service
|
23
|
-
cat <<EOF > $rootfs/etc/init/lxc.conf
|
24
|
-
# fake some events needed for correct startup other services
|
25
|
-
|
26
|
-
description "Container Upstart"
|
27
|
-
|
28
|
-
start on startup
|
29
|
-
|
30
|
-
script
|
31
|
-
rm -rf /var/run/*.pid
|
32
|
-
rm -rf /var/run/network/*
|
33
|
-
/sbin/initctl emit stopped JOB=udevtrigger --no-wait
|
34
|
-
/sbin/initctl emit started JOB=udev --no-wait
|
35
|
-
end script
|
36
|
-
EOF
|
37
|
-
|
38
|
-
# fix buggus runlevel with sshd
|
39
|
-
cat <<EOF > $rootfs/etc/init/ssh.conf
|
40
|
-
# ssh - OpenBSD Secure Shell server
|
41
|
-
#
|
42
|
-
# The OpenSSH server provides secure shell access to the system.
|
43
|
-
|
44
|
-
description "OpenSSH server"
|
45
|
-
|
46
|
-
start on filesystem
|
47
|
-
stop on runlevel [!2345]
|
48
|
-
|
49
|
-
expect fork
|
50
|
-
respawn
|
51
|
-
respawn limit 10 5
|
52
|
-
umask 022
|
53
|
-
# replaces SSHD_OOM_ADJUST in /etc/default/ssh
|
54
|
-
oom never
|
55
|
-
|
56
|
-
pre-start script
|
57
|
-
test -x /usr/sbin/sshd || { stop; exit 0; }
|
58
|
-
test -e /etc/ssh/sshd_not_to_be_run && { stop; exit 0; }
|
59
|
-
test -c /dev/null || { stop; exit 0; }
|
60
|
-
|
61
|
-
mkdir -p -m0755 /var/run/sshd
|
62
|
-
end script
|
63
|
-
|
64
|
-
# if you used to set SSHD_OPTS in /etc/default/ssh, you can change the
|
65
|
-
# 'exec' line here instead
|
66
|
-
exec /usr/sbin/sshd
|
67
|
-
EOF
|
68
|
-
|
69
|
-
cat <<EOF > $rootfs/etc/init/console.conf
|
70
|
-
# console - getty
|
71
|
-
#
|
72
|
-
# This service maintains a console on tty1 from the point the system is
|
73
|
-
# started until it is shut down again.
|
74
|
-
|
75
|
-
start on stopped rc RUNLEVEL=[2345]
|
76
|
-
stop on runlevel [!2345]
|
77
|
-
|
78
|
-
respawn
|
79
|
-
exec /sbin/getty -8 38400 /dev/console
|
80
|
-
EOF
|
81
|
-
|
82
|
-
cat <<EOF > $rootfs/lib/init/fstab
|
83
|
-
# /lib/init/fstab: lxc system fstab
|
84
|
-
none /spu spufs gid=spu,optional 0 0
|
85
|
-
none /tmp none defaults 0 0
|
86
|
-
none /var/lock tmpfs nodev,noexec,nosuid,showthrough 0 0
|
87
|
-
none /lib/init/rw tmpfs mode=0755,nosuid,optional 0 0
|
88
|
-
EOF
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
# reconfigure some services
|
93
|
-
if [ -z "$LANG" ]; then
|
94
|
-
chroot $rootfs locale-gen en_US.UTF-8
|
95
|
-
chroot $rootfs update-locale LANG=en_US.UTF-8
|
96
|
-
else
|
97
|
-
chroot $rootfs locale-gen $LANG
|
98
|
-
chroot $rootfs update-locale LANG=$LANG
|
99
|
-
fi
|
100
|
-
|
101
|
-
# remove pointless services in a container
|
102
|
-
chroot $rootfs /usr/sbin/update-rc.d -f ondemand remove
|
103
|
-
|
104
|
-
chroot $rootfs /bin/bash -c 'cd /etc/init; for f in $(ls u*.conf); do mv $f $f.orig; done'
|
105
|
-
chroot $rootfs /bin/bash -c 'cd /etc/init; for f in $(ls tty[2-9].conf); do mv $f $f.orig; done'
|
106
|
-
chroot $rootfs /bin/bash -c 'cd /etc/init; for f in $(ls plymouth*.conf); do mv $f $f.orig; done'
|
107
|
-
chroot $rootfs /bin/bash -c 'cd /etc/init; for f in $(ls hwclock*.conf); do mv $f $f.orig; done'
|
108
|
-
chroot $rootfs /bin/bash -c 'cd /etc/init; for f in $(ls module*.conf); do mv $f $f.orig; done'
|
109
|
-
|
110
|
-
echo "Please change root-password !"
|
111
|
-
echo "root:root" | chroot $rootfs chpasswd
|
112
|
-
|
113
|
-
return 0
|
114
|
-
}
|
115
|
-
|
116
|
-
configure_image()
|
117
|
-
{
|
118
|
-
image=$cache/rootfs-$arch
|
119
|
-
mkdir $image/root/.ssh
|
120
|
-
chmod 0600 /root/.ssh
|
121
|
-
|
122
|
-
cat <<EOF > $image/etc/rc.local
|
123
|
-
#!/bin/sh -e
|
124
|
-
ip route add default via 192.168.20.1
|
125
|
-
exit 0
|
126
|
-
EOF
|
127
|
-
|
128
|
-
cat <<EOF > $image/root/.ssh/authorized_keys
|
129
|
-
ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAzj2O8BxvLn1Q7vUTiyFdtle9SeataEF//+651mXTV8WdKuXGRgvIKZPu+ZnTsqnDoR+pwMRFf95hDPHScpdYj2WVY1cN2e6xEKEsz3xcKdhaTuAOBd47J9wu6Nmgr1aZ/2/AWTrLEOMxUVVp/bzeSFzfHR2bctfKCKzMUCLGZLEGn0Yv5Qbk56Vr9A5jUJcKgCodWOpTcPlf+kKzxejgt/wHRZTRrJIOyx5Zhddim10/sZZ8ct9+WgBwhIL2fUHrsAb1wjxKpQCOYoxHuRSFnv4zrFzblI737TmQIHkkb9g08z3qIJLLiLKgGNXP2wclA37ctGfqwfJWj9FA9nI9iQ== root@cucumber
|
130
|
-
EOF
|
131
|
-
|
132
|
-
mkdir $image/etc/chef
|
133
|
-
|
134
|
-
cat <<EOF > $image/tmp/validation.pem
|
135
|
-
<%= IO.read(Chef::Config[:validation_key]) %>
|
136
|
-
EOF
|
137
|
-
awk NF $image/tmp/validation.pem > $image/etc/chef/validation.pem
|
138
|
-
rm $image/tmp/validation.pem
|
139
|
-
|
140
|
-
cat <<EOF > $image/etc/apt/sources.list.d/atalanta.list
|
141
|
-
deb http://packages.atalanta-systems.com lucid main
|
142
|
-
EOF
|
143
|
-
|
144
|
-
rm $image/etc/resolv.conf
|
145
|
-
cp /etc/resolv.conf $image/etc/resolv.conf
|
146
|
-
cp /etc/lxc/install-chef.sh $image/tmp/install-chef.sh
|
147
|
-
chroot $image /bin/sh -c "/usr/bin/apt-get update && /usr/bin/apt-get --assume-yes --allow-unauthenticated install ruby1.9.1p180"
|
148
|
-
mkdir -p $image/$HOME
|
149
|
-
chroot $image /bin/sh -c "/usr/local/bin/gem install ohai --no-ri --no-rdoc"
|
150
|
-
chroot $image /bin/sh -c "/usr/local/bin/gem install chef --no-ri --no-rdoc"
|
151
|
-
return $?
|
152
|
-
}
|
153
|
-
|
154
|
-
download_ubuntu()
|
155
|
-
{
|
156
|
-
packages=dialog,apt,apt-utils,resolvconf,iproute,inetutils-ping,dhcp3-client,ssh,lsb-release,wget,gpgv,gnupg
|
157
|
-
|
158
|
-
cache=$1
|
159
|
-
arch=$2
|
160
|
-
|
161
|
-
# check the mini ubuntu was not already downloaded
|
162
|
-
mkdir -p "$cache/partial-$arch"
|
163
|
-
if [ $? -ne 0 ]; then
|
164
|
-
echo "Failed to create '$cache/partial-$arch' directory"
|
165
|
-
return 1
|
166
|
-
fi
|
167
|
-
|
168
|
-
# download a mini ubuntu into a cache
|
169
|
-
echo "Downloading ubuntu minimal ..."
|
170
|
-
debootstrap --verbose --variant=minbase --components=main,universe --arch=$arch --include=$packages lucid $cache/partial-$arch
|
171
|
-
if [ $? -ne 0 ]; then
|
172
|
-
echo "Failed to download the rootfs, aborting."
|
173
|
-
return 1
|
174
|
-
fi
|
175
|
-
|
176
|
-
mv "$1/partial-$arch" "$1/rootfs-$arch"
|
177
|
-
echo "Download complete."
|
178
|
-
|
179
|
-
return 0
|
180
|
-
}
|
181
|
-
|
182
|
-
copy_ubuntu()
|
183
|
-
{
|
184
|
-
cache=$1
|
185
|
-
arch=$2
|
186
|
-
rootfs=$3
|
187
|
-
|
188
|
-
# make a local copy of the miniubuntu
|
189
|
-
echo -n "Copying rootfs to $rootfs ..."
|
190
|
-
cp -a $cache/rootfs-$arch $rootfs || return 1
|
191
|
-
return 0
|
192
|
-
}
|
193
|
-
|
194
|
-
install_ubuntu()
|
195
|
-
{
|
196
|
-
cache="/var/cache/lxc/ubuntu"
|
197
|
-
rootfs=$1
|
198
|
-
mkdir -p /var/lock/subsys/
|
199
|
-
(
|
200
|
-
flock -n -x 200
|
201
|
-
if [ $? -ne 0 ]; then
|
202
|
-
echo "Cache repository is busy."
|
203
|
-
return 1
|
204
|
-
fi
|
205
|
-
|
206
|
-
arch=$(arch)
|
207
|
-
if [ "$arch" == "x86_64" ]; then
|
208
|
-
arch=amd64
|
209
|
-
fi
|
210
|
-
|
211
|
-
if [ "$arch" == "i686" ]; then
|
212
|
-
arch=i386
|
213
|
-
fi
|
214
|
-
|
215
|
-
echo "Checking cache download in $cache/rootfs-$arch ... "
|
216
|
-
if [ ! -e "$cache/rootfs-$arch" ]; then
|
217
|
-
download_ubuntu $cache $arch
|
218
|
-
if [ $? -ne 0 ]; then
|
219
|
-
echo "Failed to download 'ubuntu base'"
|
220
|
-
return 1
|
221
|
-
fi
|
222
|
-
fi
|
223
|
-
configure_image
|
224
|
-
echo "Copy $cache/rootfs-$arch to $rootfs ... "
|
225
|
-
copy_ubuntu $cache $arch $rootfs
|
226
|
-
if [ $? -ne 0 ]; then
|
227
|
-
echo "Failed to copy rootfs"
|
228
|
-
return 1
|
229
|
-
fi
|
230
|
-
|
231
|
-
return 0
|
232
|
-
|
233
|
-
) 200>/var/lock/subsys/lxc
|
234
|
-
|
235
|
-
return $?
|
236
|
-
}
|
237
|
-
|
238
|
-
copy_configuration()
|
239
|
-
{
|
240
|
-
path=$1
|
241
|
-
rootfs=$2
|
242
|
-
name=$3
|
243
|
-
|
244
|
-
cat <<EOF >> $path/config
|
245
|
-
lxc.utsname = $name
|
246
|
-
|
247
|
-
lxc.tty = 4
|
248
|
-
lxc.pts = 1024
|
249
|
-
lxc.rootfs = $rootfs
|
250
|
-
lxc.mount = $path/fstab
|
251
|
-
|
252
|
-
lxc.cgroup.devices.deny = a
|
253
|
-
# /dev/null and zero
|
254
|
-
lxc.cgroup.devices.allow = c 1:3 rwm
|
255
|
-
lxc.cgroup.devices.allow = c 1:5 rwm
|
256
|
-
# consoles
|
257
|
-
lxc.cgroup.devices.allow = c 5:1 rwm
|
258
|
-
lxc.cgroup.devices.allow = c 5:0 rwm
|
259
|
-
lxc.cgroup.devices.allow = c 4:0 rwm
|
260
|
-
lxc.cgroup.devices.allow = c 4:1 rwm
|
261
|
-
# /dev/{,u}random
|
262
|
-
lxc.cgroup.devices.allow = c 1:9 rwm
|
263
|
-
lxc.cgroup.devices.allow = c 1:8 rwm
|
264
|
-
lxc.cgroup.devices.allow = c 136:* rwm
|
265
|
-
lxc.cgroup.devices.allow = c 5:2 rwm
|
266
|
-
# rtc
|
267
|
-
lxc.cgroup.devices.allow = c 254:0 rwm
|
268
|
-
EOF
|
269
|
-
|
270
|
-
cat <<EOF > $path/fstab
|
271
|
-
proc $rootfs/proc proc nodev,noexec,nosuid 0 0
|
272
|
-
devpts $rootfs/dev/pts devpts defaults 0 0
|
273
|
-
sysfs $rootfs/sys sysfs defaults 0 0
|
274
|
-
EOF
|
275
|
-
|
276
|
-
if [ $? -ne 0 ]; then
|
277
|
-
echo "Failed to add configuration"
|
278
|
-
return 1
|
279
|
-
fi
|
280
|
-
|
281
|
-
return 0
|
282
|
-
}
|
283
|
-
|
284
|
-
clean()
|
285
|
-
{
|
286
|
-
cache="/var/cache/lxc/ubuntu"
|
287
|
-
|
288
|
-
if [ ! -e $cache ]; then
|
289
|
-
exit 0
|
290
|
-
fi
|
291
|
-
|
292
|
-
# lock, so we won't purge while someone is creating a repository
|
293
|
-
(
|
294
|
-
flock -n -x 200
|
295
|
-
if [ $? != 0 ]; then
|
296
|
-
echo "Cache repository is busy."
|
297
|
-
exit 1
|
298
|
-
fi
|
299
|
-
|
300
|
-
echo -n "Purging the download cache..."
|
301
|
-
rm --preserve-root --one-file-system -rf $cache && echo "Done." || exit 1
|
302
|
-
exit 0
|
303
|
-
|
304
|
-
) 200>/var/lock/subsys/lxc
|
305
|
-
}
|
306
|
-
|
307
|
-
usage()
|
308
|
-
{
|
309
|
-
cat <<EOF
|
310
|
-
$1 -h|--help -p|--path=<path> --clean
|
311
|
-
EOF
|
312
|
-
return 0
|
313
|
-
}
|
314
|
-
|
315
|
-
options=$(getopt -o hp:n:c -l help,path:,name:,clean -- "$@")
|
316
|
-
if [ $? -ne 0 ]; then
|
317
|
-
usage $(basename $0)
|
318
|
-
exit 1
|
319
|
-
fi
|
320
|
-
eval set -- "$options"
|
321
|
-
|
322
|
-
while true
|
323
|
-
do
|
324
|
-
case "$1" in
|
325
|
-
-h|--help) usage $0 && exit 0;;
|
326
|
-
-p|--path) path=$2; shift 2;;
|
327
|
-
-n|--name) name=$2; shift 2;;
|
328
|
-
-c|--clean) clean=$2; shift 2;;
|
329
|
-
--) shift 1; break ;;
|
330
|
-
*) break ;;
|
331
|
-
esac
|
332
|
-
done
|
333
|
-
|
334
|
-
if [ ! -z "$clean" -a -z "$path" ]; then
|
335
|
-
clean || exit 1
|
336
|
-
exit 0
|
337
|
-
fi
|
338
|
-
|
339
|
-
type debootstrap
|
340
|
-
if [ $? -ne 0 ]; then
|
341
|
-
echo "'debootstrap' command is missing"
|
342
|
-
exit 1
|
343
|
-
fi
|
344
|
-
|
345
|
-
if [ -z "$path" ]; then
|
346
|
-
echo "'path' parameter is required"
|
347
|
-
exit 1
|
348
|
-
fi
|
349
|
-
|
350
|
-
if [ "$(id -u)" != "0" ]; then
|
351
|
-
echo "This script should be run as 'root'"
|
352
|
-
exit 1
|
353
|
-
fi
|
354
|
-
|
355
|
-
rootfs=$path/rootfs
|
356
|
-
|
357
|
-
install_ubuntu $rootfs
|
358
|
-
if [ $? -ne 0 ]; then
|
359
|
-
echo "failed to install ubuntu"
|
360
|
-
exit 1
|
361
|
-
fi
|
362
|
-
|
363
|
-
configure_ubuntu $rootfs $name
|
364
|
-
if [ $? -ne 0 ]; then
|
365
|
-
echo "failed to configure ubuntu for a container"
|
366
|
-
exit 1
|
367
|
-
fi
|
368
|
-
|
369
|
-
copy_configuration $path $rootfs $name
|
370
|
-
if [ $? -ne 0 ]; then
|
371
|
-
echo "failed write configuration file"
|
372
|
-
exit 1
|
373
|
-
fi
|
374
|
-
|
375
|
-
if [ ! -z $clean ]; then
|
376
|
-
clean || exit 1
|
377
|
-
exit 0
|
378
|
-
fi
|
@@ -1,51 +0,0 @@
|
|
1
|
-
directory "/root/.ssh" do
|
2
|
-
owner "root"
|
3
|
-
mode "0600"
|
4
|
-
end
|
5
|
-
|
6
|
-
cookbook_file "/root/.ssh/git-key.rsa" do
|
7
|
-
source "git-private-key"
|
8
|
-
end
|
9
|
-
|
10
|
-
cookbook_file "/root/.ssh/config" do
|
11
|
-
source "permissive-ssh-config"
|
12
|
-
end
|
13
|
-
|
14
|
-
cookbook_file "/root/.ssh/id_rsa" do
|
15
|
-
source "cucumber-private-key"
|
16
|
-
mode "0600"
|
17
|
-
owner "root"
|
18
|
-
end
|
19
|
-
|
20
|
-
cookbook_file "/root/.bashrc" do
|
21
|
-
source "add-git-identity"
|
22
|
-
end
|
23
|
-
|
24
|
-
cookbook_file "/etc/lxc/controller" do
|
25
|
-
source "lxc-controller-network-config"
|
26
|
-
end
|
27
|
-
|
28
|
-
execute "lxc-create -n controller -f /etc/lxc/controller -t lucid-chef" do
|
29
|
-
not_if {File.exists?("/var/lib/lxc/controller")}
|
30
|
-
end
|
31
|
-
|
32
|
-
template "/var/lib/lxc/controller/rootfs/etc/chef/client.rb" do
|
33
|
-
source "controller-client.erb"
|
34
|
-
variables( :orgname => node["cucumber-chef"]["orgname"] )
|
35
|
-
end
|
36
|
-
|
37
|
-
cookbook_file "/var/lib/lxc/controller/rootfs/etc/chef/first-boot.json" do
|
38
|
-
source "controller-first-boot"
|
39
|
-
end
|
40
|
-
|
41
|
-
controllers = search(:node, 'name:cucumber-chef-controller')
|
42
|
-
execute 'chroot /var/lib/lxc/controller/rootfs /bin/bash -c "chef-client -j /etc/chef/first-boot.json > /dev/null 2>&1"' do
|
43
|
-
action :run
|
44
|
-
not_if { controllers.length > 0 }
|
45
|
-
end
|
46
|
-
|
47
|
-
execute 'lxc-start -d -n controller' do
|
48
|
-
status = %x[lxc-info -n controller 2>&1]
|
49
|
-
not_if {status.include?("RUNNING")}
|
50
|
-
end
|
51
|
-
|
@@ -1,35 +0,0 @@
|
|
1
|
-
%w{lxc bridge-utils debootstrap}.each do |pkg|
|
2
|
-
package "#{pkg}"
|
3
|
-
end
|
4
|
-
|
5
|
-
bash "Set up networking" do
|
6
|
-
code <<-EOH
|
7
|
-
brctl addbr br0
|
8
|
-
ifconfig br0 192.168.20.1 up
|
9
|
-
iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
|
10
|
-
sysctl -w net.ipv4.ip_forward=1
|
11
|
-
EOH
|
12
|
-
not_if "ip link ls dev br0"
|
13
|
-
end
|
14
|
-
|
15
|
-
directory "/cgroup" do
|
16
|
-
action :create
|
17
|
-
end
|
18
|
-
|
19
|
-
mount "/cgroup" do
|
20
|
-
device "cgroup"
|
21
|
-
fstype "cgroup"
|
22
|
-
pass 0
|
23
|
-
action [:mount, :enable]
|
24
|
-
end
|
25
|
-
|
26
|
-
template "/usr/lib/lxc/templates/lxc-lucid-chef" do
|
27
|
-
source "lxc-lucid-chef"
|
28
|
-
mode "0755"
|
29
|
-
variables( :orgname => node["cucumber-chef"]["orgname"] )
|
30
|
-
action :create
|
31
|
-
end
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
@@ -1,23 +0,0 @@
|
|
1
|
-
%w[rsync build-essential libxml2-dev libxslt1-dev].each do |pkg|
|
2
|
-
package pkg
|
3
|
-
end
|
4
|
-
|
5
|
-
%w[cucumber-chef rspec cucumber].each do |gem|
|
6
|
-
gem_package gem
|
7
|
-
end
|
8
|
-
|
9
|
-
directory "/root/.ssh" do
|
10
|
-
mode "0600"
|
11
|
-
owner "root"
|
12
|
-
end
|
13
|
-
|
14
|
-
cookbook_file "/root/.ssh/config" do
|
15
|
-
source "permissive-ssh-config"
|
16
|
-
end
|
17
|
-
|
18
|
-
cookbook_file "/root/.ssh/id_rsa" do
|
19
|
-
source "cucumber-private-key"
|
20
|
-
mode "0600"
|
21
|
-
owner "root"
|
22
|
-
end
|
23
|
-
|
@@ -1,46 +0,0 @@
|
|
1
|
-
%w{build-essential binutils-doc libxml2-dev libxslt1-dev}.each do |pkg|
|
2
|
-
package pkg do
|
3
|
-
action :install
|
4
|
-
end
|
5
|
-
end
|
6
|
-
|
7
|
-
package "autoconf" do
|
8
|
-
action :install
|
9
|
-
end
|
10
|
-
|
11
|
-
package "flex" do
|
12
|
-
action :install
|
13
|
-
end
|
14
|
-
|
15
|
-
package "bison" do
|
16
|
-
action :install
|
17
|
-
end
|
18
|
-
|
19
|
-
%w[cucumber-chef cucumber rspec].each do |gem|
|
20
|
-
gem_package gem
|
21
|
-
end
|
22
|
-
|
23
|
-
directory "/root/.ssh" do
|
24
|
-
owner "root"
|
25
|
-
mode "0600"
|
26
|
-
end
|
27
|
-
|
28
|
-
cookbook_file "/root/.ssh/git-key.rsa" do
|
29
|
-
source "git-private-key"
|
30
|
-
end
|
31
|
-
|
32
|
-
cookbook_file "/root/.ssh/config" do
|
33
|
-
source "permissive-ssh-config"
|
34
|
-
end
|
35
|
-
|
36
|
-
cookbook_file "/root/.ssh/id_rsa" do
|
37
|
-
source "cucumber-private-key"
|
38
|
-
mode "0600"
|
39
|
-
owner "root"
|
40
|
-
end
|
41
|
-
|
42
|
-
cookbook_file "/root/.bashrc" do
|
43
|
-
source "add-git-identity"
|
44
|
-
end
|
45
|
-
|
46
|
-
|
@@ -1,9 +0,0 @@
|
|
1
|
-
name "test_lab_test"
|
2
|
-
description "Platform for running acceptance and integration tests"
|
3
|
-
run_list(
|
4
|
-
"recipe[cucumber-chef::lxc]",
|
5
|
-
"recipe[cucumber-chef::test_lab]",
|
6
|
-
"recipe[cucumber-chef::controller]"
|
7
|
-
)
|
8
|
-
|
9
|
-
override_attributes "cucumber-chef" => { "orgname" => "#{ENV['ORGNAME']}" }
|