i using amazon opsworks , struggling working through single script, have created script named clamav.rb
. content of script is:
yum_package 'clamav' action :install end yum_package 'clamav-update' action :install end file_names = ['/etc/freshclam.conf'] file_names.each |file_name| text = file.read(file_name) replace = text.gsub("example", "#example") # merely print contents of file, use: puts replace # write changes file, use: file.open(file_name, "w") {|file| file.puts replace } end execute "run freshclam" command "/usr/bin/freshclam" end
when execute above script stuck error:
[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 /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)
but when divide script in 2 parts run well, creating separate script yum packages , separate configuration change.
you're being bitten chef's two-pass loading model. @ point in code, package hasn't been installed yet. check out https://coderanger.net/two-pass/ more details on that, fix actual problem, use line
cookbook has resources kind of search , replace in files, handle sequencing correctly you.
Comments
Post a Comment