Ansible is a highly efficient automation tool designed for managing multiple hosts at once, as well as for managing config, application deployment, and other tasks. Within this manual, we will take look on process of deploying Ansible on Debian operating system and start using it for automation. Why it needed? If we have hundreds or even thousands servers, confugure each of them individually will take catastrophically long time.
Ansible can automate such task:
- Installation and configuration of software on servers
- Configuration of network devices
- Deployment of virtual machines
- Management of Docker containers
- Monitoring and logging of the system
- And many other tasks.
Before installing, it is necessary to update the entire operating system. Run this:
sudo apt-get update
sudo apt-get upgrade
Ansible requires some dependencies to work. To install them, enter in terminal:
sudo apt-get install software-properties-common
Also Ansible require Python to be installed and him packages will be installed.
After install dependencies, we can start deploying Ansible. Do it :
sudo apt-get install ansible
After installation we can verify operability by insert this command:
If everything is installed correctly, information about the version will be displayed.
To start using automation directly, it is necessary to configure servers where the tasks will run. To do this, make a file for inventory purposes and list the hosts in it.
Playbook — file containing tasks that will be executed on the required nodes. Make playbook.yml file and append the following to the file:
- hosts: web
- name: Install lighttpd
- hosts: database
- name: Install mariadb
With such playbook, the web server lighttp and the database application MariaDB will be applied to all servers in the web and database groups, respectively.
In order to execute the playbook, insert this:
ansible-playbook -i inventory playbook.yml
The tasks stated in the playbook will be performed on every host that is specified in the inventory file.
Check Ansible working
To verify that deployment successfully apply, logon on servers in playbook by ssh and check that software from playbook is installed.
Ansible is a robust automation solution that empowers you to oversee and administer numerous servers concurrently. Installing Ansible on Debian is easy and takes only a few steps. After installation, it is necessary to configure the hosts and create a playbook to describe the tasks to be executed on these hosts. Ansible can be used for automating various tasks, making server administration much easier.