voxpupuli/puppet-mcollective

refresh-mcollective-metadata cron job broken syntax

jeffreyfroman-temboo opened this issue · 6 comments

Line 31 of yaml.pp installs a cron job with broken syntax since switching from facter to puppet facts. The command is fine when run manually, but is broken in cron thanks to the use of the % character as a delimiter in the sed expression.

From man 5 crontab:

       The  ``sixth''  field (the rest of the line) specifies the command to be run.  The entire command portion of the line, up to a newline or % character, will be executed by /bin/sh or by the shell specified in the SHELL variable of  the  crontab file.   Percent-signs (%) in the command, unless escaped with backslash (\), will be changed into newline characters, and all data after the first % will be sent to the command as standard input.

Using @ instead should work fine.

Affected Puppet, Ruby, OS and module versions/distributions

  • Puppet: 4.10.9
  • Ruby: 2.3.1p112
  • Distribution: Ubuntu 16.04
  • Module version: 2.10.6

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

Apply yaml.pp, wait 15 minutes, see error emailed by cron.

What are you seeing

/bin/sh: 1: Syntax error: Unterminated quoted string

What behaviour did you expect instead

Successful command execution and population of facts.yaml

Output log

Any additional information you'd like to impart

ekohl commented

Would you be able to put a PR together to fix this?

This seems to have been handled in 8050f53, I'm just confused as to which version I need I guess to get this fix, or more to the point how it got into the version tag I am using. Some of our installations using the same versions still contain the old cron job, using facter

So my apologies, but I'm not sure I understand where this needs to be pulled into as yet.

ekohl commented

Github points on in that commit that it's included in the v3.1.0 git tag. That would be my first try.

Well, I don't have an issue finding the fix; the problem is that puppet on Ubuntu is pulling this in via apt, and yaml.pp has changed in a previous tag (2.10.6). Once the version is tagged, it shouldn't change, should it? That version used to use facter, but recently switched to the broken puppet facts command.

@ekohl I think the code has been broken ever since the move to puppet facts. See #361