I'm not able to recreate the issue of augeas generating settings with spaces in the output. Here's how I tested it. Can you provide a counter example of using augeas such that it does generate a nagios.cfg which includes the space before or after a variable?
# On my Xenial laptop
1. lxc launch ubuntu:trusty t1
2. lxc exec t1 /bin/bash
# as root in t1 trusty container
3. apt-get update && apt-get install augeas-lenses augeas-tools nagios3
4. nagios3 --verify-config /etc/nagios3/nagios.cfg # returns OK, installed file does not include the spaces
# modify the config file to include spaces before and after and re-run 4
5. nagios3 --verify-config /etc/nagios3/nagios.cfg
Nagios Core 3.5.1
Copyright (c) 2009-2011 Nagios Core Development Team and Community Contributors
Copyright (c) 1999-2009 Ethan Galstad
Last Modified: 08-30-2013
License: GPL
Website: http://www.nagios.org
Reading configuration data...
Error in configuration file '/etc/nagios3/nagios.cfg' - Line 17 (UNKNOWN VARIABLE)
Error processing main config file!
***> One or more problems was encountered while processing the config files...
Check your configuration file(s) to ensure that they contain valid
directives and data defintions. If you are upgrading from a previous
version of Nagios, you should be aware that some variables/definitions
may have been removed or modified in this version. Make sure to read
the HTML documentation regarding the config files, as well as the
'Whats New' section to find out what has changed.
# setup temp area to test augeas out per
# http://augeas.net/tour.html
6. export AUGEAS_ROOT=/tmp/augeas-sandbox
7. mkdir $AUGEAS_ROOT
8. sudo cp -pr /etc $AUGEAS_ROOT
9. sudo chown -R $(id -nu):$(id -ng) $AUGEAS_ROOT
10. augtool -b
# in the shell, make a change
augtool> print /files/etc/nagios3/nagios.cfg/cfg_file
/files/etc/nagios3/nagios.cfg/cfg_file = "/etc/nagios3/commands.cfg"
augtool> set /files/etc/nagios3/nagios.cfg/cfg_file /etc/nagios3/commands.cfg.local
augtool> print /files/etc/nagios3/nagios.cfg/cfg_file
/files/etc/nagios3/nagios.cfg/cfg_file = "/etc/nagios3/commands.cfg.local"
augtool> save
Saved 1 file(s)
augtool>
11. check the contents of nagios.cfg in the playground:
# diff -u nagios.cfg nagios.cfg.augsave
--- nagios.cfg 2016-06-06 18:48:23.096279946 +0000
+++ nagios.cfg.augsave 2016-06-06 18:37:19.308822398 +0000
@@ -14,7 +14,7 @@
log_file=/var/log/nagios3/nagios3.log
Hello,
I'm not able to recreate the issue of augeas generating settings with spaces in the output. Here's how I tested it. Can you provide a counter example of using augeas such that it does generate a nagios.cfg which includes the space before or after a variable?
# On my Xenial laptop
1. lxc launch ubuntu:trusty t1
2. lxc exec t1 /bin/bash
# as root in t1 trusty container nagios. cfg # returns OK, installed file does not include the spaces
3. apt-get update && apt-get install augeas-lenses augeas-tools nagios3
4. nagios3 --verify-config /etc/nagios3/
# modify the config file to include spaces before and after and re-run 4 nagios. cfg
5. nagios3 --verify-config /etc/nagios3/
Nagios Core 3.5.1
Copyright (c) 2009-2011 Nagios Core Development Team and Community Contributors
Copyright (c) 1999-2009 Ethan Galstad
Last Modified: 08-30-2013
License: GPL
Website: http:// www.nagios. org nagios. cfg' - Line 17 (UNKNOWN VARIABLE)
Reading configuration data...
Error in configuration file '/etc/nagios3/
Error processing main config file!
***> One or more problems was encountered while processing the config files...
Check your configuration file(s) to ensure that they contain valid definitions
directives and data defintions. If you are upgrading from a previous
version of Nagios, you should be aware that some variables/
may have been removed or modified in this version. Make sure to read
the HTML documentation regarding the config files, as well as the
'Whats New' section to find out what has changed.
# setup temp area to test augeas out per augeas. net/tour. html ROOT=/tmp/ augeas- sandbox
# http://
6. export AUGEAS_
7. mkdir $AUGEAS_ROOT
8. sudo cp -pr /etc $AUGEAS_ROOT
9. sudo chown -R $(id -nu):$(id -ng) $AUGEAS_ROOT
10. augtool -b
# in the shell, make a change etc/nagios3/ nagios. cfg/cfg_ file etc/nagios3/ nagios. cfg/cfg_ file = "/etc/nagios3/ commands. cfg" etc/nagios3/ nagios. cfg/cfg_ file /etc/nagios3/ commands. cfg.local etc/nagios3/ nagios. cfg/cfg_ file etc/nagios3/ nagios. cfg/cfg_ file = "/etc/nagios3/ commands. cfg.local"
augtool> print /files/
/files/
augtool> set /files/
augtool> print /files/
/files/
augtool> save
Saved 1 file(s)
augtool>
11. check the contents of nagios.cfg in the playground: /var/log/ nagios3/ nagios3. log
# diff -u nagios.cfg nagios.cfg.augsave
--- nagios.cfg 2016-06-06 18:48:23.096279946 +0000
+++ nagios.cfg.augsave 2016-06-06 18:37:19.308822398 +0000
@@ -14,7 +14,7 @@
log_file=
# Commands definitions /etc/nagios3/ commands. cfg.local /etc/nagios3/ commands. cfg
-cfg_file=
+cfg_file=
# Debian also defaults to using the check commands defined by the debian
# nagios-plugins package
We can see the change but note that it's not injecting a space before or after the configuration variable.