Puppet - 如何将模块应用到 Puppet 客户端节点?

15

我刚开始接触Puppet,对这个世界非常陌生。

我有:

  • CentOS 6 Puppet主控端
  • CentOS 6 Puppet客户端

在主控端上有一个模块:

 puppet module list
/etc/puppet/modules
âââ mstanislav-yum (v1.0.0)

我想将同样的模块应用到我的木偶客户端,但我不能或者我不知道为什么

root@puppetclient: puppet agent --test
Info: Retrieving plugin
Info: Caching catalog for puppetclient
Info: Applying configuration version '1355737643'
Finished catalog run in 0.10 seconds

但客户端并没有任何更改 :-/

有什么想法吗?

10个回答

13

您还没有声明这个模块(将它分配给您的节点)...

请在site.pp文件中添加以下内容:

node 'fqdn of client' {
  include yum
} 

然后,你可以运行puppet agent -t来查看它的实际操作。


4
您可以使用以下命令查看详细的输出信息:

puppet agent --test --trace

该命令与Puppet代理程序相关,可用于检查代理程序的运行情况并获取更多详细信息。

2
尝试使用Hiera和yaml文件,我认为它更加灵活和组织得更好。
编辑site.pp文件:
node "default" {
    hiera_include('classes')
}

接下来,您可以通过简单的方式在每个特定的node.yaml文件中调用类:

classes:
  -class1
  -class2

我在Ubuntu上使用它,运行良好。


1
如果您在其他位置添加了节点声明(不建议这样做),请记得在site.pp中添加“import”配置,以引用节点清单。
这是我的配置方式。主清单DIR带有节点DIR和site.pp文件:
drwxr-xr-x. 3 root root 4096 May 19 07:23 nodes
-rw-r--r--. 1 root root   62 Jun  4 16:31 site.pp

这是我的节点目录中的节点声明:

node 'fqdn of client' {
  include yum
} 

最后,在主清单DIR中的site.pp将按如下方式导入节点:

import 'nodes/*.pp'

node default { }

1
  1. 首先从Puppet Forge安装模块
  2. 打开site.pp并添加以下行
node default {
       # include module_name
         include apache
}

然后在您的Puppet代理上运行以下命令。

sudo puppet agent --test


1

将模块应用于节点的两种主要方法是将以下内容之一添加到site.pp中:

node 'node <certname> (normally the fqdn)' {
    require <module name>
}

或者

node 'node's <certname>' {
    include <module name>
}

然后在节点中运行 puppet agent --test

require 类似于 include,但它创建依赖关系并允许多次声明相同的类,这对于想要重叠角色类非常有用。


1
您可以尝试使用“--noop”模式(干运行模式)。
puppet agent --server=YOUR_PUPPET_SERVER_NAME --onetime --no-daemonize --verbose --noop

这将显示应该进行的更改,但实际上不会改变任何内容。删除--noop将执行所有这些更改。

检查文档以了解上述命令中其他选项的说明。 http://docs.puppetlabs.com/man/agent.html


0
你必须创建一个节点定义,其中包含你想要应用的类的 'include'。

0

运行

puppet apply -e "include mstanislav-yum"

如果你想单独运行这个模块,虽然在你的 site.pp 清单中包含一个节点定义更为常见。


0

我的生产环境中的实时示例:

node 'client.io' {

class { '::selinux':
mode => 'disabled',
type => 'targeted',
}

class { 'zabbix::agent':
server => '192.168.245.11',
serveractive => '192.168.245.11',
}

include firewall
include mysql::server

}

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接