dir structure

ansible_apache/ ├── playbook.yml

├── inventory.ini └── files/ └── index.html

Playbook.yml

---
- name: Deploy Apache2 and index.html on Ubuntu
  hosts: webservers
  become: true

  tasks:
    - name: Update APT cache
      apt:
        update_cache: yes

    - name: Install Apache2
      apt:
        name: apache2
        state: present

    - name: Ensure Apache2 service is running and enabled
      service:
        name: apache2
        state: started
        enabled: true

    - name: Deploy index.html
      copy:
        src: files/index.html
        dest: /var/www/html/index.html
        owner: www-data
        group: www-data
        mode: '0644'

inventory.ini

[webservers]
your-server-ip ansible_user=your-username ansible_ssh_private_key_file=/path/to/key

Simple website for this lab

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>EVLABS</title>
    <style>
        body {
            font-family: Arial, sans-serif;
            margin: 0;
            display: flex;
            justify-content: center;
            align-items: center;
            height: 100vh;
            background-color: #f4f4f9;
        }
        h1 {
            font-size: 4rem;
            color: #333;
            text-shadow: 2px 2px 5px rgba(0, 0, 0, 0.3);
        }
    </style>
</head>
<body>
    <h1>EVLABS</h1>
</body>
</html>

Fresh target machine

Screenshot 2025-01-12 at 3.48.44 pm.png

Ansible node

Screenshot 2025-01-12 at 3.57.10 pm.png

Encrypt inventory.ini file