Putting it all together – automating web server deployment
Speaking of automating the setup of a web server, why don’t we go ahead and do exactly that? It’ll be another simple example, but it will serve you well if we demonstrate more of what Ansible can do. We will set up a playbook to perform the following tasks:
- Install Apache
 - Start the 
apache2service - Copy an HTML file for the new site
 
First, let’s set up the playbook to simply install Apache. I called mine apache.yml, but the name is arbitrary:
---
- hosts: all
  become: true
  tasks:
  - name: Install Apache
    ansible.builtin.apt:
      name: apache2
    No surprises here; we’ve already installed a package at this point. Let’s add an additional instruction to start the apache2 service:
---
- hosts: all
  become: true
  tasks:
  - name: Install Apache
    ansible.builtin.apt:
      name: apache2
  - name: Start the apache2 services
    ansible...