saltstack / salt

Software to automate the management and configuration of any infrastructure or application at scale. Install Salt from the Salt package repositories here:
https://docs.saltproject.io/salt/install-guide/en/latest/
Apache License 2.0
14.19k stars 5.48k forks source link

Pillar data empty #37708

Closed mymtw closed 7 years ago

mymtw commented 7 years ago

Upgraded salt from 2016.3.3 to 3.4 Problem: And currently when trying to get pillar data - they empty

root@saltmaster:/home/ubuntu# salt '*' pillar.items
minion1:
    ----------
minion2:
    ----------

I'm using this option pillar_source_merging_strategy: none Also I wanted that pillar data changed depending on environment: salt '*' pillar.items pillarenv=dev salt '*' pillar.items pillarenv=qa

installation here: https://github.com/mymtwcom/salt-vagrant-demo I'm using: Vagrant 1.8.6 ubuntu 16.04

gtmanfred commented 7 years ago

You do not have a top.sls file in either of the pillar roots

https://github.com/mymtwcom/salt-vagrant-demo/tree/master/saltstack/pillar/qa

The top.sls file is at a level above this directory, if you want to use pillar_source_merging_strategy, the top.sls file needs to be in both saltstack/pillar/qa and saltstack/pillar/dev.

mymtw commented 7 years ago

@gtmanfred not helped.

gtmanfred commented 7 years ago

Did you update your github repository with the change you made?

mymtw commented 7 years ago

updated

gtmanfred commented 7 years ago

You don't have anything in the top.sls files, you still need to specify what pillar files from each pillar environment go to which minion.

Make this change, https://github.com/mymtwcom/salt-vagrant-demo/pull/1 and then MOVE that top.sls file into both the dev and qa directories.

If you remove the pillar_source_merging_strategy: none, then you would not need it in both places.

mymtw commented 7 years ago

updated github. No, not works. Do anybody have ideas?

gtmanfred commented 7 years ago

Which docs did you look up to find the pillarenv= argument?

It does not look like it is available at all in https://docs.saltstack.com/en/develop/ref/modules/all/salt.modules.pillar.html

It looks like if you revert the changes I told you to make, and change the merge strategy to smart, it will find the environments correctly. The problem is that the pillarenv stuff doesn't work the way that you are trying to use it. It can only be used in the state module in 2016.3. There is some work to add it in a future release. https://github.com/saltstack/salt/issues/32435

mymtw commented 7 years ago

Which docs did you look up to find the pillarenv= argument?

I think I saw it here https://github.com/saltstack/salt/issues/30234

gtmanfred commented 7 years ago

Yeah, so that doesn't work either, pillarenv is not currently available as an argument on the pillar module.

https://github.com/saltstack/salt/issues/32435

also noted here https://github.com/saltstack/salt/issues/35823

You would need to set it in the minion config for now. Though there is work to let it be available on the commandline.

mymtw commented 7 years ago

@gtmanfred I still have no data there: salt '*' pillar.items

minion1:
    ----------
minion2:
    ----------
mymtw commented 7 years ago

@gtmanfred can I have salt/services/backend.sls as 1 folder there or not? And change only pillar data for different deploys? like salt minion1 state.apply services.backend saltenv=qa ?

gtmanfred commented 7 years ago

You could do that On Tue, Nov 15, 2016 at 1:03 PM Igor Komar notifications@github.com wrote:

@gtmanfred https://github.com/gtmanfred can I have salt/backend as 1 folder there or not? And change only pillar data for different deploys? like salt minion1 state.apply services.backend saltenv=qa ?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/saltstack/salt/issues/37708#issuecomment-260734224, or mute the thread https://github.com/notifications/unsubscribe-auth/AAssoaJSBWstS543gBrwM1M7JDmkUJjhks5q-gHUgaJpZM4Kyz02 .

mymtw commented 7 years ago

@gtmanfred ok, but how? 1 )Environments very important part. Without them I don't see any reason in using salt. Why not include this part in tutorial in docs here https://docs.saltstack.com/en/getstarted/ ? 2) currenly I'm running simple command

salt '*' pillar.items
minion1:
    ----------
minion2:
    ----------

and what's wrong in my config?

gtmanfred commented 7 years ago

YOu can use multiple environments for pillars, here is an example.

https://github.com/gtmanfred/salt-vagrant-demo/tree/igor

root@saltmaster:~# salt minion1 state.apply pillarenv=dev
minion1:
----------
          ID: /tmp/base
    Function: file.managed
      Result: True
     Comment: File /tmp/base updated
     Started: 20:01:58.915463
    Duration: 7.058 ms
     Changes:
              ----------
              diff:
                  New file

Summary for minion1
------------
Succeeded: 1 (changed=1)
Failed:    0
------------
Total states run:     1
Total run time:   7.058 ms
root@saltmaster:~# salt minion1 cmd.run 'cat /tmp/base'
minion1:
    dev
root@saltmaster:~# salt minion2 state.apply pillarenv=qa
minion2:
----------
          ID: /tmp/base
    Function: file.managed
      Result: True
     Comment: File /tmp/base updated
     Started: 20:02:31.443893
    Duration: 8.48 ms
     Changes:
              ----------
              diff:
                  New file

Summary for minion2
------------
Succeeded: 1 (changed=1)
Failed:    0
------------
Total states run:     1
Total run time:   8.480 ms
root@saltmaster:~# salt minion2 cmd.run 'cat /tmp/base'
minion2:
    qa

But as you can see here, pillar.items is still empty, because there is no pillarenv set for the minion and the pillar.items commandline module doesn't take a pillarenv, it requires the default environment to be set on the minion, or a base environment to be available to the minion.

root@saltmaster:~# salt \* pillar.items
minion1:
    ----------
minion2:
    ----------

When i remove the pillar_merge_strategy: none, i get the following

root@saltmaster:~# salt \* pillar.items
minion2:
    ----------
    test:
        dev
minion1:
    ----------
    test:
        dev
mymtw commented 7 years ago

@gtmanfred

When i remove the pillar_merge_strategy: none, i get the following

But I removed it. You can check my repo

gtmanfred commented 7 years ago

move the top file back from the qa and dev directories, to /srv/pillar.

mymtw commented 7 years ago

@gtmanfred moving top.sls helped, updated git. But it's strange why it helped

gtmanfred commented 7 years ago

Can I close this issue now?

mymtw commented 7 years ago

yes. ofc. Thank you a lot