Ansible is one of the most popular open-source software provisioning, configuration management and application-deployment tool enabling infrastructure as code. Ansible is mainly used as a DevOps tool and can perform a lot of tasks that otherwise are time-consuming, complex, repetitive, and can make a lot of errors or issues.
Let's write a simple ansible playbook which enables us to install few of the utility tools which are required by a System Administrator to troubleshoot a system. Let's say we have to install this tools in 10, 100 or even 1000 servers. With the help of this tiny powerful playbook anyone can install those required tools in a minute to thousand servers.
Assuming that, we have an ansible controller server and we have passwordless access to destination servers by doing ssh-copy-id. Additionally, we have an inventory file e.g. inventory.ini where we listed all destination servers IP or hostname in a group like below:
[blablabla]
10.10.10.20
10.10.10.21
10.10.10.22
10.10.10.50
10.10.10.51
Here is the playbook named required-packages.yaml
- hosts: blablabla
tasks:
- name : Installing net-tools service
yum :
name : net-tools
state : present
- name : Installing telnet service
yum :
name : telnet
state : present
- name : Installing iostat service
yum :
name : sysstat
state : present
- name : Installing dstat service
yum :
name : dstat
state : present
- name : Installing curl service
yum :
name : curl
state : present
---
No comments:
Post a Comment