木偶:不同节点上资源之间的关系 [英] Puppet: relationship between resources on different nodes

查看:84
本文介绍了木偶:不同节点上资源之间的关系的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道我们可以指定资源之间的关系,从而确定部署顺序。但是是否可以在Puppet中不同节点上的资源之间创建关系?

I know that we can specify relationship between resources, which determines the deployment order. But is it possible to create relationship between resources on different nodes in Puppet?

例如,我在节点A中有apache Web服务器,在节点B中有mysql服务器。我想要在启动apache Web服务器之前先启动mysql。我该如何用人偶语言表达?

For example, I have apache web server in node A and mysql server in node B. I want to start mysql first before starting apache web server. How could I express this in Puppet language?

我尝试了以下代码:

node ‘host1’ {
  @@service { ‘mysql’:
    ensure => running,
    tag => ‘host1-mysql’,
  }
}
node ‘host2’ {
  service { ‘apache2’:
    ensure => running,
  }
  Service<<| tag == ‘host1-mysql’ |>> -> Service[‘apache2’]
}

但是它没有用-编译错误。还有其他解决方案吗?

But it didn't work - produced a compile error. Any other solution?

推荐答案

在分布式人偶设置中,不能保证申请顺序。

In a distributed "puppet" setup, the apply order isn't guaranteed.

木偶不要在多个节点上进行编排。充其量,您的更改将在计算机上多次应用,并且最终将收敛到所需状态

Puppet don't do orchestration across multiple nodes. At best, your changes will get applied multiple times on the machines and finally will converge to the desired state.

依赖项只能在同一环境下工作节点。实际上,您可以获取其他节点导出的资源值(例如,配置数据库的防火墙以允许Web服务器执行sql)
或用hiera作弊以知道谁拥有 db和 app角色。

Dependencies only work in a same node. You can actually get values of resources exported by others nodes (for eg to configure the firewall of your db to allow the web server to do sql) Or cheat with hiera to know who have the "db" and "app" roles.

有关编排,请参见Capistrano之类的工具,例如 mcollective 。 ,可笑,...

For orchestration see tools like mcollective, capistrano, ansible,...

这篇关于木偶:不同节点上资源之间的关系的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