Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SysV init script breaks on empty @options #633

Open
Ph0B1uS opened this issue Aug 22, 2022 · 0 comments
Open

SysV init script breaks on empty @options #633

Ph0B1uS opened this issue Aug 22, 2022 · 0 comments

Comments

@Ph0B1uS
Copy link

Ph0B1uS commented Aug 22, 2022

Affected Puppet, Ruby, OS and module versions/distributions

  • Puppet: 7.12.0
  • Ruby: 2.7.3p183
  • Distribution: RHEL 6.10
  • Module version: 12.4.0

How to reproduce (e.g Puppet code you use)

class { 'prometheus::node_exporter':
  version => '1.3.1',
}

What are you seeing

Notice: /Stage[main]/Prometheus::Node_exporter/Prometheus::Daemon[node_exporter]/File[/etc/init.d/node_exporter]/content:
--- /etc/init.d/node_exporter	2022-08-22 11:13:53.806525689 +0200
+++ /tmp/puppet-file20220822-7324-h3tg38	2022-08-22 11:29:05.939372454 +0200
@@ -51,7 +51,8 @@
         [ -f $PID_FILE ] && rm $PID_FILE
         daemon --user=node-exporter \
             --pidfile="$PID_FILE" \
-            "'$DAEMON' >> '$LOG_FILE' 2>&1 &"
+            "'$DAEMON' \ \ \  >> '$LOG_FILE' 2>&1 &"
         retcode=$?
         sleep 1
         mkpidfile

What behaviour did you expect instead

No change from "'$DAEMON' >> '$LOG_FILE' 2>&1 &"

Output log

Any additional information you'd like to impart

I've fixed it in my environment by replacing a portion of the start() block in daemon.sysv.erb template file starting at line 54 like this:

            <%- if ! @options.strip.empty? -%>
            <%- require 'shellwords' -%>
            "'$DAEMON' <%= Shellwords.escape(@options) %> >> '$LOG_FILE' 2>&1 &"
            <%- end -%>
            <%- if @options.strip.empty? -%>
            "'$DAEMON' >> '$LOG_FILE' 2>&1 &"
            <%- end -%>

I'm sure there are more elegant solutions to this as it probably took me about 30 minutes to come up with the code above but hey, it works and I'm hoping someone more skilled than me can take this and refine it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant