Issue 9252

What if at a certain point one of those files disappear? wouldn't this 
raise an error while applying recipes?

On 16/09/14 16:17, domhnallmurphy-examtime wrote:
>
> In cookbooks/monit/recipes/default.rb:
>
> > +  end
> > +end
> > +
> > +if File.exists?('/etc/monit.d/collectd-httpd.monitrc')
> > +
> > +  line = "noalert #{mail_dest}"
> > +
> > +  file = Chef::Util::FileEdit.new('/etc/monit.d/collectd-httpd.monitrc')
> > +  file.insert_line_if_no_match(/#{line}/, line)
> > +  file.write_file
> > +
> > +  execute "monit reload" do
> > +    action :run
> > +    epic_fail true
> > +  end
> > +end
>
> Just for maintainability we could avoid a bit of repetition here:
>
> |line = "noalert #{mail_dest}"
> ['/etc/monit.d/mini_httpd.monitrc', '/etc/monit.d/collectd-httpd.monitrc'].each do |path|
>    file = Chef::Util::FileEdit.new(path)
>    file.insert_line_if_no_match(/#{line}/, line)
>    file.write_file
>
>    execute "monit reload" do
>      action :run
>      epic_fail true
>    end
> end
> |
>
> What do you think?
>
> —
> Reply to this email directly or view it on GitHub 
> <https://github.com/ExamTime/ey-cloud-recipes/pull/19/files#r17607806>.
>