Deployment 在chef环境中管理应用程序配置
我是chef的新手,一直在努力寻找如何在环境食谱中配置应用程序配置的最佳实践[source#1] 我正在编写的环境食谱应该做到以下几点:Deployment 在chef环境中管理应用程序配置,deployment,configuration,chef-infra,Deployment,Configuration,Chef Infra,我是chef的新手,一直在努力寻找如何在环境食谱中配置应用程序配置的最佳实践[source#1] 我正在编写的环境食谱应该做到以下几点: 通过创建仅适用于此部署的目录、用户等,为自定义应用程序部署准备节点 添加特定于应用程序部署的初始化和监视脚本 定义应用程序配置设置 这最后一项责任是一个特别棘手的问题 应用程序部署的示例配置文件可能如下所示: { "server": { "port": 9090 }, "session": { "pr
- 通过创建仅适用于此部署的目录、用户等,为自定义应用程序部署准备节点
- 添加特定于应用程序部署的初始化和监视脚本
- 定义应用程序配置设置
{
"server": {
"port": 9090
},
"session": {
"proxy": false,
"expires": 100
},
"redis": [{
"port": 9031,
"host": "rds01.prd.example.com"
}, {
"port": 9031,
"host": "rds02.prd.example.com"
}],
"ldapConfig": {
"url": "ldap://example.inc:389",
"adminDn": "CN=Admin,CN=Users,DC=example,DC=inc",
"adminUsername": "user",
"adminPassword": "secret",
"searchBase": "OU=BigCustomer,OU=customers,DC=example,DC=inc",
"searchFilter": "(example=*)"
},
"log4js": {
"appenders": [
{
"category": "[all]",
"type": "file",
"filename": "./logs/myapp.log"
}
],
"levels": {
"[all]": "ERROR"
}
},
"otherService": {
"basePath" : "http://api.prd.example.com:1234/otherService",
"smokeTestVariable" : "testVar"
}
}
此部署配置文件的某些部分比其他部分更稳定。虽然这可能因应用程序和设置而异,但为了简单起见,我更喜欢在不同的环境中保持相同的端口号和用户名
让我对配置设置进行分类:
knife environment edit berkshelf-api-production
稳定性质
- 会议
- 服务器
- log4js.appenders
- ldapConfig.adminUsername
- ldapConfig.searchFilter
- otherService.basePath
- redis.port
- log4js.levels
- otherService.smokeTestVariable
- redis.host:
rds01.[environment].example.com
- otherService.basePath:
http://api.[环境].example.com:1234/otherService
- ldapConfig.adminPassword
- 我希望只有一种方法可以设置配置设置
- 更改开发人员的配置文件应该相当简单(他们在推动测试之前在本地机器上使用Vagrant)
- 密码必须是安全的
- chef cookbook在与源代码相同的git存储库中进行管理
- 一些配置设置需要很大的灵活性;例如,我的示例配置中的
设置可能包含更多的log4js
s,其中包含几十个相当非结构化的变量appender
Jamie Winsor在chefconf做了一次演讲,进一步解释了基本原理和用法:
knife environment edit berkshelf-api-production
总之,厨师给了我们很多选择。我将提出以下一般性建议:
- 另请参见工具。旨在使环境cookbook模式更易于实现
- 我没有提到使用角色。这些属性还可以用于在运行时重写属性,但在专用的chef环境中捕获所有内容可能更简单。角色似乎更适合捕获应用程序组件特有的信息