---
- name: Ensure Pip is installed.
  apt: name=python-pip state=present

- name: Ensure pyinotify is installed.
  pip: name=pyinotify state=present

- name: Ensure gpio-leds folder exists.
  file:
    path: /opt/gpio-leds
    state: directory
    mode: 0755

- name: Copy LED control scripts into place.
  template:
    src: "{{ item }}.j2"
    dest: "/opt/gpio-leds/{{ item }}"
    mode: 0755
  with_items: leds_scripts

- name: Make LED control scripts available in the user's PATH.
  file:
    path: "/usr/bin/{{ item }}"
    src: "/opt/gpio-leds/{{ item }}"
    state: link
  with_items: leds_scripts

- name: Set up cron jobs for LED control.
  cron: 'name="{{ item.name }}" special_time=reboot job="{{ item.job }}"'
  with_items:
    - { name: "Switch to green on RGB LED", job: "/usr/bin/rgb green" }
    - { name: "Configure onboard Pi LEDs", job: "/usr/bin/onboard-led-setup" }

---
- name: Ensure Pip is installed.
  apt: name=python-pip state=present

- name: Ensure pyinotify is installed.
  pip: name=pyinotify state=present

- name: Ensure gpio-leds folder exists.
  file:
    path: /opt/gpio-leds
    state: directory
    mode: 0755

- name: Copy LED control scripts into place.
  template:
    src: "{{ item }}.j2"
    dest: "/opt/gpio-leds/{{ item }}"
    mode: 0755
  with_items: "{{ leds_scripts }}"

- name: Make LED control scripts available in the user's PATH.
  file:
    path: "/usr/bin/{{ item }}"
    src: "/opt/gpio-leds/{{ item }}"
    state: link
  with_items: "{{ leds_scripts }}"

- name: Set up cron jobs for LED control.
  cron: 'name="{{ item.name }}" special_time=reboot job="{{ item.job }}"'
  with_items:
    - { name: "Switch to green on RGB LED", job: "/usr/bin/rgb green" }
    - { name: "Configure onboard Pi LEDs", job: "/usr/bin/onboard-led-setup" }

Fix deprecation warning in Ansible 2.0.
Fix deprecation warning in Ansible 2.0.
