news
Extended configurations in Amsterdam
DF
May 24, 2023
Updated May 24, 2023

Install Ansible on Debian

Ansible Debian

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.

Update Debian

Before installing, it is necessary to update the entire operating system. Run this:

sudo apt-get update
sudo apt-get upgrade

Install dependencies

Ansible requires some dependencies to work. To install them, enter in terminal:

sudo apt-get install software-properties-common

Install Ansible

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

Deployment check

After installation we can verify operability by insert this command:

ansible --version

If everything is installed correctly, information about the version will be displayed.

Host configuration

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.
Example file:

[web]
websrv1.localdomain
websrv2.localdomain
[database]
dbsrv1.localdomain
dbsrv2.localdomain

Ansible playbook

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
tasks:
- name: Install lighttpd
apt:
name: lighttpd
state: present
- hosts: database
tasks:
- name: Install mariadb
apt:
name: mariadb-server
state: present

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.

Running playbook

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.

Conclusion

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.

Vote:
4 out of 5
Аverage rating : 4
Rated by: 1
1101 CT Amsterdam The Netherlands, Herikerbergweg 292
+31 20 262-58-98
700 300
ITGLOBAL.COM NL
700 300

You might also like...

We use cookies to make your experience on the Serverspace better. By continuing to browse our website, you agree to our
Use of Cookies and Privacy Policy.