---
- name: uninstall serveur web
  hosts: serveurweb
  remote_user: root

  tasks:
    - name: Remove virtualhost
      command: a2dissite virtualhost.conf
      args:
        removes: /etc/apache2/sites-enabled/virtualhost.conf

    - name: Remove packages
      apt:
        state: absent
        pkg:
        - apache2
        - php

    - name: Delete files
      file:
        path: "{{ item }}"
        state: absent
      with_items:
        - /etc/apache2/sites-available/virtualhost.conf
        - /var/www/{{ domain }}
