From 3f228b8f34cccf77fc34a0ce5c5bd34ba6287bf6 Mon Sep 17 00:00:00 2001 From: Sandra McCann Date: Thu, 24 Oct 2024 14:38:45 -0400 Subject: [PATCH] add example of extending ansible_facts (#2040) * add example of extending ansible_facts * Apply suggestions from code review Co-authored-by: Felix Fontein --------- Co-authored-by: Felix Fontein (cherry picked from commit d693f43ba7684c92c2659704b9a114953bc9ff1e) --- docs/docsite/rst/dev_guide/developing_modules_general.rst | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/docs/docsite/rst/dev_guide/developing_modules_general.rst b/docs/docsite/rst/dev_guide/developing_modules_general.rst index 44db07f92b4..8e87bbacbeb 100644 --- a/docs/docsite/rst/dev_guide/developing_modules_general.rst +++ b/docs/docsite/rst/dev_guide/developing_modules_general.rst @@ -64,6 +64,13 @@ Info and facts modules, are just like any other Ansible Module, with a few minor 5. They MUST NOT make any changes to the system. 6. They MUST document the :ref:`return fields` and :ref:`examples`. +You can add your facts into ``ansible_facts`` field of the result as follows: + +.. code-block:: python + + module.exit_json(changed=False, ansible_facts=dict(my_new_fact=value_of_fact)) + + The rest is just like creating a normal module. Verifying your module code