2013-05-07 49 views
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 

感謝,

回答

0

我有writingthe 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 

在這裏的databag的價值分析文件中,以便爲我的應用程序需要它,我可以使用它們。

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 
相關問題