Repository navigation
Add a fallback value for import_yaml/json/* if the file does not exists #70521
baby-gnu
started this conversation in
Feature Requests
Replies: 5 comments
|
For now, I found a workaround {## Work arround assignment inside for loop ##}
{%- set _config = {'values': {}} %}
{%- for file in ["file1.yaml", "file2.yaml", "file3.yaml"] %}
{%- load_yaml as loaded_values %}
{%- include file ignore missing %}
{%- endload %}
{%- if loaded_values %}
{%- do _config.update({'values': salt.slsutil.merge(_config['values'], loaded_values, strategy='smart')}) %}
{%- endif %}
{%- endfor %}
{%- set config = _config['values'] %} |
0 replies
|
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. If this issue is closed prematurely, please leave a comment and we will gladly reopen the issue. |
0 replies
|
ping |
0 replies
|
Thank you for updating this issue. It is no longer marked as stale. |
0 replies
|
This feature request was moved out of the issue tracker as part of a backlog cleanup — there is no active development commitment behind it. If you intend to implement this, please leave a comment and a maintainer can convert the discussion back to an issue to track the PR. |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Description of Issue
I would like to import a list of YAML files but some of them may not exists and the process should not raise an error.
It could be greate to have an option to handle missing file, for example:
Setup
Create a simple test SLS
/srv/salt/test.sls:{% from "test.jinja" import config %} Test state: test.nop: - name: {{ config }}Create the
/srv/salt/test.jinjaCreate the files
/srv/salt/file1.yaml:Create the files
/srv/salt/file3.yaml:Steps to Reproduce Issue
Then try to show the sls:
Versions Report
All reactions