-
Notifications
You must be signed in to change notification settings - Fork 3
/
configure-chef-workstation.sh
executable file
·50 lines (40 loc) · 1.07 KB
/
configure-chef-workstation.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
#!/bin/bash
# Configures the Chef workstation (supported on Mac OS X, Debian, and Red Hat Linux)
#
# Prerequisites:
# - Ruby 1.9 installed
# - Git installed
# - Configured Chef server
# Install Chef gem
chefInstalled=`gem list | grep chef`
if [ "$chefInstalled" == "" ]; then
echo "Installing chef gem..."
sudo gem install chef --no-ri --no-rdoc
if [ "$?" == 1 ]; then
echo "Install of Chef gem failed. Aborting..."
exit 1
fi
else
echo "Chef gem detected. Continuing..."
fi
# Create config directory
configDir=~/.chef
mkdir $configDir
# Configure knife
knife configure
# Copy validation keys from server
echo "Preparing to copy validation keys from chef server."
echo "Enter name of chef server:"
read chefServer
username=`grep node_name ~/.chef/knife.rb | awk -F\' '{print $2}'`
scp $username@$chefServer:/home/$username/.chef/*.pem $configDir
if [ "$?" == 1 ]; then
echo "Failed to copy validation keys from server. Aborting..."
exit 1
fi
echo "Testing knife configuration..."
if [ "`knife client list | grep $username`" == "" ]; then
echo "FAILED!"
else
echo "PASSED!"
fi