trane
trane

Reputation: 27

Dealing with relative paths in saltstack for state files and for pillar files

I want to use relative paths when including sls files. This approach works when including state files but does not work when including pillar files.

Let's assume I have the following structure on my salt master:

file_roots:
  base:
    - /srv/salt/states

pillar_roots:
  base:
    - /srv/salt/pillars

And let's assume I have the following files:

/srv/salt/states/top.sls
/srv/salt/states/test/
/srv/salt/states/test/init.sls
/srv/salt/states/test/test_state.sls

In the top.sls file I include the test directory like this:

base:
  '*':
    - test

The init.sls file then includes the actual state file like this:

include:
  - .test_state

When I call the highstate everything works as expected. Now I use the same logic for pillar data. That means I have the following files:

/srv/salt/pillars/top.sls
/srv/salt/pillars/test/
/srv/salt/pillars/test/init.sls
/srv/salt/pillars/test/test_pillar.sls

In the test_pillar.sls file I put one pillar like this:

test_pillar: text

The init.sls file looks like this (analogue to the init.sls file above):

include:
  - .test_pillar

When I call the highstate now I get the following error message:

Data failed to compile:
----------
Pillar failed to render with the following messages:
----------
Specified SLS '.test_pillar' in environment 'base' is not available on the salt master

So I go back to the init.sls file and make the file path absolute:

include:
  - test.test_pillar

Now it works.

To make a long story short: salt allows me to use relative paths in the init.sls for the state files but complains when doing the same for the pillar data.

Is this the intended behaviour? Or do I have to use some other syntax maybe?

Upvotes: 0

Views: 2026

Answers (1)

Utah_Dave
Utah_Dave

Reputation: 4581

Relative includes for pillar files was added with this commit: https://github.com/saltstack/salt/pull/52156

But as of this writing, 15 Nov 2019, it doesn't look like it has made it into a release yet.

Upvotes: 2

Related Questions