kitchen-salt icon indicating copy to clipboard operation
kitchen-salt copied to clipboard

Allow using `top.sls` pillar from file

Open Lirt opened this issue 6 years ago • 4 comments

Hello,

I tried to specify top.sls pillar from file but did not success. Let's say this is usual way people define pillars in suites or provisioner:

provisioner:
  name: salt_solo
  formula: dns
  salt_install: bootstrap
  salt_version: 2018.3.0
  require_chef: false
  state_top:
    base:
      '*':
        - dns
suites:
  - name: default
    provisioner:
      pillars:
        top.sls:
          base:
            '*':
              - dns

Now I would like to use top.sls pillar from file. The code I tried is this:

provisioner:
  name: salt_solo
  formula: dns
  salt_install: bootstrap
  salt_version: 2018.3.0
  require_chef: false
  state_top:
    base:
      '*':
        - dns
suites:
  - name: default
    provisioner:
    pillars-from-files:
      top.sls: test/integration/default/top.sls

This example ends with this error:

Preparing pillars into /srv/pillar Failed to complete #converge action: [undefined method `each' for nil:NilClass] on default-ubuntu-1604

I tried to diagnose with kitchen diagnose --all, but there was nothing helpful in the log. I expected that top.sls file I included in pillars-from-files will be copied into /srv/pillar and everything will work well.

Please, let me know if you need more information to troubleshoot this or if this is actually not implemented or if I am using it wrong.

Lirt avatar Apr 10 '18 06:04 Lirt

seems reasonable

gtmanfred avatar Mar 01 '19 21:03 gtmanfred

I'm not sure that pillars-from-files can be used to generate the top.sls, but you can use it to generate a pillar sls file and then include it in your pillar top.sls, something like

provisioner:
  pillars:
    top.sls:
       base:
        "*":
          - dns
    
suites:
  - name: default
    provisioner:
    pillars-from-files:
      dns.sls: test/integration/default/top.sls

I use that here https://github.com/daks/usersandgroups-formula/blob/master/kitchen.yml and it works well.

daks avatar Mar 04 '19 15:03 daks

I think I get your point.

This issue is quite old, but I think that this was what I wanted to achieve (to not define pillar variables in kitchen-salt configuration, but load them from file).

So in the suite you define the name of the pillar and path to this pillar. Then in provisioners->pillars you specify the pillar file name and the reference works, yes?

The issue in my code was, that in suites I didn't define name dns in dict ['pillars-from-files'], but name top.sls, but also, that I didn't define top.sls pillar in provisioner?

Maybe we could include some small example of loading pillars from files in docs. The usage seems a little confusing.

Edit: I can see it in documentation now.

I think we can close this. Thank you for responses.

Lirt avatar Mar 05 '19 07:03 Lirt

You get the point :)

daks avatar Mar 05 '19 08:03 daks