About | FAQ | Help
Ask Your Question
0

Failed to find facts from PuppetDB

asked 2018-05-08 00:09:42 -0500

salientdigital gravatar image

updated 2018-05-18 16:46:38 -0500

binford2k gravatar image

I finally managed to get PuppetDB to work by disabling SSL. On master I restarted puppetdb and puppetserver.

I went onto my test node and did a test agent run, and it's completely broken.

ubuntu@www0 ~ $ sudo /opt/puppetlabs/bin/puppet agent --test
Warning: Unable to fetch my node definition, but the agent run will continue: 
Warning: Error 500 on SERVER: Server Error: Could not retrieve facts for www0.rxmg.network: Failed to find facts from PuppetDB at 
puppet:8140: Failed to execute '/pdb/query/v4/nodes/www0.rxmg.network/facts' on at least 1 of the following 'server_urls': 
https://localhost:8081
Info: Retrieving pluginfacts
Info: Retrieving plugin
Info: Retrieving locales
Info: Loading facts 
Error: Could not retrieve catalog from remote server: Error 500 on SERVER: Server Error: Failed to execute '/pdb/cmd/v1? 
checksum=89e8239a590b14f858ea56c88a788eff04417a86&version=5&certname=www0.rxmg.network&command=replace_facts&producer- 
timestamp=1525755954' on at least 1 of the following 'server_urls': https://localhost:8081 
Warning: Not using cache on failed catalog
Error: Could not retrieve catalog; skipping run

Not sure if this helps:

ubuntu@puppetmaster:~$ netstat -an | grep 8081
tcp6       0      0 :::8081                 :::*                    LISTEN
ubuntu@puppetmaster:~$ curl https://localhost:8081
curl: (35) gnutls_handshake() failed: Certificate is bad

I am using self-signed certificates created by puppet.

I'm on ubuntu, so my steps were slightly different between yum -> apt. and I use $ sudo service postgresql restart and $ sudo service puppetdb restart

When I get to the step to restart puppetdb I get the following:

ubuntu@puppetmaster:~$ sudo service puppetdb restart
Job for puppetdb.service failed because the control process exited with error code. See "systemctl status puppetdb.service" and "journalctl -xe" for details.
ubuntu@puppetmaster:~$ sudo systemctl status puppetdb.service
● puppetdb.service - puppetdb Service
   Loaded: loaded (/lib/systemd/system/puppetdb.service; disabled; vendor preset: enabled)
   Active: activating (start) since Fri 2018-05-11 23:22:30 PDT; 15s ago
  Control: 18764 (bash)
    Tasks: 15
   Memory: 304.4M
      CPU: 31.428s
   CGroup: /system.slice/puppetdb.service
           ├─18764 bash /opt/puppetlabs/server/apps/puppetdb/cli/apps/start
           ├─18772 /usr/bin/java -Xmx192m -Djava.security.egd=/dev/urandom -XX:OnOutOfMemoryError=kill -9 %p -cp /opt/puppetlabs
           └─18816 sleep 1

May 11 23:22:30 puppetmaster.rxmg.network systemd[1]: Starting puppetdb Service...
ubuntu@puppetmaster:~$ sudo journalctl -xe
-- The result is failed.
May 11 23:23:04 puppetmaster.rxmg.network systemd[1]: puppetdb.service: Unit entered failed state.
May 11 23:23:04 puppetmaster.rxmg.network systemd[1]: puppetdb.service: Failed with result 'exit-code'.
May 11 23:23:05 puppetmaster.rxmg.network systemd[1]: puppetdb.service: Service hold-off time over, scheduling restart.
May 11 23:23:05 puppetmaster.rxmg.network systemd[1]: Stopped puppetdb Service.
-- Subject: Unit puppetdb.service has finished shutting down
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit puppetdb.service has finished shutting down.
May 11 23:23:05 puppetmaster.rxmg.network systemd[1]: Starting puppetdb Service...
-- Subject: Unit puppetdb.service has begun start-up
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit puppetdb ...
(more)
edit retag flag offensive close merge delete

Comments

Update your curl command in the troubleshooting step to use the -k option since the certs are self signed. https://curl.haxx.se/docs/manpage.html#-k

binford2k gravatar imagebinford2k ( 2018-05-08 14:03:13 -0500 )edit

2 Answers

Sort by » oldest newest most voted
0

answered 2018-05-18 16:48:11 -0500

binford2k gravatar image

updated 2018-05-18 16:52:10 -0500

You've got a couple things going on. You're mixing up "puppet" and "localhost" hostnames. See the error message:

Warning: Error 500 on SERVER: Server Error: Could not retrieve facts for www0.rxmg.network: Failed to find facts from PuppetDB at puppet:8140:

Then later on, you're curling https://localhost:8081

Also, the logs you're showing are just the final parts, after PuppetDB has failed to start. All it's telling you is that it can't start. The interesting parts will be in the stack trace prior to that. In other words, use the -n flag to get more lines of output from journalctl.

Finally, look in PuppetDB's logfile itself: /var/log/puppetlabs/puppetdb/puppetdb.log

edit flag offensive delete link more
0

answered 2018-05-09 00:03:52 -0500

Hypnoz gravatar image

Can you run this command and see if you get output?

curl -X GET http://localhost:8080/pdb/query/v4/facts --data-urlencode 'query=["=", "name", "operatingsystem"]'

I get output running that from my puppetdb.

Check that the file /etc/puppetlabs/puppet/puppetdb.conf is owned by puppet:puppet and has contents like this:

[main]
server_urls = https://localhost:8081

I see someone else posted a while ago with the same issue. Maybe some of their troubleshooting steps would help? https://ask.puppet.com/question/29112...

Otherwise, here's the steps I documented for setting up puppet db. Maybe check all the steps against your configs. If you made some changes, make sure to restart all the services.

edit: /etc/yum.repos.d/postgresql96.repo

[pgdg96]
name=PostgreSQL 9.6 $releasever - $basearch
baseurl=https://download.postgresql.org/pub/repos/yum/9.6/redhat/rhel-$releasever-$basearch
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-PGDG-96

edit: /etc/pki/rpm-gpg/RPM-GPG-KEY-PGDG-96

-----BEGIN PGP PUBLIC KEY BLOCK-----
Version: GnuPG v1.4.7 (GNU/Linux)

mQGiBEeD8koRBACC1VBRsUwGr9gxFFRho9kZpdRUjBJoPhkeOTvp9LzkdAQMFngr
BFi6N0ov1kCX7LLwBmDG+JPR7N+XcH9YR1coSHpLVg+JNy2kFDd4zAyWxJafjZ3a
9zFg9Yx+0va1BJ2t4zVcmKS4aOfbgQ5KwIOWUujalQW5Y+Fw39Gn86qjbwCg5dIo
tkM0l19h2sx50D027pV5aPsD/2c9pfcFTbMhB0CcKS836GH1qY+NCAdUwPs646ee
Ex/k9Uy4qMwhl3HuCGGGa+N6Plyon7V0TzZuRGp/1742dE8IO+I/KLy2L1d1Fxrn
XOTBZd8qe6nBwh12OMcKrsPBVBxn+iSkaG3ULsgOtx+HHLfa1/p22L5+GzGdxizr
peBuA/90cCp+lYcEwdYaRoF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kLm+ZsD+90Pe66w9vB00cxXuHLzm8Pad
GaCXCY8h3xi6VIhJBBgRAgAJBQJHg/JKAhsMAAoJEB8W0uFELfD4K4cAoJ4yug8y
1U0cZEiF5W25HDzMTtaDAKCaM1m3Cbd+AZ0NGWNg/VvIX9MsPA==
=au6K
-----END PGP PUBLIC KEY BLOCK-----

Install puppetdb

yum install puppet puppetdb yum install postgresql96-server postgresql96 postgresql96-contrib postgresql96-libs
run `puppet agent --test`
/usr/pgsql-9.6/bin/postgresql96-setup initdb
systemctl start postgresql-9.6
sudo -u postgres sh
createuser -DRSP puppetdb
    enter pw: puppetdb
createdb -E UTF8 -O puppetdb puppetdb

vi /var/lib/pgsql/9.6/data/pg_hba.conf:

# TYPE  DATABASE   USER   CIDR-ADDRESS  METHOD
local   all        all                  md5
host    all        all    127.0.0.1/32  md5
host    all        all    ::1/128       md5

systemctl restart postgresql-9.6

edit: /etc/puppetlabs/puppetdb/conf.d/database.ini

[database]
subname = //localhost:5432/puppetdb
username = puppetdb
password = puppetdb
log-slow-statements = 10

edit: /etc/puppetlabs/puppetdb/conf.d/jetty.ini add this line

host = 0.0.0.0

start puppetdb

systemctl start puppetdb

Testing:

Check all ports are listening on netstat

$ netstat -nlp | egrep "8080|8081|5432"

Connect to the postgresql db:

psql -h localhost -U puppetdb puppetdb

If for some reason all this stuff still doesn't work, I wrote up a full writeup a while ago for how I installed a working puppet environment which may help you:

https://ask.puppet.com/question/33483...

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2018-05-08 00:09:42 -0500

Seen: 95 times

Last updated: May 18