Accessing cached facts from custom module

28 views
Skip to first unread message

Zeek3000

unread,
Oct 15, 2020, 3:17:40 AM10/15/20
to Ansible Development
Hello,

I'm trying to access facts that are cached in AWX from within my custom network module, preferably without having to make an API call. I need to check if an element already exists in the fact cache so that it doesn't get overwritten by running the module

Is it possible to access these cached facts by using ansible_facts, and how can I make that available to my custom module? 

Thanks!

Rod Oliver

unread,
Oct 15, 2020, 3:52:59 AM10/15/20
to Zeek3000, Ansible Development
You can do this by conditionally executing your custom module on whether the custom variable (fact) that comes from your module is defined.

--
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-devel/36db0527-0eb6-40de-a76b-4a1ef2f74c35n%40googlegroups.com.

Zeek3000

unread,
Oct 20, 2020, 3:39:31 AM10/20/20
to Ansible Development
Can't do that sadly as the custom module needs to run regardless; it's just a small part of a function that I need to reference the fact cache before that particular fact gets set.

Rod Oliver

unread,
Oct 20, 2020, 6:48:18 AM10/20/20
to Zeek3000, Ansible Development
The facts in the cache are accessible as any other fact, you just don't need to set them. It's possible that I'm not really understanding the issue.

Reply all
Reply to author
Forward
0 new messages