Does not run bash script via exec in puppet?

A simple script in four lines of /etc/rc.d/rc.mongo:


/usr/bin/mongod --fork --shardsvr --logpath /var/log/mongodb.log --logappend --dbpath /mnt/cloudkc/mongo > /dev/null 2>&1

/usr/bin/mongod --fork --configsvr --logpath /var/log/mongocfg.log --logappend --dbpath /mnt/cloudkc/mongocfg > /dev/null 2>&1

sleep 3

/usr/bin/mongos --fork --logpath /var/log/mongos.log --logappend --configdb :27019 > /dev/null 2>&1


The error in the full version of any log on the client:


Jan 15 18:52:46 puppet puppet-agent[16099]: (/Stage[main]//Exec[runmongo]/returns) change from notrun to 0 failed: /etc/rc.d/rc.mongo returned 1 instead of one of [0] a

t /etc/puppet/manifests/site.pp:50


Perform in the manifest like so:


exec { "runmongo":

command =>"/etc/rc.d/rc.mongo",

path => "/usr/bin:/usr/sbin:/bin",

require => File["/etc/rc.d/rc.mongo"],

}
October 8th 19 at 03:57
3 answers
October 8th 19 at 03:59
Solution
Helped add provider -> shell

exec { "runmongo":
command =>"/etc/rc.d/rc.mongo",
path => "/usr/bin:/usr/sbin:/bin",
provider => shell,
require => File["/etc/rc.d/rc.mongo"],
}
Therefore thought I in the right direction: we had to specify what to execute the script /etc/rc.d/rc.mongo. - Mikayla.Roh commented on October 8th 19 at 04:02
October 8th 19 at 04:01
I guess you need something like this:

exec { "runmongo":<br> command =>"<b>bash</b> /etc/rc.d/rc.mongo"<br> path => "/usr/bin:/usr/sbin:/bin",<br> require => File["/etc/rc.d/rc.mongo"], <b><-- this comma is not superfluous?</b><br> }

Perhaps more will help specify #!/bin/bash at the beginning of the script.
October 8th 19 at 04:03
Correctly, puppet didn't know how to execute the file because it is not binary and the script does not specify the interpreter. In fact, according to the rules in the beginning of the script must specify which interpreter to run the script. Karabanov above already gave an example.

Find more questions by tags PuppetMongoDBNoSQL