我有一個包含這個短語(我的問題是關於在年底生產塊)的傀儡清單,用於設置MySQL配置文件:添加具有puppetlabs mysql的模塊定製服務器選項
class web_mysql_server {
include web_mysql::packages
include web_mysql::mysql_server
}
class web_mysql::packages {
Package { ensure => installed }
package { 'libmysqlclient-dev': }
}
class web_mysql::mysql_server {
# Qualified keys (dot notation: web_mysql_server.mysql_database) isn't available
# until hiera 2.0.
$mysql_config = hiera('web_mysql_server')
# https://forge.puppetlabs.com/puppetlabs/mysql
class { '::mysql::server':
root_password => '...',
remove_default_accounts => true,
override_options => {
# The data in this block gets written to /etc/mysql/my.cnf.
'mysqld' => {
max_connections => '1024', # No good reason but parroting others.
key_buffer_size => '512M', # No good reason but parroting others.
},
'production' => {
adaptor => 'mysql2',
database => $mysql_config['mysql_database'],
user => $mysql_config['mysql_username'],
password => $mysql_config['mysql_password'],
host => '0.0.0.0',
encoding => 'UTF8',
},
但有時我可能會喜歡數據庫作爲臨時數據庫,所以稱它爲生產有點混亂。沒問題,我最近了解到hiera,這是我的錘子對所有釘子今天:
$mysql_config['mysql_name'] => {
adaptor => 'mysql2',
database => $mysql_config['mysql_database'],
user => $mysql_config['mysql_username'],
password => $mysql_config['mysql_password'],
host => '0.0.0.0',
encoding => 'UTF8',
},
不,那是不行的,雖然錯誤("syntax error at line (...with '=>'...), expected '}'"
)是不是非常發人深省。
(「Key」可能是錯誤的詞,請糾正我,我對puppet有點新,而這本身也可能是我爲什麼不能通過Google搜索和閱讀來回答這個問題。)
感謝您的指點。
看來你傳遞'production'作爲參數傳遞給一個類或資源, 對?你能發佈更大的背景,包括類/資源嗎? – Mifeet
@Mifeet當然,完成了。 – jma
你的代碼有問題。在一個類定義中,比如'web_mysql :: mysql_server',你可以包含/聲明資源,其他類,賦值給變量等。''production'=> {...}'代碼段既不是。你期望這段代碼能做什麼? – Mifeet