Foreman as Puppet ENC..."could not find default node or by name with..."

Having an issue that I can't quite seem to track down. I just implemented
Foreman in my testing environment and have been trying to get it setup as
an ENC for Puppet. Currently, I have Foreman set up to for reports and
have configured my Puppet master as a smart proxy within Foreman. I was
able to import all my classes from the Puppet master and assign them to
nodes in the Foreman GUI. On my Puppet master, I'm using the node.rb file
from https://raw.githubusercontent.com/theforeman/puppet-foreman/master/templates/external_node_v2.rb.erb
with the following puppet.conf:

[main]
# The Puppet log directory.
# The default value is '$vardir/log'.
logdir = /var/log/puppet

# Where Puppet PID files are kept.
# The default value is '$vardir/run'.
rundir = /var/run/puppet

# Where SSL certificates are kept.
# The default value is '$confdir/ssl'.
ssldir = $vardir/ssl
certname = puppetvip
reports = log, foreman

[agent]
# The file in which puppetd stores a list of the classes
# associated with the retrieved configuratiion. Can be loaded in
# the separate puppet executable using the --loadclasses
# option.
# The default value is '$confdir/classes.txt'.
classfile = $vardir/classes.txt

# Where puppetd caches the local configuration.  An
# extension indicating the cache format is added automatically.
# The default value is '$confdir/localconfig'.
localconfig = $vardir/localconfig
server = puppetvip
report = true

[master]
logdir = /var/log/puppet
rundir = /var/run/puppet
ssldir = $vardir/ssl
external_nodes = /etc/puppet/node.rb
node_terminus = exec

On the Puppet master, in the nodes.pp file I have my test node commented
out:

[root@xxciripuppet1 puppet]# cat manifests/nodes.pp
#node /(xxcirihaproxy|XXCIRIHAPROXY)/ {

include puppet::agent::service

include haproxy

#}
[root@xxciripuppet1 puppet]#

From the command line on the Puppet master, I can run the following:
[root@xxciripuppet1 puppet]# sudo -u puppet /etc/puppet/nodes.rb
xxcirihaproxy1.company.com

··· --- classes: haproxy: puppet::agent::service: parameters: puppetmaster: '' root_pw: foreman_env: production owner_name: Admin User owner_email: root@company.com environment: production [root@xxciripuppet1 puppet]# curl -ks https://ak-foreman.company.com/node/xxcirihaproxy1.company.com?format=yml --- classes: haproxy: puppet::agent::service: parameters: puppetmaster: '' root_pw: foreman_env: production owner_name: Admin User owner_email: root@company.com environment: production [root@xxciripuppet1 puppet]#

On the client, when the Puppet agent is run, the follow error is generated:

[root@xxcirihaproxy1 ~]# puppet agent -t
Info: Retrieving pluginfacts
Info: Retrieving plugin
Error: Could not retrieve catalog from remote server: Error 400 on SERVER:
Could not find default node or by name with ‘xxcirihaproxy1.company.com,
xxcirihaproxy1.company, xxcirihaproxy1’ on node xxcirihaproxy1.company.com
Warning: Not using cache on failed catalog
Error: Could not retrieve catalog; skipping run
[root@xxcirihaproxy1 ~]#

I know that when using the Puppet master as the ENC, typically this would
mean the master can’t classify the node or find it in nodes.pp. If I
uncomment the entry from nodes.pp, everything works just fine, but that
defeats the purpose.

Has anyone seen an issue similar to this? Any insight would be greatly
appreciated.

Thanks!

Thanks! I guess it helps if I actually read the documentation…

··· On Monday, July 21, 2014 1:28:17 PM UTC-4, Steve Perry wrote: > > Having an issue that I can't quite seem to track down. I just implemented > Foreman in my testing environment and have been trying to get it setup as > an ENC for Puppet. Currently, I have Foreman set up to for reports and > have configured my Puppet master as a smart proxy within Foreman. I was > able to import all my classes from the Puppet master and assign them to > nodes in the Foreman GUI. On my Puppet master, I'm using the node.rb file > from > https://raw.githubusercontent.com/theforeman/puppet-foreman/master/templates/external_node_v2.rb.erb > with the following puppet.conf: > > [main] > # The Puppet log directory. > # The default value is '$vardir/log'. > logdir = /var/log/puppet > > # Where Puppet PID files are kept. > # The default value is '$vardir/run'. > rundir = /var/run/puppet > > # Where SSL certificates are kept. > # The default value is '$confdir/ssl'. > ssldir = $vardir/ssl > certname = puppetvip > reports = log, foreman > > [agent] > # The file in which puppetd stores a list of the classes > # associated with the retrieved configuratiion. Can be loaded in > # the separate ``puppet`` executable using the ``--loadclasses`` > # option. > # The default value is '$confdir/classes.txt'. > classfile = $vardir/classes.txt > > # Where puppetd caches the local configuration. An > # extension indicating the cache format is added automatically. > # The default value is '$confdir/localconfig'. > localconfig = $vardir/localconfig > server = puppetvip > report = true > > [master] > logdir = /var/log/puppet > rundir = /var/run/puppet > ssldir = $vardir/ssl > external_nodes = /etc/puppet/node.rb > node_terminus = exec > > On the Puppet master, in the nodes.pp file I have my test node commented > out: > > [root@xxciripuppet1 puppet]# cat manifests/nodes.pp > #node /(xxcirihaproxy|XXCIRIHAPROXY)/ { > # include puppet::agent::service > # include haproxy > #} > [root@xxciripuppet1 puppet]# > > From the command line on the Puppet master, I can run the following: > [root@xxciripuppet1 puppet]# sudo -u puppet /etc/puppet/nodes.rb > xxcirihaproxy1.company.com > --- > classes: > haproxy: > puppet::agent::service: > parameters: > puppetmaster: '' > root_pw: > foreman_env: production > owner_name: Admin User > owner_email: root@company.com > environment: production > [root@xxciripuppet1 puppet]# curl -ks > https://ak-foreman.company.com/node/xxcirihaproxy1.company.com?format=yml > --- > classes: > haproxy: > puppet::agent::service: > parameters: > puppetmaster: '' > root_pw: > foreman_env: production > owner_name: Admin User > owner_email: root@company.com > environment: production > [root@xxciripuppet1 puppet]# > > On the client, when the Puppet agent is run, the follow error is generated: > > [root@xxcirihaproxy1 ~]# puppet agent -t > Info: Retrieving pluginfacts > Info: Retrieving plugin > Error: Could not retrieve catalog from remote server: Error 400 on SERVER: > Could not find default node or by name with 'xxcirihaproxy1.company.com, > xxcirihaproxy1.company, xxcirihaproxy1' on node xxcirihaproxy1.company.com > Warning: Not using cache on failed catalog > Error: Could not retrieve catalog; skipping run > [root@xxcirihaproxy1 ~]# > > I know that when using the Puppet master as the ENC, typically this would > mean the master can't classify the node or find it in nodes.pp. If I > uncomment the entry from nodes.pp, everything works just fine, but that > defeats the purpose. > > Has anyone seen an issue similar to this? Any insight would be greatly > appreciated. > > Thanks! >

Sounds to me like you have some node definitions in your site.pp that
don't match the node you're running the agent on. That's something
which is explicitly called out in Puppetlabs notes for mixing ENCs
with site.pp[1] - you'll want to ensure you have a "node default {}"
declaration in there.

GTH,
Greg

[1] http://docs.puppetlabs.com/guides/external_nodes.html#how-merging-works