...

/

Configuring NGINX with Ansible

Configuring NGINX with Ansible

Discover the moving parts of an Ansible configuration.

The purpose of configuration management is to achieve a desired state for our systems. If our goal is to have our system set up with NGINX, then the desired state, in this case, would be a system configured with NGINX.

Steps to install NGINX

To achieve this desired state, we need to follow a few steps. Here are the steps to achieve the installation of NGINX for our target hosts:

Press + to interact
Installing NGINX using Ansible
Installing NGINX using Ansible
  • Defining a desired state: This means that we need to set an expected outcome of our infrastructure state. In this case, that expected state will be for our target host to have Nginx installed.

  • Writing the required playbook(s): For this, we have to define the list of steps to achieve the desired state in YAML, one play after the other and one task after the other.

  • Writing an inventory file: This requires that we write a list of hosts and add our target host in addition to the connection parameters for it.

  • Executing the playbook(s): When we have the inventory and the playbook ready, we’ll have to run the playbook that will execute our set of plays/tasks one after the other. Once the playbook finishes running, we’ll then have the desired state on the target host. It’s best that we first run any command in check mode using the -C flag before we run it in deployment mode.

  • Monitoring the playbook execution: It’s necessary to keep an eye on our playbook execution and spot any abnormality or unexpected change. We can make errors more explicit if we increase the verbosity using the -vvv flag. Increasing verbosity goes a long way in aiding troubleshooting.

Major components

Where configuration management with Ansible is ...