voxpupuli / puppet-augeasproviders

Alternative Augeas-based providers for Puppet
http://augeasproviders.com/
Apache License 2.0
63 stars 46 forks source link

Shellvar comment parameter make a mess of existing comments #119

Closed treydock closed 9 years ago

treydock commented 10 years ago

Using 1.2.0 of this module I found that when applying Shellvar resources to a file with comments, all the existing comments had their spacing scrambled.

These are the resources:

  Shellvar {
    ensure  => 'present',
    target  => '/etc/zfs/zed.d/zed.rc',
    comment => 'managed by Puppet!',
  }

  shellvar { 'ZED_DEBUG_LOG': value => $::zfsonlinux::zed_debug_log }
  shellvar { 'ZED_EMAIL': value => $::zfsonlinux::zed_email }
  shellvar { 'ZED_EMAIL_VERBOSE': value => $::zfsonlinux::zed_email_verbose }
  shellvar { 'ZED_EMAIL_INTERVAL_SECS': value => $::zfsonlinux::zed_email_interval_secs }
  shellvar { 'ZED_LOCKDIR': value => $::zfsonlinux::zed_lockdir }
  shellvar { 'ZED_RUNDIR': value => $::zfsonlinux::zed_rundir }
  shellvar { 'ZED_SYSLOG_PRIORITY': value => $::zfsonlinux::zed_syslog_priority }
  shellvar { 'ZED_SYSLOG_TAG': value => $::zfsonlinux::zed_syslog_tag }
  shellvar { 'ZED_SPARE_ON_IO_ERRORS': value => $::zfsonlinux::zed_spare_on_io_errors }
  shellvar { 'ZED_SPARE_ON_CHECKSUM_ERRORS': value => $::zfsonlinux::zed_spare_on_checksum_errors }

Here's an example:

Without the comment parameter for Shellvar

--- zfs/zed.d/zed.rc.orig   2014-06-13 03:58:30.159763492 +0000
+++ zfs/zed.d/zed.rc    2014-06-13 04:01:12.831763401 +0000
@@ -2,33 +2,43 @@

 # Absolute path to the debug output file.
 #ZED_DEBUG_LOG="/tmp/zed.debug.log"
+ZED_DEBUG_LOG=/tmp/zed.debug.log

 # Email address of the zpool administrator.
 #   Email will only be sent if ZED_EMAIL is defined.
 #ZED_EMAIL="root"
+ZED_EMAIL=

 # Email verbosity.
 #   If set to 0, suppress email if the pool is healthy.
 #   If set to 1, send email regardless of pool health.
 #ZED_EMAIL_VERBOSE=0
+ZED_EMAIL_VERBOSE=0

 # Minimum number of seconds between emails sent for a similar event.
 #ZED_EMAIL_INTERVAL_SECS="3600"
+ZED_EMAIL_INTERVAL_SECS=3600

 # Default directory for zed lock files.
 #ZED_LOCKDIR="/var/lock"
+ZED_LOCKDIR=/var/lock

 # Default directory for zed state files.
 #ZED_RUNDIR="/var/run"
+ZED_RUNDIR=/var/run

 # The syslog priority (eg, specified as a "facility.level" pair).
 #ZED_SYSLOG_PRIORITY="daemon.notice"
+ZED_SYSLOG_PRIORITY=daemon.notice

 # The syslog tag for marking zed events.
 #ZED_SYSLOG_TAG="zed"
+ZED_SYSLOG_TAG=zed

 # Replace a device with a hot spare after N I/O errors are detected.
 #ZED_SPARE_ON_IO_ERRORS=1
+ZED_SPARE_ON_IO_ERRORS=0

 # Replace a device with a hot spare after N checksum errors are detected.
 #ZED_SPARE_ON_CHECKSUM_ERRORS=10
+ZED_SPARE_ON_CHECKSUM_ERRORS=0

With the comment parameter

--- zfs/zed.d/zed.rc.orig   2014-06-13 03:58:30.159763492 +0000
+++ zfs/zed.d/zed.rc    2014-06-13 04:03:40.303763325 +0000
@@ -2,33 +2,53 @@

 # Absolute path to the debug output file.
 #ZED_DEBUG_LOG="/tmp/zed.debug.log"
+# ZED_DEBUG_LOG: managed by Puppet!
+ZED_DEBUG_LOG=/tmp/zed.debug.log

-# Email address of the zpool administrator.
-#   Email will only be sent if ZED_EMAIL is defined.
-#ZED_EMAIL="root"
-
-# Email verbosity.
-#   If set to 0, suppress email if the pool is healthy.
-#   If set to 1, send email regardless of pool health.
+#   Email address of the zpool administrator.
+#Email will only be sent if ZED_EMAIL is defined.
+# ZED_EMAIL="root"
+#   ZED_EMAIL: managed by Puppet!
+ZED_EMAIL=
+
+#   Email verbosity.
+#If set to 0, suppress email if the pool is healthy.
+# If set to 1, send email regardless of pool health.
 #ZED_EMAIL_VERBOSE=0
+# ZED_EMAIL_VERBOSE: managed by Puppet!
+ZED_EMAIL_VERBOSE=0

-# Minimum number of seconds between emails sent for a similar event.
-#ZED_EMAIL_INTERVAL_SECS="3600"
+#Minimum number of seconds between emails sent for a similar event.
+# ZED_EMAIL_INTERVAL_SECS="3600"
+#ZED_EMAIL_INTERVAL_SECS: managed by Puppet!
+ZED_EMAIL_INTERVAL_SECS=3600

 # Default directory for zed lock files.
 #ZED_LOCKDIR="/var/lock"
+# ZED_LOCKDIR: managed by Puppet!
+ZED_LOCKDIR=/var/lock

-# Default directory for zed state files.
-#ZED_RUNDIR="/var/run"
+#Default directory for zed state files.
+# ZED_RUNDIR="/var/run"
+#ZED_RUNDIR: managed by Puppet!
+ZED_RUNDIR=/var/run

 # The syslog priority (eg, specified as a "facility.level" pair).
 #ZED_SYSLOG_PRIORITY="daemon.notice"
+# ZED_SYSLOG_PRIORITY: managed by Puppet!
+ZED_SYSLOG_PRIORITY=daemon.notice

 # The syslog tag for marking zed events.
-#ZED_SYSLOG_TAG="zed"
+# ZED_SYSLOG_TAG="zed"
+# ZED_SYSLOG_TAG: managed by Puppet!
+ZED_SYSLOG_TAG=zed

 # Replace a device with a hot spare after N I/O errors are detected.
-#ZED_SPARE_ON_IO_ERRORS=1
+# ZED_SPARE_ON_IO_ERRORS=1
+# ZED_SPARE_ON_IO_ERRORS: managed by Puppet!
+ZED_SPARE_ON_IO_ERRORS=0

 # Replace a device with a hot spare after N checksum errors are detected.
-#ZED_SPARE_ON_CHECKSUM_ERRORS=10
+# ZED_SPARE_ON_CHECKSUM_ERRORS=10
+# ZED_SPARE_ON_CHECKSUM_ERRORS: managed by Puppet!
+ZED_SPARE_ON_CHECKSUM_ERRORS=0
raphink commented 10 years ago

This is a problem with the lens. Since Augeas adds a new #comment node in the tree, all the nodes are moved one step down and inherit their neighbour's spaces. It's definitely a non trivial bug to fix…

raphink commented 9 years ago

Migrated to https://github.com/hercules-team/augeasproviders_shellvar/issues/7