I wrote an ansible module is bash. It is working fine, but if want to pass arguments to that module and read them in the bash module how can I do that .. please help
- name: get top processes consuming high cpu
gettopprocesses:
numberofprocesses: 5
In library I have bash script library/gettopprocesses.sh
#!/bin/bash
TPCPU=$(ps aux --sort -%cpu | head -${numberofprocesses}
echo "{\"changed\": false, "\msg\": {"$TPCPU"}}"
exit 0
I write your bask like this: you have to add source $1 to specify you have args
You could add a test to check if right arg is given: