docs: def install_packages():
      """
      Install a set of baseline packages and configure where necessary
      """
  
      if env.verbosity:
          print env.host, "INSTALLING & CONFIGURING NODE PACKAGES:"
      #Get a list of installed packages
      p = run("dpkg -l | awk '/ii/ {print $2}'").split('\n')
      
      #Remove apparmor - TODO we may enable this later
      if env.overwrite or not server_state('apparmor-disabled') and 'apparmor' in p:
          with settings(warn_only=True):
              sudo('/etc/init.d/apparmor stop')
              sudo('update-rc.d -f apparmor remove')
              set_server_state('apparmor-disabled')
  
      #The principle we will use is to only install configurations and packages
      #if they do not already exist (ie not manually installed or other method)
      env.installed_packages[env.host] = []
      role = env.role_lookup[env.host_string]
      packages = get_packages()
      for package in packages:
          if not package in p:
              install_package(package)
              if env.verbosity:
                  print ' * installed',package
              env.installed_packages[env.host].append(package)
      if env.overwrite or env.installed_packages[env.host]: #always store the latest complete list
          set_server_state('packages_installed', packages)
          env.installed_packages[env.host] = packages
  
      if env.overwrite and 'apache2' in env.installed_packages[env.host]: 
              #some sensible defaults -might move to putting this config in a template
              sudo("rm -f /etc/apache2/sites-enabled/000-default")
              sed('/etc/apache2/apache2.conf',before='KeepAlive On',after='KeepAlive Off',use_sudo=True, backup='')
              sed('/etc/apache2/apache2.conf',before='StartServers          2', after='StartServers          1', use_sudo=True, backup='')
              sed('/etc/apache2/apache2.conf',before='MaxClients          150', after='MaxClients          100', use_sudo=True, backup='')
              for module in env.APACHE_DISABLE_MODULES:
                  sudo('rm -f /etc/apache2/mods-enabled/%s*'% module)
      #Install base python packages
      #We'll use easy_install at this stage since it doesn't download if the package
      #is current whereas pip always downloads.
      #Once both these packages mature we'll move to using the standard Ubuntu packages
      if (env.overwrite or not server_state('pip-venv-wrapper-installed')) and 'python-setuptools' in packages:
          sudo("easy_install virtualenv")
          sudo("easy_install pip")
          sudo("easy_install virtualenvwrapper")
          if env.verbosity:
              print " * easy installed pip, virtualenv, virtualenvwrapper"
          set_server_state('pip-venv-wrapper-installed')
      if not contains("/home/%s/.profile"% env.user,"source /usr/local/bin/virtualenvwrapper.sh"):
          append("/home/%s/.profile"% env.user, "export WORKON_HOME=$HOME/env")
          append("/home/%s/.profile"% env.user, "source /usr/local/bin/virtualenvwrapper.sh")
  
      #cleanup after easy_install
      sudo("rm -rf build")