Hi,
I have developed a module in BASH, and I am able to run in using external arguments given from command line:
[root@ansible ansible]# ansible ap0tv01ras02pbsw0 -m ansible_startBladeAgent -a “serverName=ap0tv01ras02pbsw0v00 platformVersion=1.0.9”
ap0tv01ras02pbsw0 | success >> {
“changed”: false,
“msg”: “Server ap0tv01ras02pbsw0v00 already running”
}
I would like to start this module without specifying the arguments in the command line, so i have set inside /etc/ansible/hosts file those variables for that specific host:
hosts:
ap0tv01ras02pbsw0 serverName=ap0tv01ras02pbsw0v00 platformVersion=1.0.9
My question is - how do I access those variables from my script?
parsing the command line vars inside my BASH script is done by:
eval $(sed -e “s/\s?([^=]+)\s?=\s?(\x22([^\x22]+)\x22|\x27([^\x27]+)\x27|(\S+))\s?/\1=‘\2’/p” $1)
and works fine.
Thanks