toft 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile.lock +6 -1
- data/Rakefile +93 -4
- data/features/checker.feature +2 -2
- data/features/chef.feature +23 -5
- data/features/command.feature +4 -3
- data/features/node.feature +21 -6
- data/features/step_definitions/chef.rb +11 -3
- data/features/step_definitions/command.rb +1 -3
- data/features/step_definitions/node.rb +19 -3
- data/features/support/env.rb +6 -3
- data/fixtures/chef/attributes.json +9 -0
- data/lib/toft/chef/chef_attributes.rb +2 -2
- data/lib/toft/chef/chef_runner.rb +17 -4
- data/lib/toft/node.rb +64 -20
- data/lib/toft/node_controller.rb +2 -2
- data/lib/toft/version.rb +1 -1
- data/lib/toft.rb +5 -2
- data/scripts/bin/centos/lxc-prepare-host +175 -0
- data/scripts/{ubuntu/bin → bin/share}/install-chef-ubuntu.sh +0 -0
- data/scripts/{ubuntu/bin → bin/share}/install-rvm.sh +0 -0
- data/scripts/{ubuntu/bin → bin/share}/lxc-create-centos-image +6 -5
- data/scripts/{ubuntu/bin → bin/ubuntu}/lxc-create-ubuntu-image +3 -3
- data/scripts/bin/ubuntu/lxc-prepare-host +190 -0
- data/scripts/cookbooks/lxc/recipes/default.rb +8 -14
- data/scripts/{ubuntu/lxc-templates → cookbooks/lxc/templates/default}/lxc-centos-6 +7 -3
- data/scripts/cookbooks/lxc/templates/default/{lxc-lucid-chef → lxc-lucid} +2 -2
- data/scripts/cookbooks/lxc/templates/default/{lxc-natty-chef → lxc-natty} +2 -2
- data/scripts/lxc-templates/files/rc.local +38 -0
- data/scripts/lxc-templates/lxc-centos-6 +279 -0
- data/scripts/{ubuntu/lxc-templates → lxc-templates}/lxc-lucid +3 -12
- data/scripts/{ubuntu/lxc-templates → lxc-templates}/lxc-natty +51 -61
- data/spec/fixtures/illegal_syntax.json +1 -0
- data/spec/spec_helper.rb +3 -1
- data/spec/tuft/chef_attributes_spec.rb +6 -0
- data/spec/tuft/chef_runner_spec.rb +34 -0
- metadata +55 -21
- data/scripts/centos/bin/lxc-prepare-host +0 -39
- data/scripts/cookbooks/lxc/files/default/lxc-create-ubuntu-image +0 -75
- data/scripts/ubuntu/bin/lxc-prepare-host +0 -24
@@ -1,39 +0,0 @@
|
|
1
|
-
#!/bin/bash
|
2
|
-
|
3
|
-
username=`id -nu`
|
4
|
-
if [ ! "$username" = "root" ]; then
|
5
|
-
echo "This command has to be run as root!"
|
6
|
-
exit 1
|
7
|
-
fi
|
8
|
-
|
9
|
-
# intsall lxc
|
10
|
-
if [[ ! -f /usr/bin/lxc-ls ]]; then
|
11
|
-
(cd /tmp && \
|
12
|
-
wget http://lxc.sourceforge.net/download/lxc/lxc-0.7.4.tar.gz && \
|
13
|
-
tar zxf lxc-0.7.4.tar.gz && \
|
14
|
-
cd lxc-0.7.4 && \
|
15
|
-
./configure --prefix=/usr && \
|
16
|
-
make && \
|
17
|
-
make install)
|
18
|
-
fi
|
19
|
-
|
20
|
-
yum install bridge-utils
|
21
|
-
|
22
|
-
if [[ ! `ip link ls dev br0` ]]; then
|
23
|
-
brctl addbr br0
|
24
|
-
ifconfig br0 192.168.20.1 netmask 255.255.255.0 up
|
25
|
-
iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
|
26
|
-
sysctl -w net.ipv4.ip_forward=1
|
27
|
-
fi
|
28
|
-
|
29
|
-
if [[ ! -d /cgroup ]]; then
|
30
|
-
mkdir -p /cgroup
|
31
|
-
fi
|
32
|
-
|
33
|
-
if [[ ! `mount | grep cgroup` ]]; then
|
34
|
-
mount none -t cgroup /cgroup
|
35
|
-
fi
|
36
|
-
|
37
|
-
# allow people to ping this machine
|
38
|
-
iptables -D FORWARD -j REJECT --reject-with icmp-host-prohibited
|
39
|
-
iptables -D INPUT -j REJECT --reject-with icmp-host-prohibited
|
@@ -1,75 +0,0 @@
|
|
1
|
-
#!/bin/bash
|
2
|
-
|
3
|
-
if [ $# -eq 0 ]; then
|
4
|
-
echo "Usage: `basename $0` <ubuntu-suite>"
|
5
|
-
exit 1
|
6
|
-
fi
|
7
|
-
|
8
|
-
username=`id -nu`
|
9
|
-
if [ ! "$username" = "root" ]; then
|
10
|
-
echo "This command has to be run as root!"
|
11
|
-
exit 1
|
12
|
-
fi
|
13
|
-
|
14
|
-
cache="/var/cache/lxc/ubuntu"
|
15
|
-
suite=$1
|
16
|
-
|
17
|
-
arch=$(arch)
|
18
|
-
if [ "$arch" == "x86_64" ]; then
|
19
|
-
arch=amd64
|
20
|
-
fi
|
21
|
-
|
22
|
-
if [ "$arch" == "i686" ]; then
|
23
|
-
arch=i386
|
24
|
-
fi
|
25
|
-
|
26
|
-
if [ -e "$cache/$suite-$arch.tar.gz" ]; then
|
27
|
-
echo "Cache rootfs already exists!"
|
28
|
-
exit 0
|
29
|
-
fi
|
30
|
-
|
31
|
-
lucid_packages=dialog,apt,apt-utils,resolvconf,iproute,inetutils-ping,dhcp3-client,ssh,lsb-release,wget,gpgv,gnupg,sudo,ruby,rubygems1.8,ruby-dev,libopenssl-ruby,build-essential,wget,ssl-cert
|
32
|
-
natty_packages=dialog,apt,apt-utils,resolvconf,iproute,inetutils-ping,isc-dhcp-client,isc-dhcp-common,ssh,lsb-release,gnupg,netbase,lxcguest,sudo,ruby,rubygems1.8,ruby-dev,libruby,build-essential,wget,ssl-cert
|
33
|
-
# check the mini ubuntu was not already downloaded
|
34
|
-
rm -rf "$cache/$suite-$arch"
|
35
|
-
mkdir -p "$cache/$suite-$arch"
|
36
|
-
if [ $? -ne 0 ]; then
|
37
|
-
echo "Failed to create '$cache/$suite-$arch' directory"
|
38
|
-
exit 1
|
39
|
-
fi
|
40
|
-
|
41
|
-
# download a mini ubuntu into a cache
|
42
|
-
echo "Downloading ubuntu minimal ..."
|
43
|
-
eval "packages=\$${suite}_packages"
|
44
|
-
cmd="debootstrap --verbose --variant=minbase --components=main,universe --arch=$arch --include=$packages $suite $cache/$suite-$arch"
|
45
|
-
echo $cmd
|
46
|
-
eval $cmd
|
47
|
-
if [ $? -ne 0 ]; then
|
48
|
-
echo "Failed to download the rootfs, aborting."
|
49
|
-
exit 1
|
50
|
-
fi
|
51
|
-
|
52
|
-
echo "Download complete."
|
53
|
-
|
54
|
-
# install chef
|
55
|
-
cat <<EOF > "$cache/$suite-$arch/tmp/install-chef-ubuntu.sh"
|
56
|
-
echo "deb http://apt.opscode.com/ $suite-0.10 main" | tee /etc/apt/sources.list.d/opscode.list
|
57
|
-
|
58
|
-
mkdir -p /etc/apt/trusted.gpg.d
|
59
|
-
gpg --keyserver keys.gnupg.net --recv-keys 83EF826A
|
60
|
-
gpg --export packages@opscode.com | tee /etc/apt/trusted.gpg.d/opscode-keyring.gpg > /dev/null
|
61
|
-
apt-get update
|
62
|
-
apt-get install ucf --force-yes -y
|
63
|
-
yes | apt-get install opscode-keyring --force-yes -y # permanent upgradeable keyring
|
64
|
-
|
65
|
-
export DEBIAN_FRONTEND=noninteractive
|
66
|
-
apt-get install chef --force-yes -qy
|
67
|
-
EOF
|
68
|
-
chroot "$cache/$suite-$arch" bash /tmp/install-chef-ubuntu.sh
|
69
|
-
|
70
|
-
# compress root image
|
71
|
-
echo "Packaging rootfs ..."
|
72
|
-
(cd $cache/$suite-$arch && tar zcf $suite-$arch.tar.gz .)
|
73
|
-
mv $cache/$suite-$arch/$suite-$arch.tar.gz $cache
|
74
|
-
|
75
|
-
|
@@ -1,24 +0,0 @@
|
|
1
|
-
#!/bin/bash
|
2
|
-
|
3
|
-
username=`id -nu`
|
4
|
-
if [ ! "$username" = "root" ]; then
|
5
|
-
echo "This command has to be run as root!"
|
6
|
-
exit 1
|
7
|
-
fi
|
8
|
-
|
9
|
-
apt-get install -y lxc bridge-utils debootstrap
|
10
|
-
|
11
|
-
if [[ ! `ip link ls dev br0` ]]; then
|
12
|
-
brctl addbr br0
|
13
|
-
ifconfig br0 192.168.20.1 netmask 255.255.255.0 up
|
14
|
-
iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
|
15
|
-
sysctl -w net.ipv4.ip_forward=1
|
16
|
-
fi
|
17
|
-
|
18
|
-
if [[ ! -d /cgroup ]]; then
|
19
|
-
mkdir -p /cgroup
|
20
|
-
fi
|
21
|
-
|
22
|
-
if [[ ! `mount | grep cgroup` ]]; then
|
23
|
-
mount none -t cgroup /cgroup
|
24
|
-
fi
|