-
Notifications
You must be signed in to change notification settings - Fork 25
Allow to load vars with expressions evaluated lazily #229
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
|
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #229 +/- ##
==========================================
- Coverage 83.80% 83.80% -0.01%
==========================================
Files 12 12
Lines 735 747 +12
Branches 143 150 +7
==========================================
+ Hits 616 626 +10
- Misses 84 85 +1
- Partials 35 36 +1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Docs Build 📝Thank you for contribution!✨ The docs for this PR have been published here: You can compare to the docs for the The docsite for this PR is also available for download as an artifact from this run: File changes: Click to see the diff comparison.NOTE: only file modifications are shown here. New and deleted files are excluded. diff --git a/home/runner/work/community.sops/community.sops/docsbuild/base/load_vars_module.html b/home/runner/work/community.sops/community.sops/docsbuild/head/load_vars_module.html
index ba62a41..3cae551 100644
--- a/home/runner/work/community.sops/community.sops/docsbuild/base/load_vars_module.html
+++ b/home/runner/work/community.sops/community.sops/docsbuild/head/load_vars_module.html
@@ -277,11 +277,12 @@ see <a class="reference internal" href="#ansible-collections-community-sops-load
<td><div class="ansible-option-cell"><p>This option controls how Jinja2 expressions in values in the loaded file are handled.</p>
<p>If set to <code class="ansible-value docutils literal notranslate"><span class="pre">ignore</span></code>, expressions will not be evaluated, but treated as regular strings.</p>
<p>If set to <code class="ansible-value docutils literal notranslate"><span class="pre">evaluate-on-load</span></code>, expressions will be evaluated on execution of this module, in other words, when the file is loaded.</p>
-<p>Unfortunately, there is no way for non-core modules to handle expressions “unsafe”, in other words, evaluate them only on use. This can only achieved by <a class="reference external" href="https://docs.ansible.com/ansible/devel/collections/ansible/builtin/include_vars_module.html#ansible-collections-ansible-builtin-include-vars-module" title="(in Ansible vdevel)"><span class="xref std std-ref">ansible.builtin.include_vars</span></a>, which unfortunately cannot handle SOPS-encrypted files.</p>
+<p>If set to <code class="ansible-value docutils literal notranslate"><span class="pre">lazy-evaluation</span></code>, expressions will be lazily evaluated. This requires ansible-core 2.19 or newer and is the same behavior than <a class="reference external" href="https://docs.ansible.com/ansible/devel/collections/ansible/builtin/include_vars_module.html#ansible-collections-ansible-builtin-include-vars-module" title="(in Ansible vdevel)"><span class="xref std std-ref">ansible.builtin.include_vars</span></a>. <code class="ansible-value docutils literal notranslate"><span class="pre">lazy-evaluation</span></code> has been added in community.sops 2.1.0.</p>
<p class="ansible-option-line"><strong class="ansible-option-choices">Choices:</strong></p>
<ul class="simple">
<li><p><code class="ansible-option-default-bold docutils literal notranslate"><strong><span class="pre">"ignore"</span></strong></code> <span class="ansible-option-choices-default-mark">← (default)</span></p></li>
<li><p><code class="ansible-option-choices-entry docutils literal notranslate"><span class="pre">"evaluate-on-load"</span></code></p></li>
+<li><p><code class="ansible-option-choices-entry docutils literal notranslate"><span class="pre">"lazy-evaluation"</span></code></p></li>
</ul>
</div></td>
</tr>
|
51042a9
to
9d0075f
Compare
I think this is ready, but I don't want to merge this before ansible-core 2.19 rc1 is out. |
With Data Tagging, this is finally possible for community.sops.load_vars.
Unfortunately, the DT PR also deprecates top-level facts, so every time you use anything loaded by community.sops.load_vars, you get a big fat deprecation warning 😭(This has been pushed to ansible-core 2.20.)I hope it's possible to either add an API so that action plugins can finally set variables, or move the deprecation to a later ansible-core version until such an API exists.
(This PR currently contains #225.)