我正在创建一个“站点模块”来管理多个VM。
我使用此项目作为模板:https://github.com/nvalentine-puppetlabs/puppet-site基于Craig Dunn在http://www.craigdunn.org/2012/05/239/
描述的惯例。我使用的是Puppet 3.4.3(Puppet Enterprise 3.2.1)。
我修改了角色类以包含基本配置文件。
class site::role inherits site::role::params {
require site
notify { "site::role": }
include site::profile::base
}
class site::profile::base inherits site::profile::base::params {
require site::profile
notify { "site::profile::base": }
include site::users
package { [
'htop',
'rsync',
'openssl',
'man',
'wget',
'nano',
'lsb-release',
'tree' ]:
ensure => present,
}
}
我已将类site :: role :: www添加到我的节点。
到目前为止,一切都运行良好。所有包都已安装。
然后我尝试创建一个www角色和一个webserver配置文件。
class site::role::www inherits site::role::www::params {
require site::role
notify { "site::role::www": }
# perhaps all nodes at your site use this as a base?
include site::profile::webserver
}
class site::profile::webserver inherits site::profile::webserver::params {
require site::profile
notify { "site::profile::webserver": }
file { "/home/httpd/":
ensure => "directory",
}
->
class { 'apache':
serveradmin => 'dev@domain.com',
server_tokens => 'Prod'
}
->
apache::vhost { "$ipaddress":
port => '80',
docroot => '/home/httpd/exploit',
}
include apache::mod::php
}
但是,在网络服务器配置文件中声明的修改都没有考虑在内......
模块结构:
site/
|-- LICENSE
|-- Modulefile
|-- README.md
|-- manifests
| |-- init.pp
| |-- params.pp
| |-- profile
| | |-- base
| | | `-- params.pp
| | |-- base.pp
| | |-- params.pp
| | |-- webserver
| | | `-- params.pp
| | `-- webserver.pp
| |-- profile.pp
| |-- role
| | |-- params.pp
| | |-- www
| | | `-- params.pp
| | `-- www.pp
| |-- role.pp
| `-- users.pp
|-- metadata.json
`-- tests
|-- init.pp
|-- site_profile.pp
|-- site_profile_base.pp
`-- site_role.pp
代理节点上的classes.txt内容:
root@****:/var/opt/lib/pe-puppet# cat classes.txt
pe_mcollective
site::role::www
settings
default
pe_mcollective
pe_mcollective::params
pe_mcollective::role::agent
pe_mcollective::server
pe_mcollective::server::plugins
pe_mcollective::shared_key_files
site::role::www::params
site::params
site::role::params
site::role::www
site::role
site
site::profile::base::params
site::profile::params
site::profile::base
site::profile
site::users