Search code examples
rubypuppetfacter

Why could `rb_sysopen` not be found anymore by the custom fact since the upgrade to Puppet4?


The following custom fact:

# returns latest packerversion, e.g. 0.10.1
Facter.add("latest_packerversion") do
  setcode do
    url="https://www.packer.io/downloads.html"

    file = open("#{url}")
    contents = file.read()

    match = contents.match(/Latest\sversion:\s(.*)</)
    match[1]
  end
end

worked using puppet 3.6.2, but since the upgrade to 4.5.2 the following issue occurs:

Error: Facter: error while resolving custom fact "latest_packerversion":
No such file or directory @ rb_sysopen - https://www.packer.io/downloads.html

Analysis

  • It seems that the rb_sysopen could not be found anymore for some reason (No such file or directory @ rb_sysopen) since the upgrade to Puppet 4.
  • Puppet4 seems to use an embedded ruby version instead of the one installed on the host (Puppet3):

Puppet 4, both Facter 2.4 and CFacter 0.4, the latest Hiera and Mcollective, as well Ruby 2.1.5, OpenSSL 1.0.0r, and our gem dependencies.

  • Does rb_sysopen not exist in Ruby 2.1.5? No evidence was found.
  • Perhaps a change related to facts have occurred that could cause the issue? Nothing related was found in the release notes.

Question

Why could rb_sysopen not be found anymore by the custom fact since the upgrade to Puppet4?


Solution

  • Concise

    I will include require 'open-uri' in both facts, but I do not understand why this is required since the upgrade to Puppet4

    Verbose

    Once require 'open-uri' is included in one of the custom facts the issue is solved.

    # returns latest gitversion, e.g. 2.8.2
    Facter.add("latest_gitversion") do
      setcode do
    require 'open-uri'
    
        url="https://git-scm.com/downloads"
    
        file = open("#{url}")
        contents = file.read()
    
        match = contents.match(/RelNotes.*((\d\.){2}\d)/)
        match[1]
      end
    end
    

    As soon as the require 'open-uri' has been commented out, the issue occurs again:

    Error: Facter: error while resolving custom fact "latest_gitversion": No such file or directory @ rb_sysopen - https://git-scm.com/downloads
    Error: Facter: error while resolving custom fact "latest_packerversion": No such file or directory @ rb_sysopen - https://www.packer.io/downloads.html
    

    At the moment it is unclear what is causing the issue.