Hello Iam new to puppet and now trying to explore with puppet manifests. Actually Iam creating a manifest for mongodb and I want to use a variable inside the exec. But each time it is giving me error. My mongodb.pp is as below
class db::mongodb ($interface) {
$ip = inline_template("<%= scope.lookupvar('::ipaddress_${interface}') -%>")
exec {'/bin/bash -c "mongo --host $ip --eval \' db = db.getSiblingDB("test"); db.addUser({user: "test", pwd: "test", roles: [ "readWrite", "dbAdmin" ]})\'"' :
}
}
But while running this Iam getting error like below
could not connect to the server --eval:27017 at src/mongo/shell/mongo.js:147
IP part is missing in the error because $ip is not substituting IP in the mongo command.. I tried different ways but all gives the same error. Actually I want to know how to use variable in the exec command as above in the puppet?? Any help is much appreciated.