Bash modules in Ansible are no different to any other bash scripts, except in the way that they print the data on stdout. Bash modules can be as straightforward as checking whether a process is running on the remote host, to running some more complex commands.
As previously stated, the general recommendation is to use Python for modules. In my opinion, the second-best choice (only for very easy modules) is the bash module, due to its simplicity and user base.
Let's create a library/kill_java.sh file with the following content:
#!/bin/bash source $1 SERVICE=$service_name JAVA_PIDS=$(/usr/java/default/bin/jps | grep ${SERVICE} | awk '{print $1}') if [ ${JAVA_PIDS} ]; then for JAVA_PID in ${JAVA_PIDS}; do /usr/bin/kill -9 ${JAVA_PID} done echo "failed=False msg=\"Killed all the orphaned processes for $...