Created
December 10, 2011 17:36
-
-
Save pulkitsinghal/1455699 to your computer and use it in GitHub Desktop.
Configuring EC2 RHEL4 with Chef
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
which ruby | |
ruby -version | |
port list | grep ruby | |
sudo gem update --system | |
gem -v | |
mkdir -p ~/chef-repo/.chef/ | |
mv ~/Downloads/<chef-hosted-account-username>.pem ~/chef-repo/.chef/ | |
mv ~/Downloads/knife.rb ~/chef-repo/.chef/ | |
mv ~/Downloads/<chef-hosted-organization-name>-validator.pem ~/chef-repo/.chef/ | |
sudo gem install chef --no-ri --no-rdoc | |
git clone git://github.com/opscode/chef-repo.git ~/chef-repo | |
chef-client -v | |
knife client list | |
knife cookbook site install getting-started | |
knife cookbook upload getting-started | |
knife cookbook list | |
knife configure client ./client-config | |
ls -l client-config/ | |
gem search -r knife | |
sudo gem install knife-ec2 | |
find ./ -name knife.rb | |
vi ./.chef/knife.rb | |
13 ###### | |
14 ##EC2# | |
15 ###### | |
16 # | |
17 ## Platform access info | |
18 knife[:aws_access_key_id] = "xxx" | |
19 knife[:aws_secret_access_key] = "xxx" | |
20 # | |
21 ## Smallest possible free machine possible | |
22 knife[:flavor] = "t1.micro" | |
23 # | |
24 ## RHEL 4 Basic 64-bit Amazon Linux AMI 2011.09 (GOOD!) | |
25 knife[:image] = "ami-1b814f72" | |
26 # | |
27 ## RHEL 6.1 x86_64 (NO SSH!) | |
28 #knife[:image] = "ami-31d41658" | |
29 # | |
30 ## RHEL-5.6-Starter-EBS-x86_64-11-Hourly2 (NO SSH!) | |
31 #knife[:image] = "ami-8f4083e6" | |
32 # | |
33 ## Keypair id in cloud to assign to the provisioned instance | |
34 knife[:aws_ssh_key_id] = "xxx" | |
35 # | |
36 ## Keypair local location to access the provisioned instance (not picked up from here!) | |
37 #knife[:identity_file] = "/Users/xxx/.ec2/ec2.pem" | |
38 #config[:ssh_user] = "ec2-user" | |
cd ~/chef-repo/ | |
knife cookbook upload yum erlang couchdb | |
cd ~/chef-repo/ | |
knife bootstrap ec2-xxx.compute-1.amazonaws.com -x ec2-user -i /Users/xxx/.ec2/ec2.pem | |
ls ~/.ec2/ec2.pem | |
chmod 400 /Users/xxx/.ec2/ec2.pem | |
ls -alrt ~/.ec2/ec2.pem | |
telnet ec2-xxx.compute-1.amazonaws.com 22 | |
vi ./.chef/knife.rb | |
cd ~/chef-repo/ | |
gem contents chef | grep linux | |
cat /Library/Ruby/Gems/1.8/gems/chef-0.10.4/lib/chef/knife/bootstrap/archlinux-gems.erb | |
knife bootstrap ec2-xxx.compute-1.amazonaws.com -x ec2-user -i /Users/xxx/.ec2/ec2.pem --sudo --template-file /Library/Ruby/Gems/1.8/gems/chef-0.10.4/lib/chef/knife/bootstrap/archlinux-gems.erb | |
ssh -i /Users/xxx/.ec2/ec2.pem [email protected] | |
cd ~/chef-repo/ | |
gem contents chef | grep cent | |
cat /Library/Ruby/Gems/1.8/gems/chef-0.10.4/lib/chef/knife/bootstrap/centos5-gems.erb | |
mkdir ~/chef-repo/.chef/bootstrap/ | |
cp /Library/Ruby/Gems/1.8/gems/chef-0.10.4/lib/chef/knife/bootstrap/centos5-gems.erb ~/chef-repo/.chef/bootstrap/centos5-gems-modified.erb | |
vi ~/chef-repo/.chef/bootstrap/centos5-gems-modified.erb | |
1 bash -c ' | |
2 <%= "export http_proxy=\"#{knife_config[:bootstrap_proxy]}\"" if knife_config[:bootstrap_proxy] -%> | |
3 | |
4 if [ ! -f /usr/bin/chef-client ]; then | |
5 yum install -y ruby ruby-devel gcc gcc-c++ automake autoconf make | |
6 yum install -y rubygems | |
7 fi | |
8 | |
9 gem update --system | |
10 gem update | |
11 gem install ohai --no-rdoc --no-ri --verbose | |
12 gem install chef --no-rdoc --no-ri --verbose <%= bootstrap_version_string %> | |
13 | |
14 mkdir -p /etc/chef | |
15 | |
16 ( | |
17 cat <<'EOP' | |
18 <%= validation_key %> | |
19 EOP | |
20 ) > /tmp/validation.pem | |
21 awk NF /tmp/validation.pem > /etc/chef/validation.pem | |
22 rm /tmp/validation.pem | |
23 | |
24 ( | |
25 cat <<'EOP' | |
26 <%= config_content %> | |
27 EOP | |
28 ) > /etc/chef/client.rb | |
29 | |
30 ( | |
31 cat <<'EOP' | |
32 <%= { "run_list" => @run_list }.to_json %> | |
33 EOP | |
34 ) > /etc/chef/first-boot.json | |
35 | |
36 <%= start_chef %>' | |
cd ~/chef-repo/ | |
knife ec2 server create --help | |
knife ec2 server create -x ec2-user -i /Users/xxx/.ec2/ec2.pem --template-file ~/chef-repo/.chef/bootstrap/centos5-gems-modified.erb --verbose | |
knife ec2 server list | |
knife client list | |
$ knife node run_list add i-17a4bf74 "recipe[getting-started]" | |
run_list: recipe[getting-started] | |
$ sudo find / -name cookbooks | |
/var/chef/cache/cookbooks | |
$ sudo find / -name chef-getting-started.txt | |
/root/chef-getting-started.txt | |
$ sudo cat /root/chef-getting-started.txt | |
Welcome to Chef! | |
This is Chef version 0.10.4. | |
Running on amazon. | |
Version 2011.09. | |
$ knife node run_list remove i-17a4bf74 "recipe[getting-started]" | |
run_list: |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment