Automate Nginx Installation Using Ansible Centos

1 minute read


#!/usr/bin/env ansible-playbook

title: ‘Automate Nginx Installation using Ansible’ date: 2018-12-19 permalink: /posts/2018/12/automate-nginx-installation-using-ansible-centos/ tags:

  • Configuration Management
  • Ansible
  • Nginx
  • Centos

    About Nginx

Nginx is a high performance open source web server which is light-weight and load balancer program which is lighter then Apache HTTP Server.

What is an Ansible?

  • Ansible is, in short, an IT automation, configuration management and provisioning tool.
  • It uses ‘playbooks’ to deploy, manage, build, test and configure anything from full server environments to web site to custom compiled sources for applications.
  • It brings together aspects of environment management that have been traditionally separate and manage indepently. Taking control of your environment with a single tool has anumber of advantages

  • Server deployment configuration
  • Making everything consistent
  • Build or hook into other applications and control them as well
  • Redeploy fresh instance in case of failure.
  • Ansible is very often called an orchestration tool.
  • You can avoid doing the same mistake again and again by automating the configuration and deployment process.

Installing Ansible

Run the below command to install ansible in Centos

sudo yum install ansible

Hello-world with Ansible

Once all requirements are installed and you have you hosts file setup you can give it a test run. For a quick test I put into the ansible hosts file as follow:

Create sample playbook

Run Play book

ansible-playbook helloworld.yml
ansible-doc service # will display man page of the service module

Variables and handlers

Below is the folder structure