- hosts: ansible
  remote_user: root
  become: yes
  tasks:
    - name: update packages
      apt:
        name: '*'
        state: latest
      register: apt
    - debug: var=apt.stdout_lines
    - name: Install Apache
      apt:
        name: apache2
        state: present
      register: apt
      notify:
        - Restart Apache
    - debug: var=apt.stdout_lines
    - name: Create index.html
      shell: echo "Hello From The Ansible Challenge 2" > /var/www/html/index.html
      args:
        executable: /bin/bash
      register: apt
    - debug: var=apt.stdout_lines
  handlers:
    - name: Restart Apache
      service:
        name: apache2
        state: reloaded