I'm trying to run the below ansible ad-hoc command that runs the "status.sh" script:
ansible host -m script -a '/path/status.sh' -u root -i inventory
The script simply gets the status of a service on the target host as shown below:
service_1=$(ls /etc/systemd/system | grep -e jboss | awk -F ' ' '{print $1}')
if [ ! -z "$service_1" ] //if service exists
then
systemctl status $service_1
else
echo "There is No $Service_1 Here !"
fi
I'm getting too much output when running the ad-hoc command, I just want to limit the output to stdout_lines or stdout, Is there a way to do so without creating a particular playbook with debug or any other modules just by adding an option or piping the output to a grep?