I was thinking about extending set_fact to be able to write the facts given as a local facts file. Something like this:
set_fact: var=value persistent_file=myvars
To create /etc/ansible/facts.d/myvars.fact as a json with the given vars.
Is this something that might be considered for core? Do you guys have opinions on semantics (separate to a different module maybe)?
Thanks
--
You received this message because you are subscribed to the Google Groups "Ansible Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-deve...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Is there a reason to keep it an action plugin and not a normal module? I'm thinking performance, is there something else?
One gotcha I just realized is local facts show up as "ansible_local.factname" to ensure they never override another fact, kind of as a safety feature.I would think it would write just the one variable to a facts.d/variable_name file, but it should probably raise an error with persistent=yes if the variable name didn't start with "ansible_local", since otherwise it would be set and referenced differently when retrieved the second time.Like so:# worksset_fact: name=ansible_local.foo value=1234 persistent=yes
On Wednesday, September 24, 2014 5:19:32 AM UTC+3, michael wrote:One gotcha I just realized is local facts show up as "ansible_local.factname" to ensure they never override another fact, kind of as a safety feature.I would think it would write just the one variable to a facts.d/variable_name file, but it should probably raise an error with persistent=yes if the variable name didn't start with "ansible_local", since otherwise it would be set and referenced differently when retrieved the second time.Like so:# worksset_fact: name=ansible_local.foo value=1234 persistent=yesThis is different than how set_fact is used now - you pass args as key=value, not as name=key value=value. I think that will also make it harder to create more complex facts:
set_fact: name=ansible_local.foo value={{ {key: value, key2:value2} }} persistent=yes # ugh
Another option, which may be a bit magic-y, is to set the facts in the ansible_local namespace if they're persistent:set_fact: myfact1=123 myfact2=asd # Will set myfact1=123, myfact2=asd