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/
Top comments (13)
It depends on your use case, sometimes a bash script is much easier. I messed with saltstack and ansible once, and I spent more time learning and debugging those tools than real development. Not worth it.
If you can have absolute control over your infrastructure then for me bashscript is enough.
Right now I use terraform for hardware orchestration and bashscript to setup my environment. Docker is also an option but I fear that will add another complexity to the code.
Thank for your feedback !
I'm really ok with you for the first point but i think "Learning and debugging tools" it's on testing stage of a deployment, when you make for launch on production you will do the trick with the lasts good testing.
For me Terraform is better for hardware orchestration, like you, BUT you wrong when you say Docker add another complexity, it's totaly wrong because Docker make easy deployment on any server , new or old. Just take a look at this article, but Learning it's essential.
dev.to/akanksha_9560/docker-for-fr...
Thank you for your feedback again !
I'm quite hesitant to use the word wrong :) in any situation. Each person has his or her own circumstances. That said, adding any tool to your stack will always introduce some level of complexity. One has to learn docker, learn how to configure it properly, then how to monitor it and keep it always up.
There are use cases for docker, but it's not an absolute need for all cases.
Sorry, i dont want to be agressive, my english is very bad and i don't know what words i should do used.
In our work team operational is the keyword.
So the learning of new technologies is a requirement to evolve and stay operational.
What i want to say is just : if you upgrade your skills you take off complexity from your projects
Exactly. If new technologies take off the complexity. When you adapt docker you suddenly have to worry about new security and network connectivity issues:
networkcomputing.com/cloud-infrast...
sysdig.com/blog/7-docker-security-...
It's not a one line command you set it up and forget about it. And then you need to now look at way to maintain your fleet (swarm vs k8). Is this worthy? It depends. But every team has a finite amount of resources. We need to invest wisely, right things at the right time. At certain point when docker becomes a must for me, you bet I will learn it. Not now.
Yeah, but ultimately containers and orchestrator done right is much better approach in a long run, although it involves some complexity.
You are absolutely right. But it's like saying electric cars are the ultimate vehicles for everyone. Perhaps I only need a skateboard? Not a very good example but I hope you get my point :).
I believe that we should embrace new technologies with care. If a team wants to move to docker, they should learn to set it up properly first. It's very easy to get started with Docker, just a few commands. But to really set it up properly and manage it, we need to spend a significant amount of time (and we should). Until we can really invest the effort, we should not just blindly do it.
Same for Ansible, it's a great tool, but it's not the right solution for every situation. The reason we use tools is to save time and cost. If the specific tool cannot save either then we should consider something else.
Our devops team uses a mix of ansible, terraform and puppet. They each have pros and cons in terms of running on host vs target machine and suited to managing AWS infrastructure or just updating packages on machines.
I forget the tradeoffs but Ansible came out as relatively light and easy for managing packages on a few servers without needing Ansible installed on the servers so i went with Ansible for home use.
However I find Ansible not intuitive to use. The Ansible way of doing things was confusing to learn and get right. Roles especially were too magical and I couldn't reason what they were doing when I could use some apt commands that are easy to run by hand on terminal. For only one machine.
I have setup iTerm on macOS so that I can SSH too many machines at once in split screens and run a command on all at the exact same time and this doesn't require Ansible.
I made a repo with my exploration in Ansible. I put all the install and run commands there including using sudo and ansible galaxy.
github.com/MichaelCurrin/ansible-p...
I don't know if Ansible has a preview but Terraform has a plan command which tells you want resources (such as servers) it will update and create and destroy before you actually apply it so it is nice for managing cloud infrastructure transparently. I don't know how well it handles package management or processes on a server
PS I recommend to use a spell checker to pick up your words to be fixed like powerfull and exemple
And the title could be phrased more naturally as "Why not use Ansible?" Or if you actually want a response then "Tell me why you don't use Ansible" or "Why don't you use Ansible"
Thank you for your complete feedback !
Ansible has an UI tool for view all of you want but , i'm alright with you when you say
Terraform is better for manage cloud infrastructure.
I want to know more about you iTerm config to tap multiple command line ?!
Thank you for feedback too about my spelling skills
Thanks. The UI tool I found looks like a job runner similar to Jenkins which we use for work Ansible playbooks
github.com/node-ci/nci-ansible-ui
I've been working on a Terraform guide if you are interested.
michaelcurrin.github.io/dev-cheats...
Here is my iTerm guide :)
github.com/MichaelCurrin/code-cook...
Dont forget to say me, why you don't use Ansible π½
I used fabric over ansible because. The orchestation only will be one time. Then a lot of deployments will be executed
I use Sparrow for an automation and configuration management where it's possible. I find that declarative style tools like ansible lack of flexibility and hard to maintain.