News
Seven days of Black Friday madness — great deal from Serverspace!

THE NEW YEAR
WHEEL OF FORTUNE

Spin the wheel and win a guaranteed prize right now!

By registering, you are signing up to receiving emails.
DF
May 24 2023
Updated June 3 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. 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.

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

Also Ansible require Python to be installed and him packages will be installed.

Install Ansible

After install dependencies, we can start deploying Ansible. Do it :

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.

 

Check Ansible working

To verify that deployment successfully apply, logon on servers in playbook by ssh and check that software from playbook is installed.

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: 3
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.