Skip to content

Commit

Permalink
add example of extending ansible_facts (#2040) (#2058)
Browse files Browse the repository at this point in the history
* 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 d693f43)

Co-authored-by: Sandra McCann <samccann@redhat.com>
  • Loading branch information
patchback[bot] and samccann authored Oct 24, 2024
1 parent b007fce commit 9a825c7
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions docs/docsite/rst/dev_guide/developing_modules_general.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 9a825c7

Please sign in to comment.