This repository has been archived by the owner on Aug 5, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
ubuntu-chef-client.sh
executable file
·77 lines (64 loc) · 1.78 KB
/
ubuntu-chef-client.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
#!/bin/bash
# Update to latest packages
sudo apt-get update
sudo apt-get upgrade
# Install essentials + a couple useful extras
sudo apt-get -y install \
autoconf \
build-essential \
curl \
git-core \
libreadline5-dev \
libssl-dev \
linux-headers-$(uname -r) \
vim \
zlib1g-dev
# Add insecure Vagrant key to authorized_keys
mkdir -p $HOME/.ssh
curl https://github.com/mitchellh/vagrant/raw/master/keys/vagrant.pub > $HOME/.ssh/authorized_keys
chmod 600 $HOME/.ssh/authorized_keys
# Disable generation of RI and Rdoc
sudo bash -c 'echo "gem: --no-ri --no-rdoc" > /etc/gemrc'
# Install RVM
sudo bash < <( curl -L http://bit.ly/rvm-install-system-wide )
sudo bash -c 'echo >> /etc/bash.bashrc'
sudo bash -c 'echo "source /usr/local/lib/rvm" >> /etc/bash.bashrc'
source /usr/local/lib/rvm
# Add Vagrant user to RVM groups
sudo usermod -a -G rvm vagrant
# Install REE
sudo rvm install ree
# Set default Ruby
sudo rvm --default ree
# Install Chef
sudo gem install chef
sudo gem install fast_xs
# 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 client bootstrap config
cat > /tmp/chef-client.json <<EOF
{
"bootstrap": {
"chef": {
"server_url": "http://33.33.33.11:4000"
}
},
"run_list": [ "recipe[chef::bootstrap_client]" ]
}
EOF
# Bootstrap Chef client
cd /tmp
rvmsudo chef-solo -c /tmp/solo.rb -j /tmp/chef-client.json
# Do the following manually:
# 1. Change %admin line to:
# %admin ALL=NOPASSWD: ALL
# 2. Install guest additions
# - Devicek > Install Guest Additions...
# - sudo mount /dev/cdrom /media/cdrom
# - sudo sh /media/cdrom/VBoxLinuxAdditions.run
# - sudo umount /media/cdrom
# 3. Set hostname