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.
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
After install dependencies, we can start deploying Ansible. Do it :
sudo apt-add-repository ppa:ansible/ansible
sudo apt-get update
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.
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.