Puppet应用错误:在节点uys0115上找不到默认节点或名称为'uys0115'的节点。

6

我在两个节点上安装了puppet,服务器节点主机名为“uys0115”,客户端节点主机名为“uys0119”,服务器节点已经签署了客户端节点。当我执行命令:puppet cert list --all时,我们可以看到:

+ "uys0115" (24:55:95:77:8E:60:33:77:C8:D4:74:EA:01:21:BD:5A)
+ "uys0119" (86:53:1B:81:E5:4F:88:23:E8:34:E1:AB:03:D4:AE:7C)

Puppet的主目录是/etc/puppet/,我编写了一个示例并按以下方式组织文件:

/etc/puppet/--
             |-/manifests/site.pp
             |-/modules/test/--  
                              |-/files/text.txt
                              |-/manifests/init.pp
                              |-/manifests/test.pp

/etc/puppet/modules/test/manifests/test.pp 中的代码如下:

class test1 {
package { "bison":
        ensure=>"installed",
}
exec { "puppet test":
        command=>"/bin/touch /tmp/puppet-test",
}
file { "/tmp/test.txt":
        ensure => "present",
        source => "puppet:///modules/test/test.txt"
}
}

/etc/puppet/modules/test/manifests/init.pp中的代码只是import "*"; 而在/etc/puppet/manifests/site.pp中的代码如下:

import "test"
node default {
        include "test1"
}

当我在客户端节点uys0119上执行命令puppet agent --test --server uys0115时, 它成功执行并在目录/tmp/中创建了两个文件puppet-test和test.txt。 在服务器节点上执行命令puppet apply site.pp, 同样也成功执行并创建了两个文件。然而,终端输出了两个警告信息:

warning: Could not retrieve fact fqdn
warning: Host is missing hostname and/or domain: uys0115

当我将代码更改为以下内容:/etc/puppet/manifests/site.pp

import "test"
node "uys0119" {
        include "test1"
}

在服务器节点中执行命令puppet apply site.pp时,出现了失败并输出错误消息:

warning: Could not retrieve fact fqdn
warning: Host is missing hostname and/or domain: uys0115
warning: Host is missing hostname and/or domain: uys0115
Could not find default node or by name with 'uys0115' on node uys0115

但是客户端节点也可以成功执行命令puppet agent --test --server uys0115。有人能解释一下吗? 如果我想让服务器节点向客户端节点发送一些请求并使一些客户端节点响应服务器并产生结果。当使用puppet时我该怎么做?有人能给个例子吗?非常感谢!!!

1个回答

4

服务器puppet既充当puppet主控端又充当puppet节点。

当您按照下面的方式编辑site.pp时:

import "test"
node default {
    include "test1"
}

所有连接到Puppet Master的Puppet节点将执行“test1”类中定义的操作。因此,在uys0115uys0119(均视为Puppet节点)中都找到了两个文件。

当更改您的site.pp如下:

import "test"
node "uys0119" {
        include "test1"
}

puppet节点uys0115在site.pp中找不到其定义(因为它只定义了uys0119),puppet master输出错误信息如下:

Could not find default node or by name with 'uys0115' on node uys0115

这里有一个修改过的site.pp,可以消除这个错误:
import "test"
node "uys0119" {
        include "test1"
}
node "uys0115" {
        include "test1"
}

在Puppet的Master/Slave模式下,建议使用完全限定域名(FQDN),例如uys0115.localdomain,这样就不会出现以下警告:

warning: Host is missing hostname and/or domain: uys0115

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