add example of extending ansible_facts (#2040) (#2059)

* add example of extending ansible_facts

* Apply suggestions from code review

Co-authored-by: Felix Fontein <felix@fontein.de>

---------

Co-authored-by: Felix Fontein <felix@fontein.de>
(cherry picked from commit d693f43ba7)

Co-authored-by: Sandra McCann <samccann@redhat.com>
This commit is contained in:
patchback[bot]
2024-10-24 15:34:24 -04:00
committed by GitHub
parent ececb7efa7
commit f19aeb4f2b

View File

@@ -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<return_block>` and :ref:`examples<examples_block>`.
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