Linux VM servers (Ubuntu)

1 x evlabs-mgmt (192.168.0.85)

1 x evlabs-c1 (192.168.0.205)

1 x evlabs-c2 (192.168.0.238)

evlabs-mgmt VM

create a directory “ansible_apache”

create a directory “ansible_apache”

Create hosts.yml and playbook ansible_apache.yml

Create hosts.yml and playbook ansible_apache.yml

all:
  children:
    clients:
      hosts:
        evlabs-c1:
          ansible_host: 192.168.0.205
          ansible_user: evlabs-c1
          ansible_password: EvlabsP@ss
          ansible_become: yes
          ansible_become_password: EvlabsP@ss
        evlabs-c2:
          ansible_host: 192.168.0.238
          ansible_user: evlabs-c2
          ansible_password: EvlabsP@ss
          ansible_become: yes
          ansible_become_password: EvlabsP@ss
---
- name: Install Apache on Client VMs
  hosts: clients
  become: yes

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

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

    - name: Ensure Apache service is running
      service:
        name: apache2
        state: started
        enabled: yes

Verify C1 and C2 don’t have Apache installed

image.png

image.png

SSH connectivity