bootstrap_pgroups

in cookbooks/fb_users/resources/default.rb [21:70]


  def bootstrap_pgroups
    
    
    if node['fb_users']['user_defaults']['gid']
      pgroups = [node['fb_users']['user_defaults']['gid']]
    end

    pgroups += node['fb_users']['users'].map { |_, info| info['gid'] }
    pgroups = pgroups.compact.sort.uniq
    Chef::Log.debug(
      'fb_users: the following groups are GIDs and may need bootstrapping: ' +
      "#{pgroups.join(', ')}.",
    )
    pgroups.each do |grp|
      if node['etc']['group'][grp] &&
          node['etc']['group'][grp]['gid'] == ::FB::Users::GID_MAP[grp]['gid']
        Chef::Log.debug(
          "fb_users: Will not bootstrap group #{grp} since it exists, and has" +
          ' the right GID',
        )
        next
      end

      info = node['fb_users']['groups'][grp]

      
      
      if info && info['action'] && info['action'] != :delete
        group "bootstrap #{grp}" do 
          group_name grp
          gid ::FB::Users::GID_MAP[grp]['gid']
          action :create
          
          
          
          info['notifies']&.each_value do |notif|
            timing = notif['timing'] || 'delayed'
            notifies notif['action'].to_sym, notif['resource'], timing.to_sym
          end
        end
      else
        Chef::Log.debug(
          "fb_users: Will not bootstrap group #{grp} since it is marked for " +
          'deletion',
        )
        next
      end
    end
  end