Skip to content

Change file_switch to append source_file lookups, rather than override #151

Closed

Description

@ErisDS

To give a concrete example from nginx-formula:

 {{ files_switch([server, 'server.conf'],
                      'server_conf_file_managed'
         )
      }}

On any given host, I may have many managed server values. Therefore, it's important that it's possible to use the dynamic server filename.

If I configure nginx.tofs.source_files.server_conf_file_managed to, e.g. default.conf, I expect this to be appended to the list of files that get looked for.

However instead, nginx-formula will now only look for default.conf, removing the ability to have multiple servers per host.

My expectation is that setting server_conf_file_managed adds a cascading override - i.e. it appends to the beginning of the list of file names to look for, not overrides the full existing list.

Activity

  1. myii commented on Jul 23, 2019

    @myii
    Contributor

    Thanks @ErisDS. Note for others, this issue was discussed in Slack. I put forward a potential solution (appending the original source_files rather than overriding it) which is working for us both:

      {#- Lookup source_files (v2), files (v1), or fallback to an empty list #}
      {%- set src_files = salt['config.get'](
          tplroot ~ ':tofs:source_files:' ~ lookup,
          salt['config.get'](
              tplroot ~ ':tofs:files:' ~ lookup,
              []
          )
      ) %}
      {#- Append source_files #}
      {%- set src_files = src_files + source_files %}

    I'll put that in a PR soon, so that it can be discussed further.

  2. added 4 commits that reference this issue on Jul 23, 2019
    b778901
    88ecbbe
    cb1f1bf
    3483e76
  3. saltstack-formulas-travis commented on Jul 25, 2019

    @saltstack-formulas-travis

    🎉 This issue has been resolved in version 3.1.1 🎉

    The release is available on GitHub release

    Your semantic-release bot 📦🚀

  4. added a commit that references this issue on Aug 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions