docs: def _synchronize_node(configfile, node):
      """Performs the Synchronize step of a Chef run:
      Uploads all cookbooks, all roles and all databags to a node and add the
      patch for data bags
  
      Returns the node object of the node which is about to be configured,
      or None if this node object cannot be found.
  
      """
      msg = "Synchronizing nodes, environments, roles, cookbooks and data bags..."
      if env.parallel:
          msg = "[{0}]: {1}".format(env.host_string, msg)
      print(msg)
      # First upload node.json
      remote_file = '/etc/chef/node.json'
      put(configfile, remote_file, use_sudo=True, mode=400)
      with hide('stdout'):
          sudo('chown root:$(id -g -n root) {0}'.format(remote_file))
      # Remove local temporary node file
      os.remove(configfile)
      # Synchronize kitchen
      extra_opts = "-q"
      if env.follow_symlinks:
          extra_opts += " --copy-links"
      ssh_opts = ""
      if env.ssh_config_path:
          ssh_opts += " -F %s" % os.path.expanduser(env.ssh_config_path)
      if env.encrypted_data_bag_secret:
          put(env.encrypted_data_bag_secret,
              "/etc/chef/encrypted_data_bag_secret",
              use_sudo=True,
              mode=0600)
          sudo('chown root:$(id -g -n root) /etc/chef/encrypted_data_bag_secret')
  
      paths_to_sync = ['./data_bags', './roles', './environments']
      for cookbook_path in cookbook_paths:
          paths_to_sync.append('./{0}'.format(cookbook_path))
  
      # Add berksfile directory to sync_list
      if env.berksfile:
          paths_to_sync.append(env.berksfile_cookbooks_directory)
  
      if env.loglevel is "debug":
          extra_opts = ""
  
      if env.gateway:
          ssh_key_file = '.ssh/' + os.path.basename(' '.join(env.ssh_config.lookup(
              env.host_string)['identityfile']))
          ssh_opts += " " + env.gateway + " ssh -o StrictHostKeyChecking=no -i "
          ssh_opts += ssh_key_file
  
      rsync_project(
          env.node_work_path,
          ' '.join(paths_to_sync),
          exclude=('*.svn', '.bzr*', '.git*', '.hg*'),
          delete=True,
          extra_opts=extra_opts,
          ssh_opts=ssh_opts
      )
  
      if env.sync_packages_dest_dir and env.sync_packages_local_dir:
          print("Uploading packages from {0} to remote server {2} directory "
                "{1}").format(env.sync_packages_local_dir,
                              env.sync_packages_dest_dir, env.host_string)
          try:
              rsync_project(
                env.sync_packages_dest_dir,
                env.sync_packages_local_dir+"/*",
                exclude=('*.svn', '.bzr*', '.git*', '.hg*'),
                delete=True,
                extra_opts=extra_opts,
                ssh_opts=ssh_opts
              )
          except:
              print("Warning: package upload failed. Continuing cooking...")
  
      _add_environment_lib()