Where can I find the list of supported attributes for the ansible saved variables?

advertisements

On Ansible you can use register: some_var in order to save information about executed task but it seems that somehow I am not able to find the list of attributes documented anywhere.

I know about some of them, but I do want a full list as I is really annoying not to have documentation.

  • changed – set to boolean true if something happened (useful to tell when a task has done something on a remote machine).
  • stderr – contains stringy output from stderr
  • stdout – contains stringy output from stdout
  • stdout_lines – contains a list of lines (i.e. stdout split on \n).

Example, how do I know if the previous task failed?


There is no comprehensive list as each module returns its own list of variables.

There are common return values, which describe what a module (should) return as a minimum.

Some modules such as shell, are kind enough to list out the return values they provide in the docs.

I agree it would be quite nice to have a comprehensive cheatsheet listing the modules and return values. As it is, we're stuck with trolling through the python code for each module.

As an example, in the case of shell (which uses command under the covers), the return values are:

module.exit_json(
    cmd      = args,
    stdout   = out.rstrip("\r\n"),
    stderr   = err.rstrip("\r\n"),
    rc       = rc,
    start    = str(startd),
    end      = str(endd),
    delta    = str(delta),
    changed  = True,
    warnings = warnings
)