我的问题是如何在数据库中创建或解析数据库内容到文件中。我想使用该文件来验证“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
谢谢,
答案 0 :(得分: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
答案 1 :(得分: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
在这里,数据库的值在文件中进行解析,因此我可以在应用程序需要时使用它们。