coren has uploaded a new change for review.
https://gerrit.wikimedia.org/r/197325
Change subject: Tool Labs: correctly handle comments in crontab
......................................................................
Tool Labs: correctly handle comments in crontab
Right now, comments are only recognized when they start at
the beginning of the line; this will retain comments verbatim
even if they are preceeded by whitespace.
Bug: T75256
Change-Id: I4cfab67012299ee7e60899575b4ae6a854d36eec
---
M modules/toollabs/templates/crontab.erb
1 file changed, 6 insertions(+), 2 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/operations/puppet
refs/changes/25/197325/1
diff --git a/modules/toollabs/templates/crontab.erb
b/modules/toollabs/templates/crontab.erb
index 846a035..41b0d56 100755
--- a/modules/toollabs/templates/crontab.erb
+++ b/modules/toollabs/templates/crontab.erb
@@ -160,7 +160,11 @@
my $modified = 0;
if(open NEW, "| /usr/bin/ssh <%= @cron_host %> /usr/bin/crontab$dashu -") {
foreach my $line (@crontab) {
- if($line =~ m/^([^#][^=\t
]+\s+\S+\s+\S+\s+\S+\s+\S+\s+|\@\S+\s+)([^#\n]*)(#.*)?\n?$/) {
+ if($line =~ m/^\s*#.*/) {
+ print NEW $line;
+ next;
+ }
+ if($line =~ m/^([^=\t
]+\s+\S+\s+\S+\s+\S+\s+\S+\s+|\@\S+\s+)([^#\n]*)(#.*)?\n?$/) {
$crlino++;
my($sched, $cmd, $cmt) = ($1, $2, $3);
my $prefix = '';
@@ -176,7 +180,7 @@
$line .= "\n";
}
}
- print NEW "$line";
+ print NEW $line;
}
close NEW;
} else {
--
To view, visit https://gerrit.wikimedia.org/r/197325
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I4cfab67012299ee7e60899575b4ae6a854d36eec
Gerrit-PatchSet: 1
Gerrit-Project: operations/puppet
Gerrit-Branch: production
Gerrit-Owner: coren <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits