check_unwanted_filesystems

in cookbooks/fb_fstab/libraries/provider.rb [256:346]


    def check_unwanted_filesystems
      
      devs_to_skip = node['fb_fstab']['umount_ignores']['devices'].dup
      dev_prefixes_to_skip =
        node['fb_fstab']['umount_ignores']['device_prefixes'].dup
      mounts_to_skip =
        node['fb_fstab']['umount_ignores']['mount_points'].dup
      mount_prefixes_to_skip =
        node['fb_fstab']['umount_ignores']['mount_point_prefixes'].dup
      fstypes_to_skip = node['fb_fstab']['umount_ignores']['types'].dup

      base_mounts = get_unmasked_base_mounts(:hash)

      
      desired_mounts = node['fb_fstab']['mounts'].to_hash

      fs_data = node.filesystem_data
      fs_data['by_pair'].to_hash.each_value do |mounted_data|
        
        
        
        unless mounted_data['mount']
          Chef::Log.debug(
            "fb_fstab: Skipping umount check for #{mounted_data['device']} " +
            "- it isn't mounted.",
          )
          next
        end
        
        if mounted_data.key?('inodes_used') && !mounted_data.key?('kb_used')
          Chef::Log.debug(
            'fb_fstab: Skipping mal-formed Chef 12 "df -i" entry ' +
            mounted_data.to_s,
          )
          next
        end
        
        if devs_to_skip.include?(mounted_data['device'])
          Chef::Log.debug(
            "fb_fstab: Skipping umount check for #{mounted_data['device']} " +
            "(#{mounted_data['mount']}): exempted device",
          )
          next
        elsif mounts_to_skip.include?(mounted_data['mount'])
          Chef::Log.debug(
            "fb_fstab: Skipping umount check for #{mounted_data['device']} " +
            "(#{mounted_data['mount']}): exempted mountpoint",
          )
          next
        elsif fstypes_to_skip.include?(mounted_data['fs_type'])
          Chef::Log.debug(
            "fb_fstab: Skipping umount check for #{mounted_data['device']} " +
            "(#{mounted_data['mount']}): exempted fstype",
          )
          next
        elsif dev_prefixes_to_skip.any? do |i|
          mounted_data['device']&.start_with?(i)
        end
          Chef::Log.debug(
            "fb_fstab: Skipping umount check for #{mounted_data['device']} " +
            "(#{mounted_data['mount']}) - exempted device prefix",
          )
          next
        elsif mount_prefixes_to_skip.any? do |i|
          mounted_data['mount']&.start_with?(i)
        end
          Chef::Log.debug(
            "fb_fstab: Skipping umount check for #{mounted_data['device']} " +
            "(#{mounted_data['mount']}) - exempted mount_point prefix",
          )
          next
        end

        
        next if should_keep(mounted_data, desired_mounts, base_mounts)

        if node['fb_fstab']['enable_unmount']
          converge_by "unmount #{mounted_data['mount']}" do
            umount(mounted_data['mount'], mounted_data['lock_file'])
          end
        else
          Chef::Log.warn(
            "fb_fstab: Would umount #{mounted_data['device']} from " +
            "#{mounted_data['mount']}, but " +
            'node["fb_fstab"]["enable_unmount"] is false',
          )
          Chef::Log.debug("fb_fstab: #{mounted_data}")
        end
      end
    end