- name: Create .bundle
  file: path=~/.bundle state=directory

# TODO: stat + register -> !result.islnk
- name: Remove exists file
  file: dest={{ item.dest }} state=absent
  with_items: '{{ symlinks }}'

- name: Link dot files
  file: src={{ playbook_dir }}/roles/dotfiles/{{ item.path }} dest={{ item.dest }} state=link
  with_items: '{{ symlinks }}'

- name: Create .bundle
  file: path=~/.bundle state=directory

- name: Check file stats
  stat: 'path={{ item }}'
  with_items: '{{ symlinks }}'
  register: file_stats
  ignore_errors: true

- name: Remove exists file
  file: dest={{ item.dest }} state=absent
  with_items: '{{ file_stats.results }}'
  when: 'item.stat is defined and not item.stat.islnk'

- name: Link dot files
  file: src={{ playbook_dir }}/roles/dotfiles/{{ item.path }} dest={{ item.dest }} state=link
  with_items: '{{ symlinks }}'

Remove exists file if file is not link
refactor: Remove exists file if file is not link
