The lab below simulates how to check a Linux server with Ansible.
![](https://tungle.ca/wp-content/uploads/2022/01/image-460.png)
Install Ansible on Linuxmint.
sudo apt install ansible
![](https://tungle.ca/wp-content/uploads/2022/01/image-450.png)
Set a password root for Linuxmint.
sudo passwd root
Install a new Debian Linux Server to test.
![](https://tungle.ca/wp-content/uploads/2022/01/1-4.png)
![](https://tungle.ca/wp-content/uploads/2022/01/2-3.png)
![](https://tungle.ca/wp-content/uploads/2022/01/image-451.png)
Install sshd service on Linuxmint.
sudo apt install ssh
![](https://tungle.ca/wp-content/uploads/2022/01/image-461.png)
Modify /etc/hosts.
![](https://tungle.ca/wp-content/uploads/2022/01/image-452.png)
Create a hosts file under /etc/ansible directory.
![](https://tungle.ca/wp-content/uploads/2022/01/image-453.png)
Create a new group_vars directory under /etc/ansible.
sudo mkdir group_vars
cd /etc/ansible/group_vars
Create a new tunglamp file.
![](https://tungle.ca/wp-content/uploads/2022/01/image-454.png)
Try to run a command and it fails.
ansible -m ping all -vvv
![](https://tungle.ca/wp-content/uploads/2022/01/image-455.png)
We need to setup Public key authentication on LinuxMint.
ssh-keygen -b 4096
![](https://tungle.ca/wp-content/uploads/2022/01/image-456.png)
Copy the key to the Debian server that you want to access.
ssh-copy-id root@192.168.5.27
![](https://tungle.ca/wp-content/uploads/2022/01/image-457.png)
Run the command below to make sure you can access to Debian server without a password.
ssh root@192.168.5.27
![](https://tungle.ca/wp-content/uploads/2022/01/image-458.png)
Check Debian server via Ansible.
ansible -m ping tunglamp
ansible -m shell -a 'free -m' tunglamp
ansible -m shell -s 'ifconfig -a | grep inet' tunglamp
![](https://tungle.ca/wp-content/uploads/2022/01/image-459-1024x906.png)