Select Page

Automate Your Environment with Ansible

Author: Venkata Vijay | | July 9, 2019

Are you looking to reduce manual work and improve the reliability of your IT environment? Then an automation tool like Ansible may be the answer. Learn how you can eliminate repetitive tasks with this open-source automation engine.

Features of Ansible:

It is an agentless, secure, provisioning and deployment tool that is easy to start, data-driven, and idempotent.

Agentless: Ansible uses an open sshd and WinRM protocol to automate your environment. No additional agents need to be installed and firewall ports need to open. It is very secure to use.

Provisioning and Deployment: From the management node you can provision and deploy to the remote nodes. There are two things that will play a major role on ansible:

1) Playbooks
2) Host inventory file

We have developed a playbook on the management node and can execute that playbook to perform deployments in the remote nodes.

In the Host inventory file, you need to define the remote nodes and then need to execute the playbooks. These playbooks are very easy to use.

Data-driven: Whatever the information you keep in the playbook is used to perform the deployment.

Idempotent: Retains the state of affairs going on the remote node.

For example: if there are 5 steps needed to be executed in the remote node and for some reason Ansible fails at step 3; if you re-run it again it will leave the previous 3 steps and execute from steps 4 & 5 which will save some time.

For one of our clients, we used Ansible to do patching and package installation. This helped them save a lot of manual effort. With the help of below YAML script, we can automate the patching activity for X no. of hosts which can save a huge amount of manual effort.

The below script will collect all the system required information with pre and post checks and once the patching completes it will automatically reboot the host with the updated patch and the latest version of the kernel as per the client requirement.

We can easily modify the script to suit any requirement.

YAML  Script

- hosts: all
gather_facts: true
remote_user: support
become: true
become_method: sudo


- name: Pre_Reboot Output
shell: df -Th | grep ^/dev ; route -n ; fdisk  -l | grep ^/dev ; uname -a ; uptime
register: prereboot
- debug: msg={{prereboot.stdout_lines}}

- name: Update OS Packages
update_cache: yes
name: "*"
state: latest
exclude: mysql, mariadb

- name: List Of Installed|Updated Packages
shell: rpm -qa --last | grep "$(date +%a\ %d\ %b\ %Y)" |cut -f 1 -d " "
register: package
- debug: msg="{{package.stdout_lines}}"

- name: Reboot the Server Post Patching
reboot_timeout: 500
test_command: uptime

- name: Wait For the Server To Come UP
connect_timeout: 120
timeout: 250

- name: Post_Reboot Output
shell: uname -a ; uptime
register: postreboot
- debug: msg={{postreboot.stdout_lines}}

How to automate your Environment with Datavail

Need help getting started with Ansible? We have a team of experts who can provide 24×7 support. First, we will run an assessment of your existing environment and provide a plan of action as to how automation can help you reduce manual work and improve the reliability of your IT environment.

Contact us today to learn more.

Risks of Running Unsupported Windows 2008

Microsoft discontinues support for Windows Server 2008 on January 14, 2020. There are things you can do to prepare.

Pete Young | October 23, 2019

Datavail’s Service Delivery Management Process

The role of a service delivery team is to provide a critical link between the external customer environment and the internal operations of the organization.

Shiv Devrajan | September 11, 2019

What Makes Datavail’s Service Delivery Model Unique?

A well-designed service delivery model is crucial in IT operations and management. What makes ours robust and unique?

Shiv Devrajan | August 26, 2019

Subscribe to Our Blog

Never miss a post! Stay up to date with the latest database, application and analytics tips and news. Delivered in a handy bi-weekly update straight to your inbox. You can unsubscribe at any time.

Work with Us

Let’s have a conversation about what you need to succeed and how we can help get you there.


Work for Us

Where do you want to take your career? Explore exciting opportunities to join our team.