Skip to content
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

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

Closed
ErisDS opened this issue Jul 23, 2019 · 2 comments · Fixed by #152
Closed

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

ErisDS opened this issue Jul 23, 2019 · 2 comments · Fixed by #152
Labels

Comments

@ErisDS
Copy link

ErisDS commented Jul 23, 2019

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.

@myii
Copy link
Member

myii commented Jul 23, 2019

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.

ErisDS added a commit to TryGhost/nginx-formula that referenced this issue Jul 23, 2019
myii added a commit to myii/template-formula that referenced this issue Jul 23, 2019
* saltstack-formulas/nginx-formula#247 (comment)
  - The main issue is that the `nginx-formula` has dynamic values being
    used by as the default `source_files` -- there is no way to provide
    this from the pillar/config in a sensible fashion
  - Prepending to this default (rather than overriding it) resolves this
    problem entirely, without adding excessive entries to the `source`
* Closes saltstack-formulas#151
myii added a commit to myii/template-formula that referenced this issue Jul 23, 2019
* saltstack-formulas/nginx-formula#247 (comment)
  - The main issue is that the `nginx-formula` has dynamic values being
    used as the default `source_files` -- there is no way to provide
    this from the pillar/config in a sensible fashion
  - Prepending to this default (rather than overriding it) resolves this
    problem entirely, without adding excessive entries to the `source`
* Closes saltstack-formulas#151
myii added a commit to myii/template-formula that referenced this issue Jul 23, 2019
* saltstack-formulas/nginx-formula#247 (comment)
  - The main issue is that the `nginx-formula` has dynamic values being
    used as the default `source_files` -- there is no way to provide
    this from the pillar/config in a sensible fashion
  - Prepending to this default (rather than overriding it) resolves this
    problem entirely, without adding excessive entries to the `source`
* Closes saltstack-formulas#151
myii added a commit to myii/template-formula that referenced this issue Jul 25, 2019
* saltstack-formulas/nginx-formula#247 (comment)
  - The main issue is that the `nginx-formula` has dynamic values being
    used as the default `source_files` -- there is no way to provide
    this from the pillar/config in a sensible fashion
  - Prepending to this default (rather than overriding it) resolves this
    problem entirely, without adding excessive entries to the `source`
* Closes saltstack-formulas#151
saltstack-formulas-travis pushed a commit that referenced this issue Jul 25, 2019
## [3.1.1](v3.1.0...v3.1.1) (2019-07-25)

### Bug Fixes

* **tofs:** prepend the config-based `source_files` to the default ([3483e76](3483e76)), closes [/github.com/saltstack-formulas/nginx-formula/pull/247#issuecomment-514262549](https://github.com//github.com/saltstack-formulas/nginx-formula/pull/247/issues/issuecomment-514262549) [#151](#151)

### Documentation

* **tofs:** ensure merged will all recent changes ([6a614d9](6a614d9))
* **tofs:** update from `nginx-formula` ([23a221e](23a221e)), closes [/github.com/saltstack-formulas/nginx-formula/pull/238#discussion_r289124365](https://github.com//github.com/saltstack-formulas/nginx-formula/pull/238/issues/discussion_r289124365)
@saltstack-formulas-travis

🎉 This issue has been resolved in version 3.1.1 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants