summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorelijah <elijah@riseup.net>2015-04-07 09:49:52 -0700
committerelijah <elijah@riseup.net>2015-04-07 09:49:52 -0700
commitc79e0282d5b5db3aba0167f13648ccc676fcb96b (patch)
tree5bab632579f9265cd0781e92eed8db59fd972597
parentee9fdf0d965cc24a0f421b588b702e1c07caeccf (diff)
rotate deploy logs by size instead of by date.
-rwxr-xr-xbin/puppet_command30
-rw-r--r--puppet/modules/site_config/manifests/syslog.pp20
2 files changed, 36 insertions, 14 deletions
diff --git a/bin/puppet_command b/bin/puppet_command
index ce56fe51..1e74522a 100755
--- a/bin/puppet_command
+++ b/bin/puppet_command
@@ -24,6 +24,7 @@ HIERA_FILE = '/etc/leap/hiera.yaml'
LOG_DIR = '/var/log/leap'
DEPLOY_LOG = '/var/log/leap/deploy.log'
SUMMARY_LOG = '/var/log/leap/deploy-summary.log'
+SUMMARY_LOG_1 = '/var/log/leap/deploy-summary.log.1'
APPLY_START_STR = "STARTING APPLY"
APPLY_FINISH_STR = "APPLY COMPLETE"
@@ -161,18 +162,23 @@ end
#
PLATFORM_RE = /\{.*platform: ([0-9\.]+)[ ,\}].*[\}$]/
def platform_version_check!
- if @info["platform"]
- new_version = @info["platform"].split(' ').first
- if File.exists?(SUMMARY_LOG) && new_version
- most_recent_line = `tail '#{SUMMARY_LOG}'`.split("\n").grep(PLATFORM_RE).last
- if most_recent_line
- prior_version = most_recent_line.match(PLATFORM_RE)[1]
- if Gem::Version.new(prior_version) > Gem::Version.new(new_version)
- log("ERROR: You are attempting to deploy platform v#{new_version} but this node uses v#{prior_version}.")
- log(" Run with --downgrade if you really want to deploy an older platform version.")
- exit(0)
- end
- end
+ return unless @info["platform"]
+ new_version = @info["platform"].split(' ').first
+ return unless new_version
+ if File.exists?(SUMMARY_LOG) && File.size(SUMMARY_LOG) != 0
+ file = SUMMARY_LOG
+ elsif File.exists?(SUMMARY_LOG_1) && File.size(SUMMARY_LOG_1) != 0
+ file = SUMMARY_LOG_1
+ else
+ return
+ end
+ most_recent_line = `tail '#{file}'`.split("\n").grep(PLATFORM_RE).last
+ if most_recent_line
+ prior_version = most_recent_line.match(PLATFORM_RE)[1]
+ if Gem::Version.new(prior_version) > Gem::Version.new(new_version)
+ log("ERROR: You are attempting to deploy platform v#{new_version} but this node uses v#{prior_version}.")
+ log(" Run with --downgrade if you really want to deploy an older platform version.")
+ exit(0)
end
end
end
diff --git a/puppet/modules/site_config/manifests/syslog.pp b/puppet/modules/site_config/manifests/syslog.pp
index 1b0c1e05..83b49c8e 100644
--- a/puppet/modules/site_config/manifests/syslog.pp
+++ b/puppet/modules/site_config/manifests/syslog.pp
@@ -15,8 +15,24 @@ action(type="mmanon" ipv4.bits="32" mode="rewrite")'
augeas {
'logrotate_leap_deploy':
context => '/files/etc/logrotate.d/leap_deploy/rule',
- changes => [ 'set file /var/log/leap/deploy*.log', 'set rotate 7',
- 'set schedule daily', 'set compress compress',
+ changes => [ 'set file /var/log/leap/deploy.log',
+ 'set rotate 5',
+ 'set size 1M',
+ 'set compress compress',
+ 'set missingok missingok',
+ 'set copytruncate copytruncate' ];
+
+ # NOTE:
+ # the puppet_command script requires the option delaycompress
+ # be set on the summary log file.
+
+ 'logrotate_leap_deploy_summary':
+ context => '/files/etc/logrotate.d/leap_deploy_summary/rule',
+ changes => [ 'set file /var/log/leap/deploy-summary.log',
+ 'set rotate 5',
+ 'set size 100k',
+ 'set delaycompress delaycompress',
+ 'set compress compress',
'set missingok missingok',
'set copytruncate copytruncate' ]
}