DevOps – Technical Blogs http://www.easywaytech.com/blog Just another WordPress site Tue, 11 Dec 2018 09:44:51 +0000 en-US hourly 1 https://wordpress.org/?v=4.7.2 Ansible http://www.easywaytech.com/blog/index.php/2016/11/21/ansible/ http://www.easywaytech.com/blog/index.php/2016/11/21/ansible/#respond Mon, 21 Nov 2016 07:38:14 +0000 http://www.easywaytech.com/blog/?p=138 Definition:

Ansible is a configuration management and provisioning tool that automates cloud provisioning, configuration management, application deployment, intra-service orchestration, and many other IT needs.

It works by establishing a connection between the nodes, through SSH, and pushing small programs called modules. In Ansible-speak, a script is called a playbook. A playbook usually contains a list of hosts (what Ansible calls remote servers) that need to be configured and an ordered list of tasks to perform on those hosts.

Why Ansible:

  • Resource utilization: Ansible is an agent-less software and does not require any extra services or daemons to be installed on its nodes.
  • Security: Ansible uses SSH connection protocol between Ansible server and its nodes. Using an SSH connection is more secure because the connection is encrypted.
  • Idempotency: Ansible modules are idempotent which means that modules can be safely re-run any number of times.
  • Simple Code: Ansible programs or modules are written in simple YAML script files and can be created either by placing everything in a single file or by following a structured model.

Below is the comparison chart for some of the configuration management tools available:

Parameter/Tool Ansible Chef Puppet
Architecture Agent Less Master/Agent Master/Agent
Mechanism Push Pull Pull
Connection SSH, Minimal in nature Chef server, chef client Server & client
Language Python , Simple YAML structure Ruby, ERB & JSON Ruby
Learning Curve Low Learning High Learning High Learning

 

Use Ansible to configure 4Linux (ubuntu-based web servers to install nginx)

How Ansible works

For example, consider hosts as webserver 1, 2, 3, and 4.  Ansible uses inventory file (a list of nodes) to establish communication.

# /etc/ansible/hosts

[webservers]

webserver1.hostname.com

webserver2.hostmame.com

webserver3.hosname.com

webserver4.hostname.com

Below are the tasks we are going to perform:

  • Install nginx
  • Generate nginx configuration file
  • Start the nginx service

Let us name the playbook, webserver.yml, and execute the below command.

Webserver.xml

---

- hosts: webservers

tasks:

- name: Installs nginx web server

apt: pkg=nginx state=installed update_cache=true

notify:

             - start nginx

 

# ansible-playbook webservers.yml

Once the above command is executed, Ansible makes ssh connection parallely with all the nodes and performs nginx web configuration tasks.

 

Ansible Execution Flow

 

]]>
http://www.easywaytech.com/blog/index.php/2016/11/21/ansible/feed/ 0
Continuous Integration and Continuous Delivery (CICD) http://www.easywaytech.com/blog/index.php/2016/06/15/continuous-integration-and-continuous-delivery-cicd/ http://www.easywaytech.com/blog/index.php/2016/06/15/continuous-integration-and-continuous-delivery-cicd/#comments Wed, 15 Jun 2016 08:56:44 +0000 http://www.easywaytech.com/blog/?p=8 Sometimes we consider a change so small that it can’t possibly break an app; so we don’t run any tests. One fine day, the product stops functioning and nobody knows why. To avoid this scenario, we thought of automating testing and deployment, which are two main integral parts of web deployment using a solution called Continuous Integration and Continuous Delivery (CICD).

  • Continuous Integration deals with testing each change done to the codebase automatically and as early as possible
    Principles of CI:
    · Automate the Build
    · Keep Build fast
    · Automate testing of each Build
    · Everyone can see what’s happening
  • Continuous Deployment follows the testing that happens during Continuous Integration and pushes changes to a staging or development system
    Principles of CD:
    · Automate the Deployment
    · Validating on production-like environments

As part of this, we integrated Jenkins (an open source tool) with GitHub to test every time the changes in the code are pushed to the source repository and following this, push the code to the app server automatically without any human intervention.

Advantages of implementing CICD:

  • Running all tests immediately for every change by which we know right away if something broke
  • Sending notifications for every success/failure of a job. Notification can be sent through emails or any kind of reporting/communication tools like Jira, Slack, Hipchat, etc.
  • Developers can focus more on writing the code and less on monitoring the server

The goal of CICD is to get, the new features and fixes included in the code, to the users as soon as possible.
Continuous delivery is generally recommended for development and staging environments.

Flow Diagram of CICD:

Jenkinsflow.png

]]> http://www.easywaytech.com/blog/index.php/2016/06/15/continuous-integration-and-continuous-delivery-cicd/feed/ 3