Writing modules in Bash is a great topic for ansible-devel. FWIW, it's as easy as "source $1" inside your bash module, reading the key=value arguments into bash variables.
Then you just need to emit key=value pairs one per line, or JSON, as you choose from your bash module. But yes, ansible-devel please! On Tue, May 20, 2014 at 2:07 PM, 'Petros Moisiadis' via Ansible Project < [email protected]> wrote: > On 05/20/14 15:10, Uri Miller wrote: > > 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 > > > -- > You received this message because you are subscribed to the Google Groups > "Ansible Project" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To post to this group, send email to [email protected]. > To view this discussion on the web visit > https://groups.google.com/d/msgid/ansible-project/50d9fe69-8286-4292-aada-09a437dba39f%40googlegroups.com<https://groups.google.com/d/msgid/ansible-project/50d9fe69-8286-4292-aada-09a437dba39f%40googlegroups.com?utm_medium=email&utm_source=footer> > . > For more options, visit https://groups.google.com/d/optout. > > > Ansible creates a file for you that holds the arguments passed to the > module. The path to this file is passed as the first argument to your > module script. So, your bash script must read and parse that file. > > -- > You received this message because you are subscribed to the Google Groups > "Ansible Project" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To post to this group, send email to [email protected]. > To view this discussion on the web visit > https://groups.google.com/d/msgid/ansible-project/537B99D4.9000309%40yahoo.gr<https://groups.google.com/d/msgid/ansible-project/537B99D4.9000309%40yahoo.gr?utm_medium=email&utm_source=footer> > . > > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "Ansible Project" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/CA%2BnsWgywy26WqWOzeNaKa2b%2B%3Dir4875o3MDj9xC%2B_8_Xyur-jA%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
