Facter.add(:virtual_environment) do
  setcode do
    virtual_environment = nil
    if env_virtual = Facter::Core::Execution.execute('cat
/opt/puppet/facts/virtual_environment')
      if env_virtual =~ /(.*?)\./
        virtual_environment = $1
      else
        virtual_environment = env_virtual
      end
    end
    virtual_environment
  end
end