Ser Heang Tan wrote:
> Hi JP,
> Yes, I know about these few variables from your sample shell script module
> :)
> But I am actually looking for a complete list of JSON returned variable,
> and the meaning of them.
You can return whatever data you want. There are really very few that have
any special meaning, everything else is up to the module to define and the
user to use. The special ones are:
- failed=True, indicating that the action failed
- skipped=True, indicating a pre-condition for running the task was already
met
- changed=True/False, indicating the task changed/didn't change something,
used to trigger notifiers and coloring of the output.
- ansible_facts=<dict>, containing custom facts that will be usable as
variables in following tasks
- stdout=<str>, containing text output. Will be split into lines that can be
used if register'd
- msg, used for e.g. failure messages
Daniel
> Thank you.
>
> On Tuesday, December 18, 2012 2:24:01 PM UTC+8, JP Mens wrote:
>>
>> > I am not sure whether there is any document on writing BASH/SH module
>> in
>> > ansible, but I did found a few example. But I would like to know what
>> is
>> > return value for JSON
>>
>> You should be able to get by, either by printing JSON to stdout, or
>> doing something like this:
>>
>> ----8<-------8<-------8<-------8<-------8<-------8<-------8<---
>> #!/bin/sh
>>
>> # do something clever
>>
>> echo "ok=true changed=true name='John Doe'"
>> ----8<-------8<-------8<-------8<-------8<-------8<-------8<---
>>
>>
>> ansible server -m jp1
>> server | success >> {
>> "changed": true,
>> "name": "John Doe",
>> "ok": true
>> }
>>
>>
>> > Also, is there some function header like the initscript "functions"
>> that I
>> > can reuse for the BASH/SH module?
>>
>> I don't think that exists.
>>
>> -JP
>>
>
> --
>
>
>