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

Getting existing pillar data using py renderer in pillars #35988

Closed
gkrystev opened this issue Sep 1, 2016 · 2 comments
Closed

Getting existing pillar data using py renderer in pillars #35988

gkrystev opened this issue Sep 1, 2016 · 2 comments
Labels
Duplicate Duplicate of another issue or PR - will be closed Question The issue is more of a question rather than a bug or a feature request
Milestone

Comments

@gkrystev
Copy link

gkrystev commented Sep 1, 2016

Description of Issue/Question

I'm trying to write a dynamic pillar, which on request makes a call to some API, acquire some data and return it as pillar data. I'm making the pillar using the python renderer.
Everything works well when I'm using the "salt-call --local" command, but when I'm using the setup as master/minion, I have some issues.

In the dynamic pillar, I have a function "run", which returns the result for the pillar. In this function, I'm trying to get some data which is needed to make the API calls, and this data is stored in another pillar (users). I saw that in this case I have a predefined variable "pillar" which holds the data for any existing pillars so far. So, in the python code for the dynamic pillar if I have "log.error(pillar)" I'm getting all the pillar data (from the users.sls in this example). This methods works very well, when I'm calling some state which use this pillar with "salt-call --local state.sls some-state". However, the same setup, when calling it like "salt 'minion' state.sls some-state", in the pillar, the "log.error(pillar)" prints an empty hash.

Setup

The setup can be simplified as this:
/srv/pillar/top.sls

'base':
  '*':
    - users
    - dynamic-pillar

/srv/pillar/users.sls

users:
  - user1
  - user2
  - user3

/srv/pillar/dynamic-pillar.sls

#!py
def run():
  ret={}
  log.error(pillar) #just to print the existing pillar data in the error log
  ret['dynamic'] = pillar
  return(ret)

Versions Report

       Salt: 2015.5.0
     Python: 2.6.6 (r266:84292, Jan 22 2014, 09:42:36)
     Jinja2: 2.2.1
   M2Crypto: 0.20.2

msgpack-python: 0.4.6
msgpack-pure: Not Installed
pycrypto: 2.0.1
libnacl: Not Installed
PyYAML: 3.10
ioflo: Not Installed
PyZMQ: 14.5.0
RAET: Not Installed
ZMQ: 4.0.5
Mako: Not Installed

@Ch3LL
Copy link
Contributor

Ch3LL commented Sep 6, 2016

@gkrystev I think you are running into the feature request in this issue #6955 to add the ability to grab other pillar information from within pillars. It looks like there is currently some workarounds posted in that issue that you can take a look at there and try out until that feature has been implemented.

@Ch3LL Ch3LL added Duplicate Duplicate of another issue or PR - will be closed Question The issue is more of a question rather than a bug or a feature request labels Sep 6, 2016
@Ch3LL Ch3LL added this to the Blocked milestone Sep 6, 2016
@Ch3LL
Copy link
Contributor

Ch3LL commented Sep 21, 2016

@gkrystev going to close this due to a duplicate of a feature and inactivity. Please ping me on this issue if you disagree with this. Thanks

@Ch3LL Ch3LL closed this as completed Sep 21, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Duplicate Duplicate of another issue or PR - will be closed Question The issue is more of a question rather than a bug or a feature request
Projects
None yet
Development

No branches or pull requests

2 participants