我们如何使用厨师连接基于群集的软件?

pho*_*nix 5 python automation orchestration chef-infra

作为平台设置编排的一部分,我们使用python包在云中的机器集群上安装各种软件包.

我们有以下场景:

  1. 在许多软件中,我们的软件之一是Ambari(帮助管理hadoop平台).
  2. 它的工作原理如下 - 报告1个ambari-server的"n"个集群机器.
  3. 对于要进行报告的每个集群机器,我们必须在每个集群机器上安装ambari-agent,并使用它所支持的ambari服务器修改其属性文件以报告并启动ambari-agent.

我们能做什么 - 我们成功地在单独的厨师烹饪书的帮助下在我们的集群机器中单独安装ambari服务器和ambari代理.

我们无法做什么 - 我们如何修改每台机器的ambari-agent属性文件,使其指向我们的ambari服务器IP.总的来说,作为Chef orchestration的一部分,将基于群集的软件连接起来的优雅方式是什么?

NB:.ambari-server是在飞行中创建的,因此它的IP是在运行时获得的.

可能吗?有没有上述问题的替代方案?

谢谢

Dra*_*ter 1

这是Chef-serversearch的场景。

您必须更改安装 ambari 代理的配方才能动态获取 ambari 服务器的 IP。

首先,您运行配置 ambari 服务器的配方。当 Chef 成功运行后,它会将有关节点的一些信息填充到 Chef-server,包括应用于该特定节点的配方和角色。您可以转到 Chef-server 并检查节点属性,特别是“recipes”属性。

现在更改您的 ambari 代理配方。我不知道代理的配置文件到底是什么样子,但我们只对其中设置主服务器 IP 的一行感兴趣。

创建配置文件的模板并将其添加到说明书中。将硬编码的主 IP 值替换为<%= @master_ip %>

更改 ambari 代理配方,以便正确设置该值:

# search for the server node. I expect server node was configured with
# ambari::server recipe. If not, change it to the appropriate value and
# don't fortget to escape colons.
ambari_server_node = search( :node, 'recipes:ambari\:\:server' )

# now create the configuration file on ambari agent node from 
# the previously created template and pass the value for the @master_ip
# variable
template '/right/path/on/target/node/config.file' do
  [...]
  variables( :master_ip => ambari_server_node['ipaddress'] )
end
Run Code Online (Sandbox Code Playgroud)