Chef学习之五:Knife bootstrap 一台 Ubuntu EC2 机器

之前bootstrap一台windows 的机器失败了,很挫败,那只能在云上起一台Linux机器作尝试了。

这次学习的是bootstrap命令,简单来说,这个命令就是在目标机器上安装Chef-Client程序,使之变成Chef Servers所能管理的node。

下面是简单的步骤:

1. 在亚马逊上起一台Unbuntu 12.10的EC2。

2. 在Ruby环境下,Chef-repo下,执行命令:“D:\Tools\Chef\chef-repo-master>knife bootstrap ec2-54-234-202-177.compute-1.amazonaws.com -x ubuntu -i E:\Projects\CloudSeed\AwsSelfUse\myKey.pem --sudo”。

-x:指定用户名

-P:用来指定密码(但是我是通过-i指定一个pem文件来进行认证的)

--sudo:表示在管理员权限下执行。

执行之后,会有如下的输出:

Bootstrapping Chef on ec2-54-234-202-177.compute-1.amazonaws.com
ec2-54-234-202-177.compute-1.amazonaws.com --2013-03-31 15:21:33--  http://opsco
de.com/chef/install.sh
ec2-54-234-202-177.compute-1.amazonaws.com
ec2-54-234-202-177.compute-1.amazonaws.com Resolving opscode.com (opscode.com)..
.
ec2-54-234-202-177.compute-1.amazonaws.com 184.106.28.83
ec2-54-234-202-177.compute-1.amazonaws.com
ec2-54-234-202-177.compute-1.amazonaws.com Connecting to opscode.com (opscode.co
m)|184.106.28.83|:80...
ec2-54-234-202-177.compute-1.amazonaws.com connected.
ec2-54-234-202-177.compute-1.amazonaws.com
ec2-54-234-202-177.compute-1.amazonaws.com HTTP request sent, awaiting response.
..
ec2-54-234-202-177.compute-1.amazonaws.com 301 Moved Permanently
ec2-54-234-202-177.compute-1.amazonaws.com
ec2-54-234-202-177.compute-1.amazonaws.com Location: http://www.opscode.com/chef
/install.sh [following]
ec2-54-234-202-177.compute-1.amazonaws.com
ec2-54-234-202-177.compute-1.amazonaws.com --2013-03-31 15:21:33--  http://www.o
pscode.com/chef/install.sh
ec2-54-234-202-177.compute-1.amazonaws.com
ec2-54-234-202-177.compute-1.amazonaws.com Resolving www.opscode.com (www.opscod
e.com)...
ec2-54-234-202-177.compute-1.amazonaws.com 184.106.28.83
ec2-54-234-202-177.compute-1.amazonaws.com
ec2-54-234-202-177.compute-1.amazonaws.com Reusing existing connection to opscod
e.com:80.
ec2-54-234-202-177.compute-1.amazonaws.com
ec2-54-234-202-177.compute-1.amazonaws.com HTTP request sent, awaiting response.
..
ec2-54-234-202-177.compute-1.amazonaws.com 200 OK
ec2-54-234-202-177.compute-1.amazonaws.com
ec2-54-234-202-177.compute-1.amazonaws.com Length:
ec2-54-234-202-177.compute-1.amazonaws.com 6470
ec2-54-234-202-177.compute-1.amazonaws.com  (6.3K)
ec2-54-234-202-177.compute-1.amazonaws.com  [application/x-sh]
ec2-54-234-202-177.compute-1.amazonaws.com
ec2-54-234-202-177.compute-1.amazonaws.com Saving to: `STDOUT'
ec2-54-234-202-177.compute-1.amazonaws.com
ec2-54-234-202-177.compute-1.amazonaws.com
ec2-54-234-202-177.compute-1.amazonaws.com
ec2-54-234-202-177.compute-1.amazonaws.com  0% [
       ] 0           --.-K/s
ec2-54-234-202-177.compute-1.amazonaws.com
ec2-54-234-202-177.compute-1.amazonaws.com 100%[================================
======>] 6,470       --.-K/s   in 0.02s
ec2-54-234-202-177.compute-1.amazonaws.com
ec2-54-234-202-177.compute-1.amazonaws.com
ec2-54-234-202-177.compute-1.amazonaws.com 2013-03-31 15:21:34 (290 KB/s) - writ
ten to stdout [6470/6470]
ec2-54-234-202-177.compute-1.amazonaws.com
ec2-54-234-202-177.compute-1.amazonaws.com
ec2-54-234-202-177.compute-1.amazonaws.com Downloading Chef 11.4.0 for ubuntu...

ec2-54-234-202-177.compute-1.amazonaws.com
ec2-54-234-202-177.compute-1.amazonaws.com Installing Chef 11.4.0
ec2-54-234-202-177.compute-1.amazonaws.com
ec2-54-234-202-177.compute-1.amazonaws.com Selecting previously unselected packa
ge chef.
ec2-54-234-202-177.compute-1.amazonaws.com
ec2-54-234-202-177.compute-1.amazonaws.com (Reading database ...
ec2-54-234-202-177.compute-1.amazonaws.com (Reading database ... 5%
ec2-54-234-202-177.compute-1.amazonaws.com (Reading database ... 10%
ec2-54-234-202-177.compute-1.amazonaws.com (Reading database ... 15%
ec2-54-234-202-177.compute-1.amazonaws.com (Reading database ... 20%
ec2-54-234-202-177.compute-1.amazonaws.com (Reading database ... 25%
ec2-54-234-202-177.compute-1.amazonaws.com (Reading database ... 30%
ec2-54-234-202-177.compute-1.amazonaws.com (Reading database ... 35%
ec2-54-234-202-177.compute-1.amazonaws.com (Reading database ... 40%
ec2-54-234-202-177.compute-1.amazonaws.com (Reading database ... 45%
ec2-54-234-202-177.compute-1.amazonaws.com (Reading database ... 50%
ec2-54-234-202-177.compute-1.amazonaws.com (Reading database ... 55%
ec2-54-234-202-177.compute-1.amazonaws.com (Reading database ... 60%
ec2-54-234-202-177.compute-1.amazonaws.com (Reading database ... 65%
ec2-54-234-202-177.compute-1.amazonaws.com (Reading database ... 70%
ec2-54-234-202-177.compute-1.amazonaws.com (Reading database ... 75%
ec2-54-234-202-177.compute-1.amazonaws.com (Reading database ... 80%
ec2-54-234-202-177.compute-1.amazonaws.com (Reading database ... 85%
ec2-54-234-202-177.compute-1.amazonaws.com (Reading database ... 90%
ec2-54-234-202-177.compute-1.amazonaws.com (Reading database ... 95%
ec2-54-234-202-177.compute-1.amazonaws.com (Reading database ... 100%
ec2-54-234-202-177.compute-1.amazonaws.com (Reading database ...
ec2-54-234-202-177.compute-1.amazonaws.com 50668 files and directories currently
 installed.)
ec2-54-234-202-177.compute-1.amazonaws.com
ec2-54-234-202-177.compute-1.amazonaws.com Unpacking chef (from .../chef_11.4.0_
amd64.deb) ...
ec2-54-234-202-177.compute-1.amazonaws.com
ec2-54-234-202-177.compute-1.amazonaws.com Setting up chef (11.4.0-1.ubuntu.11.0
4) ...
ec2-54-234-202-177.compute-1.amazonaws.com
ec2-54-234-202-177.compute-1.amazonaws.com Thank you for installing Chef!
ec2-54-234-202-177.compute-1.amazonaws.com
ec2-54-234-202-177.compute-1.amazonaws.com Starting Chef Client, version 11.4.0
[0m
ec2-54-234-202-177.compute-1.amazonaws.com
ec2-54-234-202-177.compute-1.amazonaws.com Creating a new client identity for ip
-10-202-85-20.ec2.internal using the validator key.
ec2-54-234-202-177.compute-1.amazonaws.com
ec2-54-234-202-177.compute-1.amazonaws.com resolving cookbooks for run list: []
[0m
ec2-54-234-202-177.compute-1.amazonaws.com
ec2-54-234-202-177.compute-1.amazonaws.com Synchronizing Cookbooks:
ec2-54-234-202-177.compute-1.amazonaws.com
ec2-54-234-202-177.compute-1.amazonaws.com Compiling Cookbooks...
ec2-54-234-202-177.compute-1.amazonaws.com
ec2-54-234-202-177.compute-1.amazonaws.com [2013-03-31T15:21:44+00:00] WARN: Nod
e ip-10-202-85-20.ec2.internal has an empty run list.
ec2-54-234-202-177.compute-1.amazonaws.com
ec2-54-234-202-177.compute-1.amazonaws.com Converging 0 resources
ec2-54-234-202-177.compute-1.amazonaws.com
ec2-54-234-202-177.compute-1.amazonaws.com Chef Client finished, 0 resources upd
ated
ec2-54-234-202-177.compute-1.amazonaws.com

D:\Tools\Chef\chef-repo-master>knife bootstrap ec2-54-234-202-177.compute-1.amaz
onaws.com -x ubuntu -i E:\Projects\CloudSeed\AwsSelfUse\Group4-XiaofengFeng.pem
--sudo

3. 验证下,这台EC2已经变成了一个node,执行:D:\Tools\Chef\chef-repo-master>knife client list,可以看到如下输出,第一个就是那台EC2:

ip-10-202-85-20.ec2.internal
pch-validator

3. 也可以使用命令来查询该node的信息:D:\Tools\Chef\chef-repo-master>knife client show ip-10-202-85-20.ec2.internal

admin:      false
chef_type:  client
json_class: Chef::ApiClient
name:       ip-10-202-85-20.ec2.internal
public_key:




你可能感兴趣的:(Chef学习之五:Knife bootstrap 一台 Ubuntu EC2 机器)