Network topology

How to Install Ansible on Debian 10 and Configure Debian Hosts for Ansible Automation – Linux Tip

Here is ansible-pc a Debian 10 machine on which we will install Ansible.

Servers 6f7c2 and 6b219 are Debian 10 machines that we will configure for Ansible Automation. I’m just going to call these authorized host servers for the purpose of this article.

We can use ansible PC to automate various tasks on Debian 6f7c2 and 6b219 servers.

Approved installation

In this section, I will show you how to install Ansible on an Ansible PC.

You can install Ansible on Debian 10 from the official Debian package repository.

First update the cache of the APT packet store with the following command:

How to Install Ansible on Debian 10 and Configure Debian Hosts for Ansible Automation – Linux Tip

Now install Ansible with the following command:

$ sudo apt installation is possible

How to Install Ansible on Debian 10 and Configure Debian Hosts for Ansible Automation – Linux Tip

To confirm the installation, press Y, then press .

How to Install Ansible on Debian 10 and Configure Debian Hosts for Ansible Automation – Linux Tip

Installation is permitted.

How to Install Ansible on Debian 10 and Configure Debian Hosts for Ansible Automation – Linux Tip

Now run the following command to see if Ansible works properly

As you can see, the available command is available and works well. Tolerance 2.7.7 is the latest version of Tolerance available in the Debian package repository at the time of writing.

How to Install Ansible on Debian 10 and Configure Debian Hosts for Ansible Automation – Linux Tip

SSH generator key

On the Debian 10 machine (ansible-pc) where you installed Ansible, you must first create an SSH key.

To generate an SSH key, follow the command below:

How to Install Ansible on Debian 10 and Configure Debian Hosts for Ansible Automation – Linux Tip

Now press .

How to Install Ansible on Debian 10 and Configure Debian Hosts for Ansible Automation – Linux Tip

The press.

How to Install Ansible on Debian 10 and Configure Debian Hosts for Ansible Automation – Linux Tip

The press.

How to Install Ansible on Debian 10 and Configure Debian Hosts for Ansible Automation – Linux Tip

An SSH key must be generated.

How to Install Ansible on Debian 10 and Configure Debian Hosts for Ansible Automation – Linux Tip

Configuring Debian machines for acceptable automation

In this section, I will show you how to configure a Debian host for acceptable automation. If you have multiple hosts that you want to automate with Ansible, repeat the same process for each host.

The SSH server package must be pre-installed on the hosts you want to configure for OS automation.

First update the cache of the APT packet store with the following command:

How to Install Ansible on Debian 10 and Configure Debian Hosts for Ansible Automation – Linux Tip

Then install the OpenSSH server with the following command:

$ sudo apt openssh server installation -y

How to Install Ansible on Debian 10 and Configure Debian Hosts for Ansible Automation – Linux Tip

In my case, the OpenSSH server package is already installed. If it is not installed in your case, it must be installed for this step.

How to Install Ansible on Debian 10 and Configure Debian Hosts for Ansible Automation – Linux Tip

Now use the following command to check if the sshd service is working:

$ state sudo systemctl sshd

As you can see, the sshd service is active (started) and turned on (automatically started when the system is started).

How to Install Ansible on Debian 10 and Configure Debian Hosts for Ansible Automation – Linux Tip

If the sshd service is not active (running), start it manually with the following command

$ sudo systemctl start sshd

How to Install Ansible on Debian 10 and Configure Debian Hosts for Ansible Automation – Linux Tip

If the sshd service is not enabled (not added at startup), add it manually at startup by executing the following command

$ sudo systemctl activates sshd

How to Install Ansible on Debian 10 and Configure Debian Hosts for Ansible Automation – Linux Tip

Now create an accessible user and give him/her access without a password.

To create an available user, follow the command below:

$ sudo adduser –shell /bin/bash –gecos ansible

How to Install Ansible on Debian 10 and Configure Debian Hosts for Ansible Automation – Linux Tip

Enter an available user password and click on .

How to Install Ansible on Debian 10 and Configure Debian Hosts for Ansible Automation – Linux Tip

Re-enter your password and press .

How to Install Ansible on Debian 10 and Configure Debian Hosts for Ansible Automation – Linux Tip

A valid user must be created.

How to Install Ansible on Debian 10 and Configure Debian Hosts for Ansible Automation – Linux Tip

To give the sudo user access without a password, edit the /etc/sudoers file with the following command :

