- hosts: ansible
  remote_user: root
  become: yes
  vars:
    packages:
      - apache2
      - nano
      - mysql-server
  tasks:
    - name: Install Software
      apt:
        name: "{{ item }}"
        state: present
      loop: "{{ packages }}"
    - name: Remove Software
      apt:
        name: "{{ item }}"
        state: absent
      loop: "{{ packages }}"