facter root

asked 2016-07-11 15:00:57 -0500

droopy4096 gravatar image

reading https://github.com/puppetlabs/facter/...:

  def self.setup_default_ext_facts_dirs
    if Facter::Util::Root.root?
      windows_dir = windows_data_dir
      if windows_dir.nil? then
        # Note: Beginning with Facter 3, /opt/puppetlabs/facter/facts.d will be the only
        # default external fact directory.
        @external_facts_dirs = ["/opt/puppetlabs/facter/facts.d",
                                "/etc/facter/facts.d",
                                "/etc/puppetlabs/facter/facts.d"]
      else
        @external_facts_dirs = [File.join(windows_dir, 'PuppetLabs', 'facter', 'facts.d')]
      end
    elsif ENV['HOME']
      # Note: Beginning with Facter 3, ~/.puppetlabs/opt/facter/facts.d will be the only
      # default external fact directory.
      @external_facts_dirs = [File.expand_path(File.join(ENV['HOME'], ".puppetlabs", "opt", "facter", "facts.d")),
                              File.expand_path(File.join(ENV['HOME'], ".facter", "facts.d"))]
    else
      @external_facts_dirs = []
    end
end

it is apparent that for some reason facter code was written to explicitly make custom facts different for each user on the machine. Esp. the /etc/facter/facts.d which is being used by defaul only for "root" user. This results in unexpected behavior where seemingly system-wide settings are not reflected for everybody unless they explicitely ask for it. What was the intent? Is there a workaround?

edit retag flag offensive close merge delete