How to Install Ansible on Debian 10 and Configure Debian Hosts for Ansible Automation – Linux Tip

Now add the following line to /etc/sudoers.

ALL=(ALL) NOPASSWD:ALL

Then save the file by pressing + X, then Y and finally .

How to Install Ansible on Debian 10 and Configure Debian Hosts for Ansible Automation – Linux Tip

Now determine the IP address of the allowed host 6f7c2 with the following command:

In my case, the IP address is 192.168.20.167. It’ll be different with you. Replace this address with your own form.

How to Install Ansible on Debian 10 and Configure Debian Hosts for Ansible Automation – Linux Tip

Copy the public SSH key to a valid host

From the computer on which you installed Ansible (ansible-pc), copy the public SSH key to the Ansible 6f7c2 host as follows

$ shh-copy [email protected]

How to Install Ansible on Debian 10 and Configure Debian Hosts for Ansible Automation – Linux Tip

Enter Yes and press .

How to Install Ansible on Debian 10 and Configure Debian Hosts for Ansible Automation – Linux Tip

Then enter an available user password and click on .

How to Install Ansible on Debian 10 and Configure Debian Hosts for Ansible Automation – Linux Tip

The public SSH key must be copied to the Ansible 6f7c2 host.

How to Install Ansible on Debian 10 and Configure Debian Hosts for Ansible Automation – Linux Tip

You should be able to send SSH to the authorized host 6f7c2 as an available user without a password, as you can see in the screenshot below

$ shh [email protected]

How to Install Ansible on Debian 10 and Configure Debian Hosts for Ansible Automation – Linux Tip

You should also be able to perform sudo commands without having to ask for a password.

How to Install Ansible on Debian 10 and Configure Debian Hosts for Ansible Automation – Linux Tip

Finally, close the SSH session as follows:

How to Install Ansible on Debian 10 and Configure Debian Hosts for Ansible Automation – Linux Tip

Protection of authorized service providers

Since a valid user can execute any sudo command without asking for a password, we have configured connections based on an SSH key for valid hosts. However, you can still login to SSH as a valid user with the valid user password. So it’s not very safe.

For added security, run the following command on authorized hosts to disable password-based login for the authorized user:

$ sudo usermod -L ansible

How to Install Ansible on Debian 10 and Configure Debian Hosts for Ansible Automation – Linux Tip

If you later decide to enable login with an authorised user password, run the following command on the authorised host

$ sudo usermod -U ansible

Approved tests

Create a new directory ~/project/ on a Debian machine on which you have installed an ansible PC with the following code

How to Install Ansible on Debian 10 and Configure Debian Hosts for Ansible Automation – Linux Tip

Go to the ~/project/ directory with the following code:

How to Install Ansible on Debian 10 and Configure Debian Hosts for Ansible Automation – Linux Tip

Create a new host file in the project folder as follows

How to Install Ansible on Debian 10 and Configure Debian Hosts for Ansible Automation – Linux Tip

Now enter the IP addresses or DNS names of the authorized hosts (in my case 6f7c2 and 6b219) in the Hosts:

192.168.20.167
192.168.20.168

Then save the file by pressing + X, then Y and finally .

How to Install Ansible on Debian 10 and Configure Debian Hosts for Ansible Automation – Linux Tip

To test, try pinging all hosts with Ansible using the following code:

acceptable -i ./hosts all -u ansible -m ping

NOTE: Here the -u option is used to specify the username (in this valid case) that Ansible will use for SSH on hosts.

How to Install Ansible on Debian 10 and Configure Debian Hosts for Ansible Automation – Linux Tip

As you can see, Ansible has access to all hosts. Okay, the hosts are ready for authorized automation.

How to Install Ansible on Debian 10 and Configure Debian Hosts for Ansible Automation – Linux Tip

To install Ansible on Debian 10 and configure Debian hosts to automate Ansible. Thank you for reading this article.install and configure ansible,ansible install application on linux,how to install ansible on redhat linux aws,red hat ansible configuration,setting up ansible,ansible setup,ansible linux,how to use ansible on linux

You May Also Like

World of Warcraft Classic: Some Players Use Illegal Tools to Stay Connected

Earlier this week, Blizzard released World of Warcraft Classic. The launch was,…

Crash Team Racing Bientt Back on Ps4!

Activision seems not to have finished with the remastering of the Playstation…

Calculation Number of Days Between Two Dates

Topic: Delphi Language charlene44 wrote: 18/08/2006 at 15h08 calculation of number of…