Thought I'd leave a note about an issue I ran into when upgrading to Puppet 5.0.1, in case someone else is wrestling with the same thing (also just to provide a result for some poor person Googling it after me). Turned out to be a whole bunch of factors:
- The default serialization format is now JSON (previously PSON), which doesn't support arbitrary binary data (only UTF-8 strings)
- PUP-7602 is supposed to automatically downgrade back to PSON if there's binary data in the catalog
- But this doesn't seem to account for binary facts - you get an error on apply: "Error: Failed to apply catalog: Could not render to json: source sequence is illegal/malformed utf-8"
I surmise that a binary fact is at fault because of a debug message from Facter: "Debug: Facter: Received a log message with invalid encoding:"fact \"ec2_userdata\" has resolved to [...]" (escaped data follows) - and because I'm not shipping binary in my catalog otherwise. This is particularly annoying if you're using local VMs to test your puppet server upgrade, because you won't run into it until you run it on your production EC2 node :)
The EC2 user data is gzipped to work around a user_data size limitation. (i.e.
https://www.terraform.io/docs/providers/template/d/cloudinit_config.html#gzip) - I guess I'm not close enough to the limit that I could pay the size penalty and base-64 encode the compressed user-data as well - but you can't change user data while the instance is running, so it's not nice as a workaround.
For now, I've just reverted to PSON serialization. That's not deprecated, right? (Just the default was changed?)
(Also, I'd file a JIRA ticket, but I'm not sure whether support for binary fact values is desired or necessary, whether Facter should be giving up on passing a fact if it has a binary value, or whether a PUP-7602-style serialization fallback would be better, etc.)
Regards,
Dominic