我正在使用Amazon opsworks並努力通過單個腳本來實現它,我創建了一個名爲clamav.rb
的腳本。腳本的內容是:如何在同一腳本中使用配置Ruby腳本安裝ClamAV?
yum_package 'clamav' do
action :install
end
yum_package 'clamav-update' do
action :install
end
file_names = ['/etc/freshclam.conf']
file_names.each do |file_name|
text = File.read(file_name)
replace = text.gsub("Example", "#Example")
# To merely print the contents of the file, use:
puts replace
# To write changes to the file, use:
File.open(file_name, "w") {|file| file.puts replace }
end
execute "Run Freshclam" do
command "/usr/bin/freshclam"
end
當我執行上面的腳本它堅持了一個錯誤:
[2016-08-01T13:02:36+00:00] ERROR: Running exception handlers
[2016-08-01T13:02:36+00:00] ERROR: Exception handlers complete
[2016-08-01T13:02:36+00:00] FATAL: Stacktrace dumped to /var/lib/aws/opsworks/cache.stage2/chef-stacktrace.out
[2016-08-01T13:02:36+00:00] ERROR: No such file or directory - /etc/freshclam.conf
[2016-08-01T13:02:36+00:00] FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited unsuccessfully (exit code 1)
,但是當我在兩個部分劃分腳本它運行得很好,如建立獨立的腳本用於yum包並單獨更改配置。
我是新來這個,你能不能請提供簡要 – Navneet
沒有步驟,檢查出的線菜譜自述,並說明了如何使用其資源。 – coderanger