Hi all, How can I debug external node script errors? I cant seem to figure out what is wrong with my script. It appears to work from the command line, but not from puppet. thanks, Dan --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Puppet Users" group. To post to this group, send email to puppet-users@googlegroups.com To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en -~----------~----~----~----~------~----~------~--~---
Le mercredi 24 juin 2009 à 10:02 +0200, Dan Bode a écrit :> Hi all, > > How can I debug external node script errors? I cant seem to figure out > what is wrong with my script. It appears to work from the command > line, but not from puppet.Run your master with --debug --trace --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Puppet Users" group. To post to this group, send email to puppet-users@googlegroups.com To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en -~----------~----~----~----~------~----~------~--~---
I just had to solve it the old fashion way. Write statements to a log file,
and find the broken line. The issue was that a file did not have proper read
permissions for the puppet user.
trace is not very helpful
here is the server on trace:
#puppetmasterd --no-daemonize --verbose --debug --trace
debug: Executing ''/etc/puppet/conf/node_classifier HOST.com''
/usr/lib/ruby/site_ruby/1.8/puppet/indirector/catalog/compiler.rb:18:in
`find''
/usr/lib/ruby/site_ruby/1.8/puppet/indirector/indirection.rb:210:in
`find''
/usr/lib/ruby/site_ruby/1.8/puppet/indirector.rb:49:in `find''
/usr/lib/ruby/site_ruby/1.8/puppet/network/handler/master.rb:65:in
`getconfig''
/usr/lib/ruby/gems/1.8/gems/activesupport-2.0.2/lib/active_support/inflector.rb:257:in
`to_proc''
/usr/lib/ruby/site_ruby/1.8/puppet/network/xmlrpc/processor.rb:52:in
`call''
/usr/lib/ruby/site_ruby/1.8/puppet/network/xmlrpc/processor.rb:52:in
`protect_service''
/usr/lib/ruby/site_ruby/1.8/puppet/network/xmlrpc/processor.rb:85:in
`setup_processor''
/usr/lib/ruby/1.8/xmlrpc/server.rb:336:in `call''
/usr/lib/ruby/1.8/xmlrpc/server.rb:336:in `dispatch''
/usr/lib/ruby/1.8/xmlrpc/server.rb:323:in `each''
/usr/lib/ruby/1.8/xmlrpc/server.rb:323:in `dispatch''
/usr/lib/ruby/1.8/xmlrpc/server.rb:366:in `call_method''
/usr/lib/ruby/1.8/xmlrpc/server.rb:378:in `handle''
/usr/lib/ruby/site_ruby/1.8/puppet/network/xmlrpc/processor.rb:44:in
`process''
/usr/lib/ruby/site_ruby/1.8/puppet/network/xmlrpc/webrick_servlet.rb:68:in
`service''
/usr/lib/ruby/1.8/webrick/httpserver.rb:104:in `service''
/usr/lib/ruby/1.8/webrick/httpserver.rb:65:in `run''
/usr/lib/ruby/1.8/webrick/server.rb:173:in `start_thread''
/usr/lib/ruby/1.8/webrick/server.rb:162:in `start''
/usr/lib/ruby/1.8/webrick/server.rb:162:in `start_thread''
/usr/lib/ruby/1.8/webrick/server.rb:95:in `start''
/usr/lib/ruby/1.8/webrick/server.rb:92:in `each''
/usr/lib/ruby/1.8/webrick/server.rb:92:in `start''
/usr/lib/ruby/1.8/webrick/server.rb:23:in `start''
/usr/lib/ruby/1.8/webrick/server.rb:82:in `start''
/usr/lib/ruby/site_ruby/1.8/puppet.rb:293:in `start''
/usr/lib/ruby/site_ruby/1.8/puppet.rb:144:in `newthread''
/usr/lib/ruby/site_ruby/1.8/puppet.rb:143:in `initialize''
/usr/lib/ruby/site_ruby/1.8/puppet.rb:143:in `new''
/usr/lib/ruby/site_ruby/1.8/puppet.rb:143:in `newthread''
/usr/lib/ruby/site_ruby/1.8/puppet.rb:291:in `start''
/usr/lib/ruby/site_ruby/1.8/puppet.rb:290:in `each''
/usr/lib/ruby/site_ruby/1.8/puppet.rb:290:in `start''
/usr/sbin/puppetmasterd:285
err: Could not call: Could not find node NODE.com''; cannot compile
Here is the script run from the command line:
# /etc/puppet/conf/node_classifier HOST.com
/etc/puppet/conf/node_classifier:26:in `initialize'': No such file or
directory - /etc/puppet/conf/inventory.csv (Errno::ENOENT)
from /etc/puppet/conf/node_classifier:26:in `new''
from /etc/puppet/conf/node_classifier:26:in `getHost''
from /etc/puppet/conf/node_classifier:133
On Wed, Jun 24, 2009 at 10:12 AM, Nicolas Szalay
<nszalay@qualigaz.com>wrote:
>
> Le mercredi 24 juin 2009 à 10:02 +0200, Dan Bode a écrit :
> > Hi all,
> >
> > How can I debug external node script errors? I cant seem to figure out
> > what is wrong with my script. It appears to work from the command
> > line, but not from puppet.
>
> Run your master with --debug --trace
>
>
> >
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Puppet Users" group.
To post to this group, send email to puppet-users@googlegroups.com
To unsubscribe from this group, send email to
puppet-users+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/puppet-users?hl=en
-~----------~----~----~----~------~----~------~--~---
Le mercredi 24 juin 2009 à 10:28 +0200, Dan Bode a écrit :> # /etc/puppet/conf/node_classifier HOST.com > /etc/puppet/conf/node_classifier:26:in `initialize'': No such file or > directory - /etc/puppet/conf/inventory.csv (Errno::ENOENT) > from /etc/puppet/conf/node_classifier:26:in `new'' > from /etc/puppet/conf/node_classifier:26:in `getHost'' > from /etc/puppet/conf/node_classifier:133You previously said it was fine from the command line ?!? --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Puppet Users" group. To post to this group, send email to puppet-users@googlegroups.com To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en -~----------~----~----~----~------~----~------~--~---
This is not my original error, I have fixed that. My original error did not output to stderr (from the script execution) because it was a permissions issue with the puppet user. I created this error as an example to show that error outputs from script execution are being suppressed at trace level. regards, Dan --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Puppet Users" group. To post to this group, send email to puppet-users@googlegroups.com To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en -~----------~----~----~----~------~----~------~--~---
Hello,
Alright, my puppetmaster configuration works without external nodes,
but I really need my external node script to work.
In my /etc/puppet/puppet.conf I have the following:
[main]
...
node_terminus = exec
external_nodes = /etc/puppet/tools/external_nodes.py
When running puppetmaster, I get:
[root@vpsadmins ~]# puppetmasterd --no-daemonize --verbose --debug
[--snip--]
info: Listening on port 8140
notice: Starting Puppet server version 0.24.8
debug: Overriding dc2-vps1-400.example.com with cert name dc2-
vps1-400b.example.com
info: access[fileserver]: allowing *.example.com access
info: access[puppetmaster]: allowing *.example.com access
info: access[resource]: allowing vpsadmins.example.com access
info: access[puppetbucket]: allowing *.example.com
access info: access
[puppetreports]: allowing *.example.com access
debug: Allowing authenticated client dc2-vps1-400b.example.com
(67.227.199.245) access to puppet
master.getconfig
debug: Our client is remote
debug: Executing ''/etc/puppet/tools/external_nodes.py dc2-
vps1-400b.example.com''
err: Could not call: Could not find node
''dc2-vps1-400b.example.com'';
cannot compile
notice: Caught INT; shutting down
debug: Signal caught here:
debug: /usr/lib/ruby/site_ruby/1.8/puppet/external/event-loop/event-
loop.rb:127:in `call''
debug: /usr/lib/ruby/site_ruby/1.8/puppet/external/event-loop/event-
loop.rb:127:in `select''
debug: /usr/lib/ruby/site_ruby/1.8/puppet/external/event-loop/event-
loop.rb:127:in `select''
debug: /usr/lib/ruby/site_ruby/1.8/puppet/external/event-loop/event-
loop.rb:116:in `iterate''
debug: /usr/lib/ruby/site_ruby/1.8/puppet/external/event-loop/event-
loop.rb:107:in `run''
debug: /usr/lib/ruby/site_ruby/1.8/puppet.rb:320:in `start''
debug: /usr/sbin/puppetmasterd:285
notice: Shutting down
When I run the script directly:
[root@vpsadmins ~]# python /etc/puppet/tools/external_nodes.py dc2-
vps1-400b.example.com
---
classes:
- custom
- monitoring::base
- ntpd
- puppetd
- rpms
- sshd
- yum
- crontab
- iptables
- ldap::client
- monitoring::vps
- sudo
- virtuozzo
- vpsscripts
Here''s the script I am running:
#!/usr/local/bin/python
#
# external_nodes.py
# Take a YAML file containing node types, regular expressions to
match
# a hostname, and which modules are get loaded for each node type.
# Print to stdout the list of classes (in YAML) associated with the
node
# type. This script is currently not very pythonic.
#
# TODO: actual error checking, particularly for file handling
### Imports
import sys
import re
import time
import yaml
### Constants
# puppet user must have read acces to this
NODEFILE = ''/etc/puppet/nodes.yaml''
# puppet user must have write access to this
LOGFILE = ''/var/log/puppet/nodes.log''
### Arguments
hostname = sys.argv[1]
### Functions
# Open NODESFILE and load the two documents into structures, return as
tuple
def parse_nodefile():
f = file(NODEFILE, ''r'')
docs = yaml.load_all(f.read())
f.close()
return (docs.next(), docs.next())
# Write a msg to LOGFILE
def log(msg):
f = file(LOGFILE, ''a'')
timestamp = time.strftime(''%Y%m%d-%H:%M'')
f.write(timestamp + '' - '' + msg + ''\n'')
f.close()
### Action!
(regexes, modules) = parse_nodefile()
for nodetype, regexlist in regexes.iteritems():
for regex in regexlist:
p = re.compile(regex)
m = p.match(hostname)
if m:
found_nodetype = nodetype
modulelist = modules[''default'']
try:
if found_nodetype and modules[found_nodetype] is not None:
modulelist.extend(modules[found_nodetype])
except NameError:
log(hostname + '' doesn\''t match a defined node
type'')
sys.exit(1)
yamldoc = {''classes'': modulelist}
print yaml.dump(yamldoc, explicit_start=True,
default_flow_style=False)
# Puppet expects a return code of 0 to signal to indicate success
# and non-zero for error or a non-regcognized hostname
sys.exit(0)
This particular server is covered by this in my nodes.yaml:
- ^dc2-vps[12]-[2-9][0-9][0-9]b\.example\.com$
According to the wiki all I need to do is return YAML with an exit
code of 0, which this script does.
Anyone have any ideas as to why I am getting this error?
I appreciate any help,
Curt Micol
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Puppet Users" group.
To post to this group, send email to puppet-users@googlegroups.com
To unsubscribe from this group, send email to
puppet-users+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/puppet-users?hl=en
-~----------~----~----~----~------~----~------~--~---
Le lundi 29 juin 2009 à 01:09 -0700, Curt Micol a écrit :> When I run the script directly: > [root@vpsadmins ~]# python /etc/puppet/tools/external_nodes.py dc2- > vps1-400b.example.com > --- > classes: > - custom > - monitoring::base > - ntpd > - puppetd > - rpms > - sshd > - yum > - crontab > - iptables > - ldap::client > - monitoring::vps > - sudo > - virtuozzo > - vpsscriptsDid you try running it as the "puppet" user ? permissions on NODEFILE & LOGFILE could be source of errors. Regards, Nicolas
2009/6/29 Nicolas Szalay <nszalay@qualigaz.com>:> Le lundi 29 juin 2009 à 01:09 -0700, Curt Micol a écrit : > Did you try running it as the "puppet" user ? permissions on NODEFILE & > LOGFILE could be source of errors.Yes, sorry, I get the same results with running as the puppet user. Just tested once more to verify and received the same error. -- # Curt Micol --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Puppet Users" group. To post to this group, send email to puppet-users@googlegroups.com To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en -~----------~----~----~----~------~----~------~--~---
Hi Curt, Did you manage to resolve this issue? If not I think it may be the format of your yaml output.>--- >classes: >- custom >- monitoring::baseShould be this --- classes: - custom - monitoring::base Note the indentation. Having said that I have been unable to persuade the python yaml module to produce this as yet. Hope this helps Martin On Mon, Jun 29, 2009 at 10:39 AM, Curt Micol<asenchi@gmail.com> wrote:> > 2009/6/29 Nicolas Szalay <nszalay@qualigaz.com>: >> Le lundi 29 juin 2009 à 01:09 -0700, Curt Micol a écrit : >> Did you try running it as the "puppet" user ? permissions on NODEFILE & >> LOGFILE could be source of errors. > > Yes, sorry, I get the same results with running as the puppet user. > Just tested once more to verify and received the same error. > > -- > # Curt Micol > > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Puppet Users" group. To post to this group, send email to puppet-users@googlegroups.com To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en -~----------~----~----~----~------~----~------~--~---
On Fri, Jul 3, 2009 at 12:05 PM, Martin Wheldon<mwheldon@googlemail.com> wrote:> > Hi Curt, > > Did you manage to resolve this issue? If not I think it may be the > format of your yaml output. > >>--- >>classes: >>- custom >>- monitoring::base > > Should be this > > --- > classes: > - custom > - monitoring::base > > Note the indentation. Having said that I have been unable to persuade > the python yaml module to produce this > as yet. > > Hope this helpsHey Martin, Thanks for the response. I did indeed get this working, it turns out it wasn''t Puppet at all. The path for finding Python was incorrect, so while I was pointing it at /usr/local/bin/python it wasn''t finding it and using /usr/bin/python which for some reason this script can''t use (version issues). How and why this is, I don''t know, but that''s about as close to the reason as I was able to get. I think YAML is white space agnostic due to the ''-'' and '':'' syntax. I could be wrong though. I hope to get some time and send in a patch to update the output on errors for executing external nodes, 4 days trying to figure out this issue was quite annoying and the error did little to help remedy the issue. Thanks again for the reponse, -- # Curt Micol --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Puppet Users" group. To post to this group, send email to puppet-users@googlegroups.com To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en -~----------~----~----~----~------~----~------~--~---
Hi Curt, I realize this is 3 year s later, but do you have any idea how one debugs such an issue in 2012? Cheers, Virgil On Friday, July 3, 2009 2:13:14 PM UTC-7, Curt Micol wrote:> > On Fri, Jul 3, 2009 at 12:05 PM, Martin Wheldon<mwhe...@googlemail.com<javascript:>> > wrote: > > > > Hi Curt, > > > > Did you manage to resolve this issue? If not I think it may be the > > format of your yaml output. > > > >>--- > >>classes: > >>- custom > >>- monitoring::base > > > > Should be this > > > > --- > > classes: > > - custom > > - monitoring::base > > > > Note the indentation. Having said that I have been unable to persuade > > the python yaml module to produce this > > as yet. > > > > Hope this helps > > Hey Martin, > > Thanks for the response. I did indeed get this working, it turns out > it wasn''t Puppet at all. The path for finding Python was incorrect, so > while I was pointing it at /usr/local/bin/python it wasn''t finding it > and using /usr/bin/python which for some reason this script can''t use > (version issues). How and why this is, I don''t know, but that''s about > as close to the reason as I was able to get. > > I think YAML is white space agnostic due to the ''-'' and '':'' syntax. I > could be wrong though. > > I hope to get some time and send in a patch to update the output on > errors for executing external nodes, 4 days trying to figure out this > issue was quite annoying and the error did little to help remedy the > issue. > > Thanks again for the reponse, > > -- > # Curt Micol > >-- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To view this discussion on the web visit https://groups.google.com/d/msg/puppet-users/-/aTahLqqWzIwJ. To post to this group, send email to puppet-users@googlegroups.com. To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.