How to check inventory file contents?

You can check the contents of your Ansible inventory file using the grep command in the terminal. Here’s a simple script that verifies if the inventory file contains specific groups:

#!/bin/zsh
grep -q "\[local\]" /etc/ansible/hosts && grep -q "\[webservers\]" /etc/ansible/hosts

This script checks for the presence of the [local] and [webservers] groups in the inventory file located at /etc/ansible/hosts. If both groups are found, the command will succeed silently.

Make sure to replace the path with the correct location of your inventory file if it's different.

0 Comments

no data
Be the first to share your comment!