我在两个节点上安装了puppet,服务器节点主机名为“uys0115”,客户端节点主机名为“uys0119”,服务器节点已经设置了客户端节点。当我执行commad: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
。任何人都可以解释一下吗?
如果我想要服务器节点发送一些repuests到客户端节点并驱动一些客户端节点响应服务器并产生结果。使用木偶时该怎么办?有人能举个例子吗?非常感谢!!!
答案 0 :(得分:4)
服务器木偶充当木偶主节点和木偶节点。
编辑site.pp时如下:
import "test"
node default {
include "test1"
}
连接到puppet master的所有puppet节点都将执行类“test1”中定义的操作。因此,您在uys0115
和uys0119
中找到了两个文件(视为木偶节点)。
将site.pp更改为以下内容时:
import "test"
node "uys0119" {
include "test1"
}
puppet node uys0119
无法在site.pp和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"
}
在木偶主/从模式下,你最好使用fqdn,例如uys0115.localdomain
,然后不会显示以下警告
warning: Host is missing hostname and/or domain: uys0115