-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathchef-install.sh
47 lines (35 loc) · 1.58 KB
/
chef-install.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
# set hostname
sudo hostname chef.vbox.local
sudo sed -i '/HOSTNAME=/c\HOSTNAME=chef.vbox.local' /etc/sysconfig/network
sudo echo -e "127.0.0.1 `hostname` `hostname -s`" | sudo tee -a /etc/hosts
sudo /etc/init.d/network restart
# update
sudo yum -y update
# install dep packages
sudo yum -y install git curl wget tar
# install chef-solo
curl -L https://www.chef.io/chef/install.sh | sudo bash
# create required bootstrap dirs/files
sudo mkdir -p /var/chef/cache /var/chef/cookbooks
# pull down chef-server cookbook
wget -qO- https://supermarket.chef.io/cookbooks/chef-server/download | sudo tar xvzC /var/chef/cookbooks
# pull down dependency cookbooks
for dep in yum-chef yum apt-chef apt packagecloud compat_resource
do
wget -qO- https://supermarket.chef.io/cookbooks/${dep}/download | sudo tar xvzC /var/chef/cookbooks
done
knife cookbook site download chef-ingredient 1.1.0
sudo tar xvzf chef-ingredient-1.1.0.tar.gz -C /var/chef/cookbooks && rm -f chef-ingredient-1.1.0.tar.gz
# install chef-server
sudo chef-solo -j 'https://raw.githubusercontent.com/bshaw/chef-server/master/dna.json' -o 'recipe[chef-server::default]'
# create an admin user
sudo chef-server-ctl user-create --filename admin.pem admin Chef Admin [email protected] Password1!
# create an organization
sudo chef-server-ctl org-create vagrant "Vagrant" --association_user admin --filename vagrant.pem
# setup chef server as a client of its self
sudo cp vagrant.pem /etc/chef/validation.pem
knife ssl fetch
sudo cp -R /root/.chef/trusted_certs/ /etc/chef/
# copy keys to host
cp admin.pem /vagrant/.chef/
cp vagrant.pem /vagrant/.chef/