Hi. I'm trying to write a policy to promise that sendmail.cf will contain the lines "O QueueLA=100" and "O RefuseLA=200" to raise the load average thresholds at which point sendmail will stop sending (or accepting) mail.
I've got two scenarios: 1. sendmail contains the default, which is: # load average at which we just queue messages #O QueueLA=8 # load average at which we refuse connections #O RefuseLA=12 So I just do a search and replace, "#O QueueLA=8" to "O QueueLA=100", that works fine. Scenario #2: sendmail.cf has a DIFFERENT setting, e.g. O QueueLA=50 I want to change that to "O QueueLA=100". This part is not working. The regex I am using in my replace_patterns promise is: "^O QueueLA=[^1][^0][^0]" Help, please? Here is my full policy: {{{ # sendmail will by default refuse to accept messages if the load average is too high body common control { inputs => { "/var/cfengine/inputs/cfengine_stdlib.cf" }; } bundle agent configure_sendmail_not_to_refuse_messages_under_high_load { files: "/etc/mail/sendmail.cf" edit_line => set_Queue_LA_and_Refuse_LA_to_very_high_values, comment => "Raise QueueLA and RefuseLA ridiculously high, so that the OS craps out before sendmail does. By default, sendmail will limit its functionality under high load. Well, don't do that. Maybe my server can operate under high load. Maybe I like to squeeze a lot of work out of my server."; commands: reload_sendmail:: "/etc/init.d/sendmail reload"; } bundle edit_line set_Queue_LA_and_Refuse_LA_to_very_high_values { replace_patterns: "^#O QueueLA.*$" replace_with => value("O QueueLA=100"), classes => if_repaired("reload_sendmail"), comment => "Replace default line with my line"; replace_patterns: "^O QueueLA=[^1][^0][^0]" replace_with => value("O QueueLA=100"), classes => if_repaired("reload_sendmail"), comment => "Replace non-matching value for QueueLA (not 100) with my value (100)"; replace_patterns: "^#O RefuseLA.*$" replace_with => value("O RefuseLA=200"), classes => if_repaired("reload_sendmail"); replace_patterns: "^O RefuseLA=[^2][^0][^0]" replace_with => value("O RefuseLA=200"), classes => if_repaired("reload_sendmail"), comment => "Replace non-matching value for RefuseLA (not 200) with my value (200)"; } }}} I would like to keep the line with the parameter just below the comment describing it, as it is before Cfengine touches the file. Yours, Aleksey _______________________________________________ Help-cfengine mailing list Help-cfengine@cfengine.org https://cfengine.org/mailman/listinfo/help-cfengine