---
- hosts: vagrant
  tasks:
    - name: update apt cache
      apt: update-cache=yes cache_valid_time=3600
      sudo: yes

    - name: upgrade distro
      apt: upgrade=yes
      sudo: yes

    - name: install packages
      action: apt pkg={{ item }} state=installed
      with_items:
        - python-setuptools
        - nginx
      notify: restart nginx
      sudo: yes

    - name: install pip
      action: easy_install name=pip
      sudo: yes

    - name: install virtualenv
      action: pip name=virtualenv
      sudo: yes

    - name: create virtualenv directory
      action: file dest=/srv/yoyo/.virtualenv state=directory recurse=yes owner=vagrant group=vagrant
      sudo: yes

    - name: install app dependencies
      action: pip requirements=/srv/yoyo/requirements.txt virtualenv=/srv/yoyo/.virtualenv state=present virtualenv_site_packages=no

    - name: start gunicorn
      action: command /srv/yoyo/.virtualenv/bin/gunicorn yoyo:create_app() --config gunicorn.conf chdir=/srv/yoyo

    - name: remove /etc/nginx/sites-enabled/default
      action: file path=/etc/nginx/sites-enabled/default state=absent
      notify: restart nginx
      sudo: yes

    - name: symlink /etc/nginx/sites-enabled/yoyo
      action: file src=/srv/yoyo/nginx.conf dest=/etc/nginx/sites-enabled/yoyo state=link
      notify: restart nginx
      sudo: yes

  handlers:
    - name: restart nginx
      action: service name=nginx state=restarted enabled=yes
      sudo: yes

---
- hosts: vagrant
  vars:
    - root: /srv/yoyo
  tasks:
    - name: update apt cache
      apt: update-cache=yes cache_valid_time=3600
      sudo: yes

    - name: upgrade distro
      apt: upgrade=yes
      sudo: yes

    - name: install packages
      action: apt pkg={{ item }} state=installed
      with_items:
        - python-setuptools
        - nginx
      notify: restart nginx
      sudo: yes

    - name: install pip
      action: easy_install name=pip
      sudo: yes

    - name: install virtualenv
      action: pip name=virtualenv
      sudo: yes

    - name: create virtualenv directory
      action: file dest={{ root }}/.virtualenv state=directory recurse=yes owner=vagrant group=vagrant
      sudo: yes

    - name: install app dependencies
      action: pip requirements={{ root }}/requirements.txt virtualenv={{ root }}/.virtualenv state=present virtualenv_site_packages=no

    - name: start gunicorn
      action: command {{ root }}/.virtualenv/bin/gunicorn yoyo:create_app() --config gunicorn.conf chdir={{ root }}

    - name: remove /etc/nginx/sites-enabled/default
      action: file path=/etc/nginx/sites-enabled/default state=absent
      notify: restart nginx
      sudo: yes

    - name: symlink /etc/nginx/sites-enabled/yoyo
      action: file src={{ root }}/nginx.conf dest=/etc/nginx/sites-enabled/yoyo state=link
      notify: restart nginx
      sudo: yes

  handlers:
    - name: restart nginx
      action: service name=nginx state=restarted enabled=yes
      sudo: yes

Define a variable that contains the root path.
Define a variable that contains the root path.