Angenommen, ich habe Folgendes in der /etc/syslog.conf
Datei:
# Log all kernel messages to the console.
# Logging much else clutters up the screen.
#kern.* /dev/console
Ich möchte es ändern kern.* /var/log/kern.log
, um den für Menschen lesbaren Zeitstempel für das Kernel-Protokoll zu erhalten.
Puppe kann es tun:
class syslog::config {
file { "/etc/syslog.conf":
ensure => present,
source => "puppet:///modules/syslog/syslog.conf",
require => Class["syslog::install"],
notify => Class["syslog::service"],
}
}
oder ich kann auch das benutzen sed -i
.
Mit Augeas kann ich diese Zeile an das Ende der Datei anhängen:
class syslog::config {
augeas { "syslogkern":
context => "/files/etc/syslog.conf",
changes => [
"set entry[last()+1]/selector/facility kern",
"set entry[last()]/selector/level *",
"set entry[last()]/action/file '/var/log/kern.log'",
],
}
}
oder ändern Sie das Ziel:
class syslog::config {
augeas { "syslogkern":
context => "/files/etc/syslog.conf",
onlyif => "get #comment[3] == 'kern.*\t\t\t\t\t\t\t/dev/console'",
changes => [
"set #comment[3] 'kern.*\t\t\t\t\t\t\t/var/log/kern.log'",
],
}
}
Aber wie kommentiere ich diese Zeile aus?
AKTUALISIEREN
Folgendes habe ich versucht, eine Zeile danach einzufügen #comment[3]
:
augtool> ins facle after /files/etc/syslog.conf/#comment[3]
augtool> set /files/etc/syslog.conf/facle/selector/facility kern
augtool> set /files/etc/syslog.conf/facle/selector/level *
augtool> set /files/etc/syslog.conf/facle/action/file /var/log/kern.log
oder:
augtool> ins facle after /files/etc/syslog.conf/#comment[3]
augtool> set /files/etc/syslog.conf/facle[last()] kernlog
augtool> set /files/etc/syslog.conf/facle[. = 'kernlog']/selector/facility kern
augtool> set /files/etc/syslog.conf/facle[. = 'kernlog']/selector/level *
augtool> set /files/etc/syslog.conf/facle[. = 'kernlog']/action/file /var/log/kern.log
aber es hat nicht funktioniert:
augtool> save
error: Failed to execute command
error: saving failed (run 'print /augeas//error' for details)
augtool> print /augeas//error
/augeas/files/etc/syslog.conf/error = "put_failed"
/augeas/files/etc/syslog.conf/error/path = "/files/etc/syslog.conf"
/augeas/files/etc/syslog.conf/error/lens = "/usr/share/augeas/lenses/dist/syslog.aug:243.18-.51:"
/augeas/files/etc/syslog.conf/error/message = "Failed to match \n ({ } | { /#comment/ = /[^\\001-\\004\\t\\n !+-][^\\001-\\004\\n]*[^\\001-\\004\\t\\n ]|[^\\001-\\004\\t\\n !+-]/ } | { /entry/ })*({ /program/ } | { /hostname/ })*\n with tree\n { \"#comment\" = \"Log all kernel messages to the console.\" } { \"#comment\" = \"Logging much else clutters up the screen.\" } { \"#comment\" = \"kern.*\t\t\t\t\t\t\t/var/log/kern.log\" } { \"facle\" = \"kernlog\" } { \"entry\" } { } { \"#comment\" = \"Log anything (except mail) of level info or higher.\" } { \"#comment\" = \"Don't log private authentication messages!\" } { \"entry\" } { } { \"#comment\" = \"The authpriv file has restricted access.\" } { \"entry\" } { } { \"#comment\" = \"Log all the mail messages in one place.\" } { \"entry\" } { } { } { \"#comment\" = \"Log cron stuff\" } { \"entry\" } { } { \"#comment\" = \"Everybody gets emergency messages\" } { \"entry\" } { } { \"#comment\" = \"Save news errors of level crit and higher in a special file.\" } { \"entry\" } { } { \"#comment\" = \"Save boot messages also to boot.log\" } { \"entry\" } { } { } { \"#comment\" = \"INN\" } { } { \"entry\" } { \"entry\" } { \"entry\" }"
/var/log/kern.log
?\t
hat nicht funktioniert.