Skip to content

Conversation

@myii
Copy link
Contributor

@myii myii commented Jan 24, 2019

Continues work done by @mkotsbak in #211 for files added after that PR was merged.

@myii myii requested a review from noelmcloughlin January 24, 2019 13:24
@myii
Copy link
Contributor Author

myii commented Jan 24, 2019

What's the situation with using tpldir in .yaml files? I've found that it is in use in the ceph-formula:

I've tried it out with the .yaml files in this repo with no apparent backlash. If those changes are viable, I can add them to this PR.

@noelmcloughlin
Copy link
Contributor

The tpldir is just a pattern I saw others using - generally works fine so you could try?

@noelmcloughlin
Copy link
Contributor

I never used salt.file.dirname(tpldir) pattern - maybe it is exact same astmpldir variable?

@myii
Copy link
Contributor Author

myii commented Jan 24, 2019

@noelmcloughlin There is a difference between tpldir and salt.file.dirname(tpldir).

https://github.com/saltstack/salt/blob/9c81df64c19e1e25cd9cd2be570d116e2a886604/salt/utils/templates.py#L131:

                tpldir = os.path.dirname(template).replace('\\', '/')

So this returns the directory name where template is located. That works fine for .sls files in the base directory. But what if the .sls file is in a sub-directory, like the ones in this PR? Using tpldir would result in looking for:

  • postgres/client/map.jinja
  • postgres/dev/map.jinja
  • postgres/server/map.jinja

Thus, salt.file.dirname(tpldir) is required when an .sls file is located within a sub-directory. This then references the parent directory appropriately, i.e. postgres/map.jinja.

Other examples from these same sub-directories:

{%- from salt.file.dirname(tpldir) ~ "/map.jinja" import postgres with context -%}

{%- from salt.file.dirname(tpldir) ~ "/map.jinja" import postgres with context -%}

{%- from salt.file.dirname(tpldir) ~ "/map.jinja" import postgres with context -%}

@myii
Copy link
Contributor Author

myii commented Jan 24, 2019

@noelmcloughlin Forgot to mention: thanks for taking the time out to review!

Copy link
Contributor

@noelmcloughlin noelmcloughlin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the hard work and detailed explanation @myii I'll remember this info. LGTM !

@aboe76 aboe76 merged commit 31fb296 into saltstack-formulas:master Jan 24, 2019
@aboe76
Copy link
Contributor

aboe76 commented Jan 24, 2019

@myii thanks for you work.

@myii myii deleted the PR_tpldir branch January 24, 2019 19:11
@myii
Copy link
Contributor Author

myii commented Jan 24, 2019

@aboe76 Thanks for the merge.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants