Skip to content

Commit

Permalink
Directly reference filters (#125)
Browse files Browse the repository at this point in the history
* Directly reference filters.

* Add more references.
  • Loading branch information
felixfontein authored Nov 26, 2022
1 parent 8442c98 commit a3fd029
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 2 deletions.
4 changes: 2 additions & 2 deletions docs/docsite/rst/guide.rst
Original file line number Diff line number Diff line change
Expand Up @@ -214,9 +214,9 @@ The ``empty_on_not_exist=true`` flag is needed to avoid the lookup to fail when
Working with encrypted data from other sources
----------------------------------------------

You can use the ``community.sops.decrypt`` Jinja2 filter plugin to decrypt arbitrary data. This can be data read earlier from a file, returned from an action, or obtained through some other means.
You can use the :ref:`community.sops.decrypt Jinja2 filter <ansible_collections.community.sops.decrypt_filter>` to decrypt arbitrary data. This can be data read earlier from a file, returned from an action, or obtained through some other means.

For example, assume that you want to decrypt a file retrieved from a HTTPS server with the `ansible.builtin.uri module <ansible_collections.ansible.builtin.uri_module>`_. To use the ``community.sops.sops`` lookup, you have to write it to a file first. With the filter, you can directly decrypt it:
For example, assume that you want to decrypt a file retrieved from a HTTPS server with the `ansible.builtin.uri module <ansible_collections.ansible.builtin.uri_module>`_. To use the :ref:`community.sops.sops lookup <ansible_collections.community.sops.sops_lookup>`, you have to write it to a file first. With the filter, you can directly decrypt it:

.. code-block:: yaml+jinja

Expand Down
6 changes: 6 additions & 0 deletions plugins/filter/decrypt.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,12 @@
default: true
extends_documentation_fragment:
- community.sops.sops
seealso:
- plugin: community.sops.sops
plugin_type: lookup
- plugin: community.sops.sops
plugin_type: vars
- module: community.sops.load_vars
'''

EXAMPLES = '''
Expand Down
10 changes: 10 additions & 0 deletions plugins/lookup/sops.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,16 @@
- community.sops.sops.ansible_ini
notes:
- This lookup does not understand 'globbing' - use the fileglob lookup instead.
seealso:
- ref: community.sops.decrypt filter <ansible_collections.community.sops.decrypt_filter>
description: The decrypt filter can be used to descrypt sops-encrypted in-memory data.
# - plugin: community.sops.decrypt
# plugin_type: filter
- ref: community.sops.sops vars plugin <ansible_collections.community.sops.sops_vars>
description: The sops vars plugin can be used to load sops-encrypted host or group variables.
# - plugin: community.sops.sops
# plugin_type: vars
- module: community.sops.load_vars
"""

EXAMPLES = """
Expand Down
12 changes: 12 additions & 0 deletions plugins/modules/load_vars.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,18 @@
- module: ansible.builtin.include_vars
- ref: playbooks_delegation
description: More information related to task delegation.
- ref: community.sops.sops lookup <ansible_collections.community.sops.sops_lookup>
description: The sops lookup can be used decrypt sops-encrypted files.
# - plugin: community.sops.sops
# plugin_type: lookup
- ref: community.sops.decrypt filter <ansible_collections.community.sops.decrypt_filter>
description: The decrypt filter can be used to descrypt sops-encrypted in-memory data.
# - plugin: community.sops.decrypt
# plugin_type: filter
- ref: community.sops.sops vars plugin <ansible_collections.community.sops.sops_vars>
description: The sops vars plugin can be used to load sops-encrypted host or group variables.
# - plugin: community.sops.sops
# plugin_type: vars
'''

EXAMPLES = r'''
Expand Down
2 changes: 2 additions & 0 deletions plugins/modules/sops_encrypt.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@
seealso:
- ref: community.sops.sops lookup <ansible_collections.community.sops.sops_lookup>
description: The sops lookup can be used decrypt sops-encrypted files.
# - plugin: community.sops.sops
# plugin_type: lookup
'''

EXAMPLES = r'''
Expand Down
10 changes: 10 additions & 0 deletions plugins/vars/sops.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,16 @@
- community.sops.sops
- community.sops.sops.ansible_env
- community.sops.sops.ansible_ini
seealso:
- ref: community.sops.sops lookup <ansible_collections.community.sops.sops_lookup>
description: The sops lookup can be used decrypt sops-encrypted files.
# - plugin: community.sops.sops
# plugin_type: lookup
- ref: community.sops.decrypt filter <ansible_collections.community.sops.decrypt_filter>
description: The decrypt filter can be used to descrypt sops-encrypted in-memory data.
# - plugin: community.sops.decrypt
# plugin_type: filter
- module: community.sops.load_vars
'''

import os
Expand Down

0 comments on commit a3fd029

Please sign in to comment.