diff --git a/lib/facter/profiles.rb b/lib/facter/profiles.rb index af24dc7..60768aa 100644 --- a/lib/facter/profiles.rb +++ b/lib/facter/profiles.rb @@ -4,18 +4,12 @@ require 'puppet/util/plist' require 'time' - require 'tmpdir' profiles = {} if Facter.value(:os)['release']['major'].to_i >= 12 - path = Dir.mktmpdir + '/profiles.plist' - - # why???? - Facter::Util::Resolution.exec(['/usr/bin/profiles', '-C', '-o', path].join(' ')) - - plist = Puppet::Util::Plist.read_plist_file(path) + plist = Puppet::Util::Plist.parse_plist(Facter::Util::Resolution.exec(['/usr/bin/profiles', '-C', '-o', 'stdout-xml'].join(' '))) if plist.key?('_computerlevel') for item in plist['_computerlevel'] diff --git a/lib/puppet/provider/profile_manager/macos.rb b/lib/puppet/provider/profile_manager/macos.rb index 22de902..7aebf6b 100644 --- a/lib/puppet/provider/profile_manager/macos.rb +++ b/lib/puppet/provider/profile_manager/macos.rb @@ -1,5 +1,4 @@ require 'puppet/util/plist' -require 'tmpdir' Puppet::Type.type(:profile_manager).provide :macos do desc 'Provides management of mobileconfig profiles on macOS.' @@ -61,12 +60,10 @@ def writereceipt end def getinstalledstate - # profiles will only write to a nonexistant file, so we make a temp dir for it to write to. - path = Dir.mktmpdir + '/profiles.plist' - Puppet::Util::Execution.execute(['/usr/bin/profiles', '-C', '-o', path]) + Puppet::Util::Execution.execute(['/usr/bin/profiles', '-C', '-o', 'stdout-xml']) - plist = Puppet::Util::Plist.read_plist_file(path) + plist = Puppet::Util::Plist.parse_plist(Puppet::Util::Execution.execute(['/usr/bin/profiles', '-C', '-o', 'stdout-xml'])) if plist.key?('_computerlevel') for item in plist['_computerlevel']