---
- name: Check current state.
  stat:
    path: "{{ drush_path }}"
  register: drush_path_state

- name: Perform cleanup of old symlink.
  file:
    path: "{{ drush_path }}"
    state: absent
  when: drush_path_state.stat.islnk is defined and drush_path_state.stat.islnk

- name: Install Drush.
  get_url:
    url: "{{ drush_phar_url }}"
    dest: "{{ drush_path }}"

- name: Ensure Drush is executable.
  file:
    path: "{{ drush_path }}"
    mode: 0755