【发布时间】:2017-02-27 23:37:25
【问题描述】:
我正在尝试设置 only_if 配方,我只希望在我们的东部地区使用 file1,在西部地区使用 File2。现在的结果是,由于 only_if,客户端绕过了说明书(文件)。我查看了日志,但它们的信息量不是很大。所以我不知道为什么它不起作用。
我也尝试过这种方法,结果相同。
节点[ec2][placement_availability_zone]
cookbook_file "/dir/dir/dir/file.json" do
only_if { node['ec2']['region'] == "us-east-1"}
source "dir/file1.json"
owner "user"
group "group"
action :create
notifies :restart, "service[app-client]", :delayed
end
cookbook_file "/etc/dir/dir/file.json" do
only_if { node['ec2']['region'] == "us-west-2"}
source "dir/file2.json"
owner "user"
group "group"
action :create
notifies :restart, "service[app-client]", :delayed
end
这是同一服务器上的 ohai 结果。
ohai | grep region
"dm_region_hash": {
"json?": "{\n \"devpayProductCodes\" : null,\n \"privateIp\" : \”0.0.0.0\”,\n \"availabilityZone\" : \"us-west-2c\",\n \"version\" : \”date\”,\n \"region\" : \"us-west-2\",\n \"instanceId\" : \”ID\”,\n \"billingProducts\" : null,\n \"instanceType\" : \"t2.micro\",\n \"accountId\" : \"\",\n \"kernelId\" : null,\n \"ramdiskId\" : null,\n \"architecture\" : \"x86_64\",\n \"imageId\" : \”ami-111111\”,\n \"pendingTime\" : \”date\time\”\n}”,
【问题讨论】:
标签: amazon-ec2 chef-infra ohai-gem