问题描述
我一直在尝试自定义tomcat厨师食谱,但我所做的一切似乎都没有改变tomcat的安装方式。我正在使用无业游民即。
I've been trying to customise a tomcat chef recipe but nothing I'm doing seems to change the tomcat installation. I'm using vagrant ie.
vagrant destroy && vagrant up
在Vagrantfile中
In Vagrantfile
config.vm.provision :chef_solo do |chef|
chef.add_recipe "apt"
chef.add_recipe "nginx-app"
chef.add_recipe "tomcat-app"
end
cookbooks / tomcat-app / recipes / default.rb
cookbooks/tomcat-app/recipes/default.rb
#
# Cookbook Name:: tomcat-app
# Recipe:: default
package "tomcat7" do
action :install
end
cookbooks / tomcat-app / attributes.rb
cookbooks/tomcat-app/attributes.rb
node.default["tomcat"]["port"] = 8083 <-- can't seem to make this apply
谢谢
推荐答案
作者留言
此答案已有5年历史了。它可能不适用于您今天的情况。
This answer is now 5 years old. It may not apply to your scenario today.
我怀疑您是在编写自己的tomcat食谱吗? node属性将仅覆盖此处记录的开源食谱的工作:
I suspect you're writing your own tomcat cookbook? The node attribute overrides only work with the open source cookbooks documented here:
- java
- tomcat
这是
├── .kitchen.yml
├── Berksfile
└── test
└── integration
├── default
│ └── serverspec
│ └── tomcat_spec.rb
└── roles
└── tomcat.json
tomcat角色说明了如何设置运行-列出并覆盖属性。
The "tomcat" role illustrates how to set the run-list and override the attributes.
---
driver:
name: vagrant
provisioner:
name: chef_zero
platforms:
- name: ubuntu-14.04
suites:
- name: default
run_list:
- role[tomcat]
attributes:
test / integration / roles / tomcat.json
test/integration/roles/tomcat.json
{
"name": "tomcat",
"description": "Runs tomcat with oracle JDK",
"override_attributes": {
"java": {
"jdk_version": 8,
"install_flavor": "oracle",
"oracle": {
"accept_oracle_download_terms": true
}
},
"tomcat": {
"base_version": 7,
"port": 8081
}
},
"run_list": [
"recipe[apt]",
"recipe[java]",
"recipe[tomcat]"
]
}
Berksfile
Berkshelf自动从厨师超市下载食谱。
Berksfile
Berkshelf automatically downloads cookbooks from the chef supermarket.
source 'https://supermarket.chef.io'
cookbook "apt"
cookbook "java"
cookbook "tomcat"
test / integration / serverspec / tomcat_spec.rb
test/integration/serverspec/tomcat_spec.rb
require 'serverspec'
set :backend, :exec
describe service('tomcat7') do
it { should be_running }
end
describe port('8081') do
it { should be_listening }
end
describe process('java') do
it { should be_running }
its(:args) { should match /org.apache.catalina.startup.Bootstrap/ }
end
这篇关于如何在Chef中自定义tomcat食谱的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!