简体   繁体   English

在机架空间上使用jclouds-chef安装厨师客户端

[英]installing chef client using jclouds-chef on rackspace

I am running into a problem trying to automate everything. 我在尝试使一切自动化时遇到问题。 I was trying to create few brand new servers on rackspace 我试图在机架空间上创建一些全新的服务器

  1. Node 1 - Chef Server installed. 节点1-已安装Chef服务器。
  2. Node 2 - Chef Client 节点2-Chef客户端
  3. Node 3 - Chef Client and was able to install chef-server on node 1 and was trying to install chef client on other nodes using jclouds-chef api. 节点3-Chef Client,能够在节点1上安装Chef-server,并尝试使用jclouds-chef api在其他节点上安装Chef Client。 I am running the code from my local machine and connecting to rackspace. 我正在从本地计算机运行代码并连接到机架空间。

Q1 . Q1。 How do I get knife tool configured on Node 1 remotely with out interactive our with interactive. 如何在不进行交互的情况下在节点1上远程配置刀具工具。 Is there any way to do it using the jclouds ? 有什么办法可以使用jclouds吗?

Q2 . Q2。 How do I get the client.pem file and validation. 我如何获得client.pem文件和验证。 pem file which are not available on my local machine when i try to use the above example to configure the nodes with chef client. 当我尝试使用上述示例通过Chef客户端配置节点时,pem文件在本地计算机上不可用。

Q3 . Q3。 How do I get client.pem created using a script or do it remotely ? 我如何使用脚本创建client.pem或远程创建它?

Any help will be appreciated. 任何帮助将不胜感激。

The tricky part here is installing the Chef Server. 这里最棘手的部分是安装Chef Server。 The Chef API does not provide a way to get the private key for the clients; Chef API没有提供一种获取客户端私钥的方法。 it allows you to regenerate and download it, but in the first instance you need to have a valid one to perform that call to the API. 它允许您重新生成和下载它,但是在第一个实例中,您需要具有一个有效的API才能执行对该API的调用。

The easiest approach is to generate a key pair locally, and then use it to configure the client and validator in the Chef Server and configure the client nodes with them too. 最简单的方法是在本地生成密钥对,然后使用它来在Chef Server中配置客户端和验证器,并使用它们来配置客户端节点。 This involves a tricky step by storing the private key in the internal Chef Server database (it uses Postgres), but this has worked fine for me. 通过将私钥存储在内部Chef Server数据库中(使用Postgres),这涉及到一个棘手的步骤,但这对我来说很好。

This could be a script to install and configure a Chef Server, and override the keys for the default client and validator with a known ones. 这可能是一个脚本,用于安装和配置Chef Server,并用已知的脚本覆盖默认客户端和验证器的密钥。

First of all, generate the key pairs locally. 首先,在本地生成密钥对。 This can be done programmatically, or with the following commands: 这可以通过编程或使用以下命令来完成:

# Generate the keys for the client and the validator
ssh-keygen -t rsa -N "" -f client.pem      # This creates the client.pem and client.pem.pub
ssh-keygen -t rsa -N "" -f validator.pem   # This creates the validator.pem and validator.pem.pub

Once the keys have been generated, you can use the following script to install and configure the Chef Server. 生成密钥后,您可以使用以下脚本来安装和配置Chef Server。

# Install the Chef Server (assumes an Ubuntu operating system)
# You can get the URLs for other operating systems at http://www.getchef.com
wget https://opscode-omnibus-packages.s3.amazonaws.com/ubuntu/12.04/x86_64/chef-server_11.0.11-1.ubuntu.12.04_amd64.deb
dpkg -i chef-server_11.0.11-1.ubuntu.12.04_amd64.deb
chef-server-ctl reconfigure

# Install the client public keys in the database
CLIENTKEY=`cat client.pem.pub`
VALIDATORKEY=`cat validator.pem.pub`
/opt/chef-server/embedded/bin/psql -U opscode_chef -c "update clients set public_key = \"$CLIENTKEY\" where name = 'chef-validator'"
/opt/chef-server/embedded/bin/psql -U opscode_chef -c "update clients set public_key = \"$VALIDATORKEY\" where name = 'chef-webui'"

# Override the default keys with the auto-generated ones
cp -f client.pem /etc/chef-server/chef-webui.pem
cp -f validator.pem /etc/chef-server/chef-validator.pem

At this point you will have the Chef Server installed and with the default clients configured with the generated keys. 此时,您将安装Chef Server,并使用生成的密钥配置默认客户端。

Having these scripts will help you with the bootstrap process. 拥有这些脚本将帮助您进行引导过程。 You may have to upload the generated keys to the node first. 您可能必须先将生成的密钥上载到该节点。 You can do it using an ssh client as shown in the jclouds compute guide . 您可以使用ssh客户端执行此操作,如jclouds计算指南中所示

Once you have the node with the Chef server configured, provisioning the client nodes is pretty straightforward with jclouds-chef. 在配置了Chef服务器的节点之后,使用jclouds-chef即可轻松配置客户端节点。 You can follow the Chef guide or the procedure described in this stack overflow question . 您可以按照Chef指南此堆栈溢出问题中描述的过程进行操作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM