如何将 Foreman 主机组与 Puppet 一起使用? [英] How can I use Foreman host groups with Puppet?

查看:75
本文介绍了如何将 Foreman 主机组与 Puppet 一起使用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这个清单:

$foremanlogin = file('/etc/puppetlabs/code/environments/production/manifests/foremanlogin.txt')
$foremanpass = file('/etc/puppetlabs/code/environments/production/manifests/foremanpass.txt')

$query = foreman({foreman_user => "$foremanlogin",
                  foreman_pass => "$foremanpass",
                  item         => 'hosts',
                  search       => 'hostgroup = "Web Servers"',
filter_result => 'name',
})

$quoted = regsubst($query, '(.*)', '"\1"')
$query6 = join($quoted, ",")

notify{"The value is: ${query6}": }

node ${query6} {

package { 'atop':
    ensure => 'installed',
  }

}

当我在代理上执行此操作时出现错误:

When I execute this on agent I got error:

Server Error: Could not parse for environment production: Syntax error at ''

我的节点块出错

node ${query6} {

package { 'atop':
    ensure => 'installed',
  }

}

我从 notify 中看到正确的输出,我的变量如下所示:

I see correct output from notify, my variable looks like this:

"test-ubuntu1","test-ubuntu2"

节点清单格式正确的变量.

Variable in correct node manifest format.

我不明白怎么了?变量 query6 是正确的.

I don't understand whats wrong? variable query6 is correct.

如何解决这个问题?

推荐答案

我只是想将此清单应用到领班主机组,该怎么做才对?

I just want to apply this manifest to foreman host group, how to do this right?

在 Puppet 方面,您创建来描述如何管理机器整体配置的适当子单元,并将这些类组织成模块.这方面的细节太广泛,无法在 SO 答案中涵盖——这类似于回答我如何用 [语言 X] 进行编程?".

On the Puppet side, you create classes describing how to manage appropriate subunits of your machines' overall configuration, and organize those classes into modules. The details of this are far too broad to cover in an SO answer -- it would be analogous to answering "How do I program in [language X]?".

准备好您的课程后,任务是指示 Puppet 将哪些课程分配给每个节点.这称为分类".节点块是执行分类的一种方式.另一个是外部节点分类器 (ENC).还有一些基于站点清单中普通顶级 Puppet 代码的替代方案.这些都不是排他性的.

Having prepared your classes, the task is to instruct Puppet which ones to assign to each node. This is called "classification". Node blocks are one way to perform classification. Another is external node classifiers (ENCs). There are also alternatives based on ordinary top-level Puppet code in your site manifest. None of these are exclusive.

如果您使用 Foreman 运行 Puppet,那么您应该配置 Puppet 以使用 Foreman 提供的 ENC.然后您使用 Foreman 将(Puppet)类分配给节点和/或节点组,Foreman 通过其 ENC 将详细信息传达给 Puppet.这根本不需要 Puppet 端的任何分类代码.

If you are running Puppet with The Foreman, however, then you should configure Puppet to use the ENC that Foreman provides. You then use Foreman to assign (Puppet) classes to nodes and / or node groups, and Foreman communicates the details to Puppet via its ENC. That does not require any classification code on the Puppet side at all.

另见主机组如何与工头合作?

这篇关于如何将 Foreman 主机组与 Puppet 一起使用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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