2

我正在创建一个“站点模块”来管理多个 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 角色和一个网络服务器配置文件。

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
4

0 回答 0