如何将 .pp 应用到节点
How to apply a .pp to a node
我是 puppet 的新手,我无法应用 .pp 来更改 motd。
我有/etc/puppetlabs/code/modules/helloworld/manifests
init.pp
class helloworld {
notify { 'hello, world!': }
}
node 'kp2.keepy-i.com'{
include helloworld
}
motd.pp
class helloworld::motd {
file { '/etc/motd':
owner => 'root',
group => 'root',
mode => '0644',
content => "hello, world!\n",
}
}
如果我执行 puppet agent -t --verbose
Info: Using configured environment 'production'
Info: Retrieving pluginfacts
Info: Retrieving plugin
Info: Caching catalog for kp2.keepy-i.com
Info: Applying configuration version '1463497694'
Notice: Applied catalog in 0.04 seconds
但没有任何变化。
提前致谢
/etc/puppetlabs/code/modules
是基本模块路径。你不应该把你通过声明调用的模块放在那里。您应该将您引用的模块(例如 stdlib)放在那里。该模块属于 /etc/puppetlabs/code/environments/'environment'/modules/
。我建议阅读有关目录环境的文档。
更重要的是,您正在为默认环境编译目录 'production'。为此使用的默认清单位于 /etc/puppetlabs/code/environments/production/manifests/site.pp
。您的节点定义属于那里。节点定义中的 include helloworld
将调用位于 /etc/puppetlabs/code/environments/environment/modules/helloworld/init.pp
的模块,该模块的 class 名称应为 helloworld
,以便自动加载。如果您的 init.pp
包含 include helloworld::motd
或 class { 'helloworld::motd': }
,那么将从 helloworld
调用该清单,您将获得所需的行为。
我是 puppet 的新手,我无法应用 .pp 来更改 motd。
我有/etc/puppetlabs/code/modules/helloworld/manifests
init.pp
class helloworld {
notify { 'hello, world!': }
}
node 'kp2.keepy-i.com'{
include helloworld
}
motd.pp
class helloworld::motd {
file { '/etc/motd':
owner => 'root',
group => 'root',
mode => '0644',
content => "hello, world!\n",
}
}
如果我执行 puppet agent -t --verbose
Info: Using configured environment 'production'
Info: Retrieving pluginfacts
Info: Retrieving plugin
Info: Caching catalog for kp2.keepy-i.com
Info: Applying configuration version '1463497694'
Notice: Applied catalog in 0.04 seconds
但没有任何变化。
提前致谢
/etc/puppetlabs/code/modules
是基本模块路径。你不应该把你通过声明调用的模块放在那里。您应该将您引用的模块(例如 stdlib)放在那里。该模块属于 /etc/puppetlabs/code/environments/'environment'/modules/
。我建议阅读有关目录环境的文档。
更重要的是,您正在为默认环境编译目录 'production'。为此使用的默认清单位于 /etc/puppetlabs/code/environments/production/manifests/site.pp
。您的节点定义属于那里。节点定义中的 include helloworld
将调用位于 /etc/puppetlabs/code/environments/environment/modules/helloworld/init.pp
的模块,该模块的 class 名称应为 helloworld
,以便自动加载。如果您的 init.pp
包含 include helloworld::motd
或 class { 'helloworld::motd': }
,那么将从 helloworld
调用该清单,您将获得所需的行为。