- hosts: ansible remote_user: root become: yes tasks: - name: Install Apache apt: name: apache2 state: present - name: Restart Apache service: name: apache2 state: restarted - name: Remove Apache apt: name: apache2 state: absent