# (on the puppet master) create a custom fact {code:javaruby}
Facter.add('test') do setcode do # This makes # Error: Facter: Error while resolving custom fact fact='sysctl', resolution='<anonymous>': invalid byte sequence in UTF-8 # go away: Encoding.default_external = Encoding::ASCII_8BIT
value = Facter::Core::Execution.execute('/bin/cat /tmp/null')
value.bytesize end
end {code} # (on the node) create some content containing leading and/or trailing NULL bytes {code:javashell}
echo -en "\x00\x00\x00\x00" > /tmp/null
{code} # (on the node) synchronize so the {{test}} fact becomes available # (on the node) query the new fact
{{puppet facts test --value-only}} reports {{4}} ({_}four{_} bytes)
# (on the puppet master) create a custom fact{code:ruby}Facter.add('test') do setcode do # This makes
# Error: Facter: Error while resolving custom fact fact='test', resolution='<anonymous>': invalid byte sequence in UTF-8
# go away: Encoding.default_external = Encoding::ASCII_8BIT
value = Facter::Core::Execution.execute('/bin/cat /tmp/null')
value.bytesize end end{code} # (on the node) create some content containing leading and/or trailing NULL bytes{code:shell}echo -en "\x00\x00\x00\x00" > /tmp/null{code} # (on the node) synchronize so the {{test}} fact becomes available
# (on the node) query the new fact{code:shell}puppet facts test --value-only{code}This reports {{0}} (zero).