Use sudo to read last_run_summary and last_run_report files when nece…#48
Use sudo to read last_run_summary and last_run_report files when nece…#48bill-mcgonigle wants to merge 1 commit into
Conversation
| # Cmnd_Alias PUPPETCHECK=/usr/bin/puppet config print all, \ # puppet 2 | ||
| # /usr/bin/puppet config print, \ # puppet 3 | ||
| # /usr/bin/puppet config print --section agent # other puppet version | ||
| # /usr/bin/puppet config print, \ --section agent # other puppet version |
There was a problem hiding this comment.
I'm guessing the placement of the comma and the slash here is a typo?
/usr/bin/puppet config print, \ --section agent -> /usr/bin/puppet config print --section agent, \
There was a problem hiding this comment.
@bill-mcgonigle Can you please move the \ to the end of line as @baldurmen suggests?
|
This works on my side. Thanks! |
aswen
left a comment
There was a problem hiding this comment.
@bill-mcgonigle Thanks for your PR. I would love to add this to the check script. Please fix the few remarks made by me and @baldurmen (Thanks @baldurmen for your review!).
| if ( sudo test -s $lastrunfile && sudo test -r $lastrunfile ); then | ||
| sudo_summary='sudo' | ||
| else | ||
| result 1 if [ -n "$SHOW_ERROR" ] |
There was a problem hiding this comment.
@bill-mcgonigle Did you test this? I never saw this order in if statements in sh scripts. It reminds me of ruby style instead.
I was curious, so tested this:
$ echo yes if [ 1 -eq 1 ]
yes if [ 1 -eq 1 ]
$ echo yes if [ -z "$thing" ]
yes if [ -z ]
$ thing=hooray
$ echo yes if [ -n "$thing" ]
yes if [ -n hooray ]
This leads me to the suspicion this would execute the result function with 1 if [ -n <the contents of $SHOW_ERROR here> ]. That is probably not what you intended.
| if ( sudo test -s $lastrunreport && sudo test -r $lastrunreport ); then | ||
| sudo_report='sudo' | ||
| else | ||
| result 12 if [ -n "$SHOW_ERROR" ] |
| # Cmnd_Alias PUPPETCHECK=/usr/bin/puppet config print all, \ # puppet 2 | ||
| # /usr/bin/puppet config print, \ # puppet 3 | ||
| # /usr/bin/puppet config print --section agent # other puppet version | ||
| # /usr/bin/puppet config print, \ --section agent # other puppet version |
There was a problem hiding this comment.
@bill-mcgonigle Can you please move the \ to the end of line as @baldurmen suggests?
This implements some of the fixes proposed in #38 , which appears to be necessary in my Puppet 4/5 environment. Tested on : Debian Stretch/Buster, Fedora 26/27, CentOS 6/7, Ubuntu 16.04.
Please modify to fit your coding style or where I misunderstood what was happening. It's working here, but I wasn't able to test on old puppets.