Ayrton
Posted on October 2, 2020
Hi Shellers (people who use only shell command)
Many thanks for your support in my last post :
https://dev.to/simerca/trick-merge-a-js-array-with-1-line-of-code-not-as-simple-c6a
Today I want to ask you one question.
Why you don't use Ansible ?
For the newbie, Ansible is a tool to set infrastructure with configuration file, the most efficient thing about it it's the powerfull to setup many server with one command line.
exemple:
You should deploy 1 server with a webserver configuration, and another server with a bdd configuration.
Without ansible you will connect to the ssh tunel inside each server and set the command line associated to her configuration.
BUT !
If you do deploy :
Webserver:
3 servers:
-- 1 prod
-- 1 preprod
-- 1 backup3 databases:
-- 1 prod
-- 1 preprod
-- 1 backup
You will connect to the 6 servers and set manually the configuration ?
Too repetitive...
So ..
Ansible with an Inventory can do this for you exemple
Inventory.ini
[webservers]
server1-prod
server2-preprod
server3-backup
# Should be IP or domain
[databases]
db1-prod
db2-preprod
db3-backup
# Should be IP or domain
Here is the set of all your servers ip or domain.
Now you can easy execute a command with an Ansible Playbook.
Ansible Playbook Exemple
Playbook.yml
---
- name: Ansible Playbook Exemple
host: webservers
tasks:
name: Update apt package registry
command: apt-get update
name: Install PHP
command: apt-get install php
if you launch this command:
ansible-playbook playbook.yml -i inventory.ini -v
You will Update Package Registry and install PHP on all webservers at the same time.
Awesome no ?
So go learn and code your infrastructure 💪
more docs at https://docs.ansible.com/
Posted on October 2, 2020
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.