If you were following along with all parts of this series, at this point you should be familiar with installing system packages, applying templates, and using handlers in Ansible playbooks. In this part of the series, you’ll use what you’ve seen so far to create a playbook that automates setting up a remote Nginx server to host a static HTML website on Ubuntu 20.04.

Start by creating a new directory on your Ansible control node where you’ll set up the Ansible files and a demo static HTML website to be deployed to your remote server. This could be in any location of your choice within your home folder. In this example we’ll use ~/ansible-nginx-demo.

mkdir ~/ansible-nginx-demo
cd ~/ansible-nginx-demo

Next, copy your existing inventory file into the new directory. In this example, we’ll use the same inventory you set up at the beginning of this series:

cp ~/ansible-practice/inventory .

This will copy a file named inventory from a folder named ansible-practice in your home directory, and save it to the current directory.

Obtaining the Demo Website

For this demonstration, we’ll use a static HTML website that is the subject of our How To Code in HTML series. Start by downloading the demo website files by running the following command:

curl -L https://github.com/do-community/html_demo_site/archive/refs/heads/main.zip -o html_demo.zip

You’ll need unzip to unpack the contents of this download. To make sure you have this tool installed, run:

sudo apt install unzip

Then, unpack the demo website files with:

unzip html_demo.zip

This will create a new directory called html_demo_site-main on your current working directory. You can check the contents of the directory with an ls -la command:

ls -la html_demo_site-main

Output
total 28
drwxrwxr-x 3 sammy sammy 4096 sep 18 2020 .
drwxrwxr-x 5 sammy sammy 4096 mrt 25 15:03 …
-rw-rw-r-- 1 sammy sammy 1289 sep 18 2020 about.html
drwxrwxr-x 2 sammy sammy 4096 sep 18 2020 images
-rw-rw-r-- 1 sammy sammy 2455 sep 18 2020 index.html
-rw-rw-r-- 1 sammy sammy 1079 sep 18 2020 LICENSE
-rw-rw-r-- 1 sammy sammy 675 sep 18 2020 README.md

#html #website #ansible #ubuntu 20.04

How To Deploy a Static HTML Website with Ansible on Ubuntu 20.04 (Nginx)
1.45 GEEK