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 apache2 service
- 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
apt: name=apache2
No surprises here, we've already installed a package at this point. Let's add an additional instruction to have the apache2 service started:
---
- hosts: all
become: true
tasks:
- name: Install Apache
apt: name=apache2
- name: Start the apache2 services
service...