ENC in Nodejs Error

39 views
Skip to first unread message

Jordan Cabral

unread,
Jan 3, 2014, 9:16:10 AM1/3/14
to puppet...@googlegroups.com
Hi,
Im writing a simple ENC in Nodejs.
When I run the script manually with some hostname it returns a valid YAML (tested on http://yaml-online-parser.appspot.com/)
But when I run it from puppet I gen an error "Could not find node 'xxx'; cannot compile" in the client
and "Empty response for hosname from exec terminus" when debugging the master


I tested with a simple bash scipt with empty class and work ok:
########################################################
#!/bin/sh

echo '---
parameters:
'

exit 0

########################################################




Nodejs script example:
########################################################
#!/usr/bin/env node

var yaml = require('js-yaml');

//Initialize ENC classes
var nodeParameters = {};
var nodeClasses = {};

/*
Fill parameters and classes objects
*/

var nodeConfig = {classes: nodeClasses, parameters: nodeParameters};
console.log(yaml.safeDump(nodeConfig));
process.exit(0);
########################################################


Some idea about what i'm doing wrong, or how can debug this error?

Thanks!

Jason Antman

unread,
Jan 4, 2014, 8:35:07 AM1/4/14
to puppet...@googlegroups.com
I *think* that "Empty response" is the issue here... your script appears to be sending back YAML with just an (empty) classes hash and an (empty) parameters hash. Try putting something in parameters (at least). Also make sure that it's actually writing to STDOUT, not STDERR.

Assuming neither of those are the problem...

- Are you running the script as the same user that Puppet runs as? With the same path?
- Does puppet.conf have the absolute path to the script?
- Are you *sure* you're calling it the same way puppet is? If you run your puppetmaster in --debug mode, when a node checks in for its catalog, you should see a log entry with the full path and arguments to the command that's being run, like:
Debug: Executing '/etc/puppet/my_terminus.sh node_hostname.example.com'
- Are the permissions right (the script needs to be executable)?

Generally when I've had problems like this, they've been either permissions-related, or path-related (i.e. your script is #!/usr/bin/env node, which assumes that node is actually in puppet's path). I'd recommend doing a "sudo su - username" to the user that Puppet runs as, confirming your env and path, and then trying the script.

-Jason
--
You received this message because you are subscribed to the Google Groups "Puppet Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to puppet-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-users/7976eb3c-1f20-4d2c-98f4-3e19b33a8eca%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Jordan Cabral

unread,
Jan 6, 2014, 10:08:26 AM1/6/14
to puppet...@googlegroups.com
Thanks for the answer.

That script is just an example, in my full script y fill both classes (parameters and classes), and when i run it prints a complete yaml
Y also check in debug to see how puppet run de script, I run the same command with "sudo -su puppet" and works perfect.
I also copy the yaml returned by de script and paste it into a simple shell script and works ok.
Its like puppet doesn't like nodejs console.log.

I think i would need write my script in other language
Reply all
Reply to author
Forward
0 new messages