Puppet:模块中的多个清单
我正在尝试创建Puppet:模块中的多个清单,puppet,Puppet,我正在尝试创建Puppet模块来设置我的web服务器 我想要的是将配置拆分为逻辑模块(按服务分类清单:webserver,database,ftp等),但我不知道如何在init.pp 我只将它用于puppet apply而不是服务器客户端配置 我的文本模块清单(kp/manifests/init.pp): 和其他清单(kp/manifests/testfile.pp) 文件说: If a class is defined in a module, you can declare that cla
Puppet
模块来设置我的web服务器
我想要的是将配置拆分为逻辑模块(按服务分类清单:webserver
,database
,ftp
等),但我不知道如何在init.pp
我只将它用于puppet apply
而不是服务器客户端配置
我的文本模块清单(kp/manifests/init.pp):
和其他清单(kp/manifests/testfile.pp)
文件说:
If a class is defined in a module, you can declare that class by name in any manifest. Puppet will automatically find and load the manifest that contains the class definition.
但是当我运行puppet apply init.pp
时,我收到了错误消息
Could not find class kp::testfile for myhost.com at /myDir/puppetModules/kp/manifests/init.pp:2 on node vagrant.example.com
事实
位于/myDir/puppetModules/
中,因此此处没有问题modulepath
- 傀儡版本v2.7.11
- Ubuntu 12.04 LTS
提前谢谢 您的kp::testfile是定义的类型,而不是类。要使用已定义的类型,您需要像以下那样声明它:
kp::testfile { 'name': }
尝试重新定义kp::testfile,如
class kp::testfile {
$value = template("kp/some.erb")
file { 'testfile':
path => '/tmp/my.txt',
ensure => file,
content => $value
}
}
你可能会有更好的运气。哦,我的天啊,我花了这么多时间在这上面,而且很简单。我现在不知道我是从哪里得到这个带有“define”的例子的,但我只是没有注意到,因为我写了它。谢谢,看起来它现在可以工作了!
kp::testfile { 'name': }
class kp::testfile {
$value = template("kp/some.erb")
file { 'testfile':
path => '/tmp/my.txt',
ensure => file,
content => $value
}
}