我有以下简单的木偶配方:
# Apache
class { 'apache':
mpm_module => 'prefork', # Determines which MPM is loaded and configured for the HTTPD process (event, itk, peruser, prefork, worker or false).
}
include apache::mod::prefork # Implements a non-threaded, pre-forking web server
include apache::mod::rewrite # Provides a rule-based rewriting engine to rewrite requested URLs on the fly.
include apache::mod::expires # Generation of Expires and Cache-Control HTTP headers according to user-specified criteria.
include apache::mod::headers # Customization of HTTP request and response headers.
include apache::mod::php # Installs and configures mod_php.
# MySQL
# Note: mysql module will manage all the restarts needed after all the configuration changes.
class { '::mysql::server':
root_password => 'root', # Sets MySQL root password.
override_options => {
'mysqld' => {
'log' => 'ON',
}
}
}
# Import many manifest files with vhost definitions.
import 'vhosts/*.pp'
我正在导入许多 vhost 定义文件(包括数据库),例如:
# Apache vhost.
apache::vhost { 'foo1':
docroot => '/var/www/foo1',
directories => [
{ path => '/var/www/foo1',
allow_override => ['All'],
},
],
}
# MySQL database.
mysql_database { 'foo1':
ensure => 'present',
}
但问题是,导入清单是已弃用每次运行时都会出现以下红色警告:
$ sudo puppet apply foo.pp
Warning: The use of 'import' is deprecated at foo.pp:49. See http://links.puppetlabs.com/puppet-import-deprecation
(at /usr/lib/ruby/vendor_ruby/puppet/parser/parser_support.rb:110:in `import')
因此问题是,当前导入多个清单文件(每个文件用于不同的 vhost)的简单、好用的方法是什么?
我期望以下结构:
main-config.pp
includes/vhost-foo1.pp
includes/vhost-foo2.pp
includes/vhost-foo3.pp
...
答案1
来自您发布的链接,推荐的方式是在类中定义 vhost 并包含这些 vhost(在节点清单中或通过 ENC),或者为每个节点手动定义每个 vhost(在节点清单中)>