---
- hosts: all
  vars:
  sudo: yes
  tasks:
  - name: assert debian
    assert:
      that: "ansible_os_family == 'Debian'"
  - name: add line to source interfaces.d
    lineinfile: dest=/etc/network/interfaces
                line="source-directory interfaces.d"
                backup=yes
  - name: comment allow-hotplug eth0
    lineinfile: dest=/etc/network/interfaces
                line="# allow-hotplug eth0"
                regexp="allow-hotplug eth0"
                backup=yes
  - name: comment dhcp setup for eth0
    lineinfile: dest=/etc/network/interfaces
                line="# iface eth0 inet dhcp"
                regexp="iface eth0 inet dhcp"
                backup=yes
  - name: put interfaces file for static IP
    copy: src=debian_setup.static_ip.interfaces
          dest=/etc/network/interfaces.d/static_ip
    notify:
    - restart networking service

  handlers:
  - name: restart networking service
    service: name=networking state=restarted