Cos'è Ansible?
Abile è uno strumento open source di fornitura di software, gestione della configurazione e distribuzione di applicazioni che abilita l'infrastruttura come codice. Funziona su molti sistemi simili a Unix e può configurare sia sistemi simili a Unix che Microsoft Windows. Include il proprio linguaggio dichiarativo per descrivere la configurazione del sistema. Ansible è stato scritto da Michael DeHaan e acquisito da Red Hat nel 2015. Ansible è senza agenti e si connette temporaneamente in remoto tramite SSH o Windows Remote Management (consentendo l'esecuzione remota di PowerShell) per svolgere le sue attività.
In altre parole puoi eseguire un comando su più server e guadagnare tempo.
Come installare Ansible nel server Ubuntu?
# Update server
sudo apt-get update
sudo apt-get upgrade -y
# Install dependences
sudo apt-get install python -y
# Install repository
sudo apt-add-repository ppa:ansible/ansible
# Install ansible
sudo apt install ansible
Code language: Bash (bash)
Come aggiungere host ad ansbile?
sudo nano /etc/ansible/hosts
/etc/ansible/hosts
[servers]
server1 ansible_host=10.20.0.2
server2 ansible_host=10.20.0.3
server3 ansible_host=10.20.0.4
[all:vars]
ansible_python_interpreter=/usr/bin/python3
Code language: JavaScript (javascript)
Come controllare i server aggiunti?
sudo ansible-inventory --list -y
Code language: PHP (php)
output
all:
children:
servers:
hosts:
server1:
ansible_host: 10.20.0.2
ansible_python_interpreter: /usr/bin/python3
server2:
ansible_host: 10.20.0.3
ansible_python_interpreter: /usr/bin/python3
server3:
ansible_host: 10.20.0.4
ansible_python_interpreter: /usr/bin/python3
ungrouped: {}
Code language: JavaScript (javascript)
Come testare la connessione ai server Ansible?
sudo ansible all -m ping -u root
output
server1 | SUCCESS => {
"changed": false,
"ping": "pong"
}
server2 | SUCCESS => {
"changed": false,
"ping": "pong"
}
server3 | SUCCESS => {
"changed": false,
"ping": "pong"
}
Code language: JavaScript (javascript)
Come eseguire un comando su tutti i server?
sudo ansible all -a "df -h" -u root
Code language: JavaScript (javascript)
Conclusione
in conclusione possiamo dire che ansible è un meraviglioso software per la gestione di più server Linux in tutto il mondo, estremamente facile e accessibile da lavorare