From 967bd3ade1c99ac48a14fabcdfb14926f529067c Mon Sep 17 00:00:00 2001 From: JohnEricson <946327+JohnEricson@users.noreply.github.com> Date: Mon, 20 Jul 2020 11:41:58 +0200 Subject: [PATCH] Add link to upload_facts.rb script and documentation how to use it in Puppet upgrades to README (#30) * Fix problem where a nodes details wouldn't load/show in puppet-catalog-diff-viewer when the JSON-file is generated on a Puppet Master that has server configuration config_version set to generate Epoch numbers. In this case these numbers where stored as numbers instead of strings in the JSON-file which caused puppet-catalog-diff-viewer to throw an exception when it tries to replace strange characters in the version string. I've verified this works in latest version of puppet-catalog-diff-viewer. See also conversation on #puppet here https://puppetcommunity.slack.com/archives/C0W298S9G/p1594642754396700. * Added link to upload_facts.rb script and documentation for when it's useful and how it's recommended to be used in a Puppet upgrade. * Clarified documentation about which Puppet versions the upload_facts.rb script should work fine on after discussion with raphink on https://github.com/camptocamp/puppet-catalog-diff/pull/30. --- README.md | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/README.md b/README.md index b908a6f..431629e 100644 --- a/README.md +++ b/README.md @@ -35,6 +35,12 @@ that the node is still active. This filtered list should contain only machines that have not been decommissioned in PuppetDB (important as compiling their catalogs would also reactive them and their exports otherwise). +When you are comparing between different versions of Puppet using two Master servers +you are going to need to copy facts from the old Master to the new one in order to be +able to compile catalogs on the new Master. This is useful when upgrading Puppet version. + +To upload facts to PuppetDB on a Master see the [Upload facts](#upload-facts-to-puppetdb) script. + ## Usage @@ -178,6 +184,37 @@ viewed in markdown using the Rakefile in this directory. A web viewer is also available at [https://github.com/camptocamp/puppet-catalog-diff-viewer](https://github.com/camptocamp/puppet-catalog-diff-viewer) +## See also + +### Upload facts to PuppetDB + +Standalone Ruby script `upload_facts.rb` that is used to upload yaml files with facts to +PuppetDB. This is useful when you are upgradering Puppet version and uses two different +Puppet Masters for this. Then you can use this script to upload facts from the old Master +to the new one. The script can also be used to just refresh the facts in PuppetDB from +the old Master. These facts are required to be able to compile the catalogs on the new +Master. + +The script uses yaml-files in the same format as stored on the Puppet Master when real +agents report their facts at the beginning of a Puppet Agent execution. + +The script is developed to be executed on the Puppet Master, so the yaml-facts files +should be copied to the new Master using scp or similar, preferably to the +`$(puppet config print vardir)/yaml/facts` directory. + +Then all files in the directory can be uploaded to PuppetDB by using this command: + +```shell +$ ./upload_facts.rb $(puppet config print vardir)/yaml/facts/*.yaml +``` + +The script is available at [https://github.com/JohnEricson/upload_facts](https://github.com/JohnEricson/upload_facts). + +It's been verified to work with uploading facts from Puppet Masters running Puppet +version 3 to Masters running version 5. It uses the [`/puppet/v3/facts/` API](https://puppet.com/docs/puppet/6.17/http_api/http_facts.html) +which is available in version 3 and >= 5 of Puppet. This API was removed in Puppet 4 but +added again in 5. + ## Authors R.I.Pienaar / www.devco.net / @ripienaar Zack Smith / @acidprime