--- 

- name: Install packages with apt
  apt: name={{ item }} state=present
  with_items:
    - python-pip
    - python-dev
    - libcairo2-dev
    - python-twisted
    - python-cairo
    - fontconfig
    - uwsgi
    - uwsgi-plugin-python
    - sudo

- name: Use the pip package, version 13
  pip: name="Twisted==13.0" state=present

- name: Install init.d script for carbon-cache
  template: src=debian_carbon_service.j2 dest=/etc/init.d/carbon-cache
  notify: restart carbon-cache

- name: Check the install scripts perms
  file: path=/etc/init.d/{{ item }} mode=0755 owner=root group=root
  with_items:
    - carbon-cache

- name: Install uwsgi graphite config
  template: src=uwsgi_graphite.ini.j2 dest=/etc/uwsgi/apps-available/graphite.ini
  notify: restart uwsgi

- name: Enable uwsgi graphite config
  file: src=/etc/uwsgi/apps-available/graphite.ini dest=/etc/uwsgi/apps-enabled/graphite.ini state=link
  notify: restart uwsgi

- name: Make sure we have /run/uwsgi/graphite
  file: path=/run/uwsgi/graphite state=directory owner={{ graphite_user }} group={{ graphite_user }}

--- 

- name: Install packages with apt
  apt: name={{ item }} state=present update_cache=true
  with_items:
    - python-pip
    - python-dev
    - libcairo2-dev
    - python-twisted
    - python-cairo
    - fontconfig
    - uwsgi
    - uwsgi-plugin-python
    - sudo

- name: Use the pip package, version 13
  pip: name="Twisted==13.0" state=present

- name: Install init.d script for carbon-cache
  template: src=debian_carbon_service.j2 dest=/etc/init.d/carbon-cache
  notify: restart carbon-cache

- name: Check the install scripts perms
  file: path=/etc/init.d/{{ item }} mode=0755 owner=root group=root
  with_items:
    - carbon-cache

- name: Install uwsgi graphite config
  template: src=uwsgi_graphite.ini.j2 dest=/etc/uwsgi/apps-available/graphite.ini
  notify: restart uwsgi

- name: Enable uwsgi graphite config
  file: src=/etc/uwsgi/apps-available/graphite.ini dest=/etc/uwsgi/apps-enabled/graphite.ini state=link
  notify: restart uwsgi

- name: Make sure we have /run/uwsgi/graphite
  file: path=/run/uwsgi/graphite state=directory owner={{ graphite_user }} group={{ graphite_user }}

Refresh apt cache before install
Refresh apt cache before install

This avoids lots of errors on install with 404 packages