0

我的问题是如何在配方中创建或解析数据包内容到文件中。我想使用该文件来验证“wal-e”应用程序。

这是我的草稿,任何人都可以帮助我查看更多示例或添加语法

 file "/etc/wal-e.d/env" do
   AWS_ACCESS_KEY_ID aws['access']
   AWS_SECRET_ACCESS_KEY aws['secret']
   WALE_S3_PREFIX "#{node['fc_db']['s3']['wale_s3_prefix']}"
 action :create
 end

谢谢,

4

2 回答 2

0

我的一个想法如下。

 directory "/etc/wal-e.d" do
   owner "postgres"
   group "postgres"
   mode 00755
   action :create
 end

 directory "/etc/wal-e.d/env" do
   owner "postgres"
   group "postgres"
   mode 00755
   action :create
 end

 aws = data_bag_item('aws', 'keys')

 file "/etc/wal-e.d/env/AWS_SECRET_ACCESS_KEY" do
   variables(:AWS_SECRET_ACCESS_KEY => aws['secret'])
   owner "postgres"
   mode  "0644"
   action :create
 end

 file "/etc/wal-e.d/env/AWS_ACCESS_KEY_ID" do
   variables(:AWS_ACCESS_KEY_ID => aws['access'])
   owner "postgres"
   mode  "0644"
   action :create
 end

 file "/etc/wal-e.d/env/WALE_S3_PREFIX" do
   variables(:WALE_S3_PREFIX => "#{node['fc_db']['s3']['wale_s3_prefix']}")
   owner "postgres"
   mode  "0644"
   action :create
 end
于 2013-05-07T06:29:54.130 回答
0

我已经通过编写ff来解决这个问题:

 aws = data_bag_item('aws', 'keys')

 template "/path/to/file/AWS_SECRET_ACCESS_KEY" do
   owner "postgres"
   mode 0644
   source "AWS_SECRET_ACCESS_KEY.erb"
   variables(:AWS_SECRET_ACCESS_KEY => aws['secret'])
   action :create
 end

 template "/path/to/file//AWS_ACCESS_KEY_ID" do
   owner "postgres"
   mode  0644
   source "AWS_ACCESS_KEY_ID.erb"
   variables(:AWS_ACCESS_KEY_ID => aws['access'])
   action :create
 end

 template "/path/to/file//WALE_S3_PREFIX" do
   owner "postgres"
   mode  0644
   source "WALE_S3_PREFIX.erb"
   action :create
 end

在这里,数据包的值在文件中解析,因此我可以在应用程序需要时使用它们。

于 2013-05-15T03:05:24.300 回答