OpenSource For You

The DevOps Series Ansible Deployment of LAMP and WordPress

This is the second article in the DevOps series, and covers the installati­on of a LAMP stack and WordPress, using Ansible.

-

In this article, we are going to learn how to automate the deployment of a LAMP stack and install WordPress. LAMP stands for Linux, Apache (a Web server), MySQL (a database) and PHP (serverside scripting). It is a technology stack on which you can deploy different Web applicatio­ns. We are also going to explore the installati­on of WordPress, which is free and open source software for creating websites and blogs.

Installing Linux

A Parabola GNU/Linuxlibre x86_64 system is used as the host system. An Ubuntu 15.04 image runs as a guest OS using KVM/QEMU. Ansible is installed on the host system using the distributi­on package manager. You should be able to issue commands from Ansible to the guest OS. For example:

$ ansible ubuntu -m ping ubuntu | SUCCESS => { "changed": false, "ping": "pong" }

The /etc/hosts file already has an entry for the guest Ubuntu VM.

192.168.122.250 ubuntu

On the host system, we will create a project for our playbooks. It has the following directory structure:

ansible/inventory/kvm/ /playbooks/configurat­ion/ /playbooks/admin/

An ‘inventory’ file is created inside the inventory/kvm folder that contains the following:

ubuntu ansible_-host=-192.168.-122.250 an si b le_ connection= ssh an sib le_ user= xe tex

Installing Apache

We will first install and test the Apache Web server on the guest Ubuntu system. Let’s then create a playbooks/ configurat­ion/apache.yml file with the following content:

--name: Install Apache web server hosts: ubuntu become: yes become_method: sudo gather_facts: true tags: [web] tasks:

- name: Update the software package repository apt:

update_cache: yes

- name: Install Apache package: name: "{{ item }}" state: latest with_items:

- apache2

- wait_for:

port: 80

On the Ubuntu guest system, the playbook runs aptget update and then installs the apache2 package. The playbook finishes after the server has started, and is listening on port 80. Open a terminal, enter the ansible/ folder, and execute the

 ??  ??
 ??  ??

Newspapers in English

Newspapers from India