This repository has been archived by the owner on Jun 28, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathchef-bootstrap.sh
executable file
·78 lines (64 loc) · 1.55 KB
/
chef-bootstrap.sh
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
#!/usr/bin/env bash
rubygems_version="1.3.7"
function usage {
echo "usage: $0 <client|server> <server-url>"
}
if [[ $# != 2 ]]; then
usage
exit
fi
if [[ $1 != 'server' && $1 != 'client' ]]; then
usage
exit
fi
bootstrap_type="$1"
server_url="$2"
# Install required packages
apt-get install ruby ruby-dev libopenssl-ruby build-essential wget ssl-cert
# Install Rubygems from source
cd /tmp
wget "http://production.cf.rubygems.org/rubygems/rubygems-${rubygems_version}.tgz"
tar xzf "rubygems-${rubygems_version}.tgz"
cd "rubygems-${rubygems_version}"
ruby setup.rb -q --no-format-executable
# Disable Rubygems RDoc and RI generation
cat > /etc/gemrc <<EOF
gem: --no-ri --no-rdoc
EOF
# Install Chef
gem install chef
# Create Chef Solo config
cat > /tmp/solo.rb <<EOF
file_cache_path "/tmp/chef-solo"
cookbook_path "/tmp/chef-solo/cookbooks"
recipe_url "http://s3.amazonaws.com/chef-solo/bootstrap-latest.tar.gz"
EOF
# Create Chef server bootstrap config
cat > /tmp/chef-server.json <<EOF
{
"bootstrap": {
"chef": {
"server_url": "$server_url",
"webui_enabled": true
}
},
"run_list": [ "recipe[chef::bootstrap_server]" ]
}
EOF
# Create Chef client bootstrap config
cat > /tmp/chef-client.json <<EOF
{
"bootstrap": {
"chef": {
"server_url": "$server_url"
}
},
"run_list": [ "recipe[chef::bootstrap_client]" ]
}
EOF
if [[ $bootstrap_type = 'client' ]]; then
chef-solo -c /tmp/solo.rb -j /tmp/chef-client.json
fi
if [[ $bootstrap_type = 'server' ]]; then
chef-solo -c /tmp/solo.rb -j /tmp/chef-server.json
fi