voxpupuli/puppetboard

[QUESTION] 404 error

Closed this issue · 3 comments

I'm on CentOS 7 and have the following installation:

PuppetDB Yum package: puppetdb-6.13.1-1.el7.noarch

Puppetboard Pip packages:

Package      Version  
------------ ---------
certifi      2020.12.5
chardet      4.0.0    
click        7.1.2    
commonmark   0.9.1    
Flask        1.1.2    
Flask-WTF    0.14.3   
idna         2.10     
itsdangerous 1.1.0    
Jinja2       2.11.3   
MarkupSafe   1.1.1    
pip          9.0.3    
puppetboard  2.2.0    
pypuppetdb   2.2.0    
requests     2.25.1   
setuptools   39.2.0   
urllib3      1.26.3   
virtualenv   15.1.0   
Werkzeug     1.0.1    
WTForms      2.3.3    

When pointing the Puppet server to the PuppetDB server, I noticed these POST requests:

10.40.0.4 - - [10/Feb/2021:14:11:14 +0100] "POST /pdb/cmd/v1?checksum=cc6b8f538b18118b170558b44fa84d309d66fd15&version=9&certname=<fqdn1>&command=replace_catalog&producer-timestamp=2021-02-10T13:11:14.703Z HTTP/1.1" 200 53 "-" "Apache-HttpAsyncClient/4.1.4 (Java/11.0.8)" 11
10.40.0.4 - - [10/Feb/2021:14:11:15 +0100] "POST /pdb/cmd/v1?checksum=1584cb0518a17092ca49d3f7f50362c870c2ed90&version=5&certname=<fqdn2>&command=replace_facts&producer-timestamp=2021-02-10T13:11:15.077Z HTTP/1.1" 200 53 "-" "Apache-HttpAsyncClient/4.1.4 (Java/11.0.8)" 8
...etc...

Since the result is 200, I expect that all is fine and that the PuppetDB contains a couple of nodes. I read that I may get a 404 when the PuppetDB is empty, so I doublechecked:

>>> from pypuppetdb import connect
>>> db = connect()
>>> nodes = db.nodes()
>>> for node in nodes:
...     print(node)
... 
<fqdn1>
<fqdn2>
<..etc..>

For configuring Puppetboard I've followed "Apache + mod_wsgi" on this page, except for different file locations: https://pypi.org/project/puppetboard/

/etc/puppetlabs/puppetboard/settings.py:

PUPPETDB_HOST = 'localhost'
PUPPETDB_PORT = 8080
PUPPETDB_PROTO = 'http'
SECRET_KEY = 'my super secret key'
LOGLEVEL = 'debug'
DEFAULT_ENVIRONMENT = 'linux'

(I'm connecting to localhost, so I'd preferably not bother with https, and no I don't normally use the debug loglevel.)

/var/www/puppetboard/wsgi.py:

from __future__ import absolute_import
import os

# Needed if a settings.py file exists
os.environ['PUPPETBOARD_SETTINGS'] = '/etc/puppetlabs/puppetboard/settings.py'
from puppetboard.app import app as application

In /etc/httpd/conf.d/10-puppetboard.conf:

<VirtualHost *:80>
    ServerName puppetboard2.netmatch.eu

    WSGIDaemonProcess puppetboard user=apache group=apache threads=5
    WSGIScriptAlias / /var/www/puppetboard/wsgi.py

    ErrorLog logs/puppetboard-error_log
    CustomLog logs/puppetboard-access_log combined

    Alias /static /usr/local/lib/python3.6/site-packages/puppetboard/static
    <Directory /usr/local/lib/python3.6/site-packages/puppetboard/static>
        Satisfy Any
        Allow from all
    </Directory>

    <Directory /usr/local/lib/python3.6/site-packages/puppetboard>
        WSGIProcessGroup puppetboard
        WSGIApplicationGroup %{GLOBAL}
        Require all granted
    </Directory>
</VirtualHost>

Apache says it's WSGI enabled. I'm using this module: rh-python36-mod_wsgi-4.5.18-1.el7.x86_64

# apachectl -M | grep wsgi
 wsgi_module (shared)

Apache config:

LoadModule wsgi_module /opt/rh/httpd24/root/usr/lib64/httpd/modules/mod_rh-python36-wsgi.so
<IfModule mod_wsgi.c>
  WSGISocketPrefix /var/run/wsgi
</IfModule>

Each time I request the Puppetboard page I get a 404, and this is logged by Apache:

==> puppetboard-error_log <==
[Wed Feb 10 14:45:37.572988 2021] [wsgi:error] [pid 13163] [client 192.168.x.y:41836] DEBUG:pypuppetdb.api:_query called with endpoint: environments, path: None, query: None, limit: None, offset: None, summarize_by None, count_by None, count_filter: None, payload: None
[Wed Feb 10 14:45:37.573101 2021] [wsgi:error] [pid 13163] [client 192.168.x.y:41836] DEBUG:pypuppetdb.api:_url called with endpoint: environments and path: None
[Wed Feb 10 14:45:37.574600 2021] [wsgi:error] [pid 13163] [client 192.168.x.y:41836] DEBUG:urllib3.connectionpool:Starting new HTTP connection (1): localhost:8080
[Wed Feb 10 14:45:37.588188 2021] [wsgi:error] [pid 13163] [client 192.168.x.y:41836] DEBUG:urllib3.connectionpool:http://localhost:8080 "GET /pdb/query/v4/environments HTTP/1.1" 200 63

==> puppetboard-access_log <==
192.168.x.y - - [10/Feb/2021:14:45:37 +0100] "GET / HTTP/1.1" 404 232 "-" "Mozilla/5.0 (X11; Linux x86_64; rv:56.0) Gecko/20100101 Firefox/56.0 Waterfox/56.4"

I verified that all required/configured files exist on the configured locations, and that they are readable.

Can anyone hint me on what's wrong or how to proceed to find out what's wrong?

Thanks in advance.

It looks like you're using the default environment as DEFAULT_ENVIRONMENT = 'linux' do you have any nodes actively reporting in to that environment?
I've noticed that if Puppetboard can't see any nodes in a given environment it will give a 404 (or sometimes and Internal Server Error on Puppet 7.5+)

Try adding an /env/ on the end of your URL where env = an environment with nodes that are actively talking to PuppetDB.
For example (assuming that your Puppetboard is on the localhost) http://127.0.0.1:8000/dev/ or http://127.0.0.1:8000/production/

Isn't this de facto the same as #515 ?

This should be fixed in v3.6.0, released today. Please comment if it is not, @storm49152.