Hello
I have a use case where I want to create a user in a postgres database
only if it does not exist. A separate module could be written for
this but I think a general solution for this kind of situation makes
sense.
My suggestion is to have a way to assign stdout to a variable to be
used later on in the playbook. I think this could be added to command.
As a very simple example (even though this is covered by facts/ohai).
command uname -i stdout_var=architecture
So architecture can be used as var later on in the templates/
conditionals.
This seems pretty trivial to implement, but does require a change to
the runner code. I have made a quick hack attempt but it seems that
currently the way to do this is to add these variables to setup_cache,
which is badly named, and the comments say it is going away anyway.
I would suggest that having a way for any module to add vars would be
useful. So adding an optional
"extra_vars" : {"var1" : "value", ...}
to any module result json/dict could make sense. This would mean that
ohai/factor could use this and would not be a special case anymore.
I am happy to work on this and give you a patch, but want to make sure
that you also think this kind of feature is valuable.
Thanks
David