Storing facts on remote hosts

Hello, Ansible users!

I am trying to make a group of variables persistent on hosts, preferably as a text file.
I was using puppet+facter before and now I’m looking for a native way to accomplish this with ansible.

My task:

  1. Facts are being initialised only once, when host is provisioned
  2. Facts are stored as a text file on remote host and are reusable from any other scripts on that host
  3. Facts are automatically read into ansible vars from file once ansible connects to a host

At this moment I’ve tried following:

  • include_vars’ works only with local file

  • set_fact’ facts are not persistent

  • fact caching saves facts on local machine

  • facter’ module cannot store facts on host, it can only retrieve existing

It looks like that my task can be accomplished with a custom inventory script, but before I spend a week on this, I’m asking here.

Thanks!

/etc/ansible/facts.d on the target nodes might be what you are looking for.

See http://docs.ansible.com/ansible/playbooks_variables.html#local-facts-facts-d