The lab below simulates how to check a Linux server with Ansible.
Install Ansible on Linuxmint.
sudo apt install ansible
Set a password root for Linuxmint.
sudo passwd root
Install a new Debian Linux Server to test.
Install sshd service on Linuxmint.
sudo apt install ssh
Modify /etc/hosts.
Create a hosts file under /etc/ansible directory.
Create a new group_vars directory under /etc/ansible.
sudo mkdir group_vars
cd /etc/ansible/group_vars
Create a new tunglamp file.
Try to run a command and it fails.
ansible -m ping all -vvv
We need to setup Public key authentication on LinuxMint.
ssh-keygen -b 4096
Copy the key to the Debian server that you want to access.
ssh-copy-id root@192.168.5.27
Run the command below to make sure you can access to Debian server without a password.
ssh root@192.168.5.27
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