我想使用现有的木偶模块在服务器上提供多组东西,最简单的例子是:
file { "/var/www/MYVARIABLEHERE":
ensure => "directory",
}
mysql::db { MYVARIABLEHERE:
user => MYVARIABLEHERE,
password => MYVARIABLEHERE,
host => 'localhost',
grant => ['all'],
}
有没有办法把它抽象出来,这样我就可以说一组预定义的选项,然后将它们传递到现有的 puppet 模块中,这样我就不会得到一个数千行长的清单文件?
根据下面的答案,我已经设置:
define mySites {
mysql::db { $name:
user => $name,
password => $name,
host => 'localhost',
grant => ['all'],
}
file { "/var/www/${name}.drupal.dev":
ensure => "directory",
}
}
然后我打电话给:
mySites {"site": $name => "test", }
并得到以下错误:
Could not parse for environment production: Syntax error at 'name'; expected '}'