(2)puppet单机测试命令apply

单机测试apply命令:
以独立的方式,将清单中的配置应用于本机,也就是说,根据配置清单配置当前服务器。

1.apply这个子命令有很多选项,而我们常用的有debug、verbose、noop等,debug表示显示调试信息,verbose表示显示详细信息,noop表示测试模式模拟执行

[root@lvs-master manifests]# puppet apply --verbose --noop test.pp
Notice: Compiled catalog for lvs-master.lvs-master in environment production in 0.12 seconds
Info: Applying configuration version '1495770577'
Notice: /Stage[main]/Main/File[/tmp/12567.txt]/ensure: current_value absent, should be present (noop)
Notice: Class[Main]: Would have triggered 'refresh' from 1 events
Notice: Stage[main]: Would have triggered 'refresh' from 1 events
Notice: Finished catalog run in 0.03 seconds

从测试执行的返回信息中,可以看到,当我们执行puppet apply命令以后,第一步就是将对应的test.pp这个清单编译成catalog,
之前已经说过,清单不能直接运行,需要先编译成catalog,这里也验证了我们的理论。
测试信息中的绿色字体是一条应用配置的版本号,我们不用在意它。

2.这次我们在执行puppet命令时不添加–noop选项,也就是说不进行测试执行,而是真正的执行

[root@lvs-master manifests]# puppet apply --verbose  test.pp
Notice: Compiled catalog for lvs-master.lvs-master in environment production in 0.08 seconds
Info: Applying configuration version '1495773784'
Notice: /Stage[main]/Main/File[/tmp/12567.txt]/ensure: created
Notice: Finished catalog run in 0.03 seconds
[root@lvs-master manifests]# cat /tmp/12567.txt 
aaaaababbau

可以发现,puppet已经按照test.pp清单中的配置,正确的创建了一个名为12567.txt的文件了

参考链接:
http://www.zsythink.net/archives/331

原文地址:https://www.cnblogs.com/fanren224/p/8457242.html