Ansible is a DevOps tool, used for managing servers. Ansible allow you to manage multiple servers easily. With ansible playbook, you can automate complex server administration and deployment tasks.
To install Ansible on Ubuntu, run
sudo apt-get install ansible
We need to create a file with name “hosts”, that list all our servers. We can group them under differnt category, for example, webservers, dbservers, etc.. so we can manage them easily.
Here is my hosts file
boby@hon-pc-01:~/www/ansible $ cat hosts [cpanelservers] [email protected]:3333 [email protected]:3333 boby@hon-pc-01:~/www/ansible $
You can specify user and port in the server list. Or you can specify it in ansible.cfg
Now, lets run
boby@hon-pc-01:~/www/ansible $ ansible -i hosts cpanelservers -a "uptime" [email protected] | success | rc=0 >> 17:47:55 up 1:51, 1 user, load average: 0.46, 0.44, 0.49 [email protected] | success | rc=0 >> 17:49:05 up 94 days, 10:02, 1 user, load average: 2.47, 2.42, 2.11 boby@hon-pc-01:~/www/ansible $
Ansible run the command “uptime” on all servers listed in cpanelservers group and print out the result.
This is very basic usage of ansible. You can use Ansible playbook for complex software installation/management tasks.