Configure an Nginx Web Server

Configure a Linux host as an Nginx web server with an Ansible playbook.

We'll cover the following

Ad-hoc commands are like a rubber mallet—great for certain situations but infrequently used. Playbooks, on the other hand, are like a hammer—a general tool you’ll use a majority of the time.

Not all of the automation you write with Ansible will start as an ad-hoc command. Playbooks are also a starting point.

One example is creating a web server. Creating a web server involves several tasks, with each one building upon the next. In some cases, a task has a dependency on what came before it. A playbook is an excellent place to start with this type of automation. After all, Ansible is, first and foremost, a configuration management tool.

Let’s learn how to configure a Linux host as an Nginx web server with an Ansible playbook.

  1. Create a new file and name it configure_nginx_web_server.yml.
  2. Add the hosts line, target the all group.

Get hands-on with 1400+ tech skills courses.