self.loginctl_users

in itchef/cookbooks/cpe_helpers/libraries/cpe_helpers.rb [55:85]


    def self.loginctl_users
      @loginctl_users ||= begin
        
        loginctl_path = nil
        [
          
          '/usr/bin/loginctl',
          
          '/bin/loginctl',
        ].each do |p|
          if ::File.exist?(p)
            loginctl_path = p
            break
          end
        end

        if linux? && !loginctl_path.nil?
          
          
          res = shell_out("#{loginctl_path} --no-legend list-users")
          return [] if res.error?

          res.stdout.lines.map do |u|
            uid, uname = u.split
            { 'uid' => Integer(uid), 'user' => uname }
          end
        else []
        end
      end
    end