我尝试将敏感的应用配置数据传递到部署时的实例,例如数据库连接信息。
继承自定义堆栈json字符串
{
"deploy": {
"development": {
"app" : {
"api_key" : "data",
"api_secret" : "data",
"gmail_account" : "data",
"gmail_account_password" : "data"
},
"database" : {
"db_hostname" : "data",
"db_username" : "data",
"db_password" : "data",
"db_database" : "data"
}
}
}
}
我的回购设置就像这样
配方/ appsetup.rb
node[:deploy].each do |application, config|
template "#{deploy[:deploy_to]}/current/config.php" do
source "config.php.erb"
mode 0660
group deploy[:group]
if platform?("ubuntu")
owner "www-data"
elsif platform?("amazon")
owner "apache"
end
variables(
:api_key => (deploy[:app][:api_key] rescue nil),
:api_secret => (deploy[:app][:api_secret] rescue nil),
:gmail_account => (deploy[:app][:gmail_account] rescue nil),
:gmail_account_password => (deploy[:app][:gmail_account_password] rescue nil),
:db_hostname => (deploy[:database][:db_hostname] rescue nil),
:db_username => (deploy[:database][:db_username] rescue nil),
:db_password => (deploy[:database][:db_password] rescue nil),
:db_database => (deploy[:database][:db_database] rescue nil)
)
end
end
然后是php模板 模板/默认/ config.php.erb
$config = array();
$config['api_key'] = '<%= @api_key%>';
$config['api_secret'] = '<%= @api_secret%>';
$config['gmail_account'] = '<%= @gmail_account%>';
$config['gmail_account_password'] = '<%= @gmail_account_password%>';
$db = array();
$db['default']['hostname'] = '<%= @db_hostname%>';
$db['default']['username'] = '<%= @db_username%>';
$db['default']['password'] = '<%= @db_password%>';
$db['default']['database'] = '<%= @db_database%>';
我会在Custom Chef Recipes Deploy下放置什么?我尝试了很多东西,但似乎无法装载我的食谱。
答案 0 :(得分:3)
您的回购设置似乎配置为包含单个食谱。 OpsWorks要求您的Custom Cookbooks存储库包含一系列烹饪书。
查看AWS OpsWorks Cookbooks官方文件夹结构: https://github.com/aws/opsworks-cookbooks
在你的情况下: