salt icon indicating copy to clipboard operation
salt copied to clipboard

salt-proxy with external pillar not working

Open Set4now opened this issue 9 years ago • 2 comments

we are trying to use salt-proxy with external pillar. for that we have our own custom module that takes the minion id as arg in ext_pillar function and form an api url ,from where we will get the data for proxy.

/usr/lib/python2.7/dist-packages/salt/pillar/network_pillar.py def ext_pillar(minion_id, pillar, # pylint: disable=W0613 url=None): ''' Read pillar data from HTTP response.

:param url String to make request
:returns dict with pillar data to add
:returns empty if error
 '''
  opts=salt.config.minion_config('/etc/salt/master.d/integration.conf')
  token=opts["api"]["authorization.token"]
  baseurl='{}?where={{%22entityid%22:%22{}%22}}'.format(url, minion_id)
  res=requests.get(baseurl, headers={ 'Authorization': token }, verify=False).json()
 return salt.utils.router_parse.router_pillar(res) ----> this is another function inside utils which will do the parsing and resturn the dict for proxy like below:
 {"proxy": {"proxytype": "napalm","driver": "ios","host": "192.168.43.2","username": "cognizant","password": "automation"}}

but when we run salt-proxy --proxyid=<minion_id>, we accept the keys, but after that it fails and says no pillar/opts data for proxy to connect. So basically at these point the salt proxy in unable to use data from external pillar.

These is master config file ext_pillar:

  • cloud_router_pillar: url: http://10.236.220.196:5000/api/v1/viewentities
  • network_pillar: url: https://uat2-harmony.cognizantgoc.com/api/v1/viewentities

I dont know what`s the issue here...also if i do salt pillar.items -l debug. it says minion is not available ( since this router is not a minion here) but if we hard code this res={"proxy": {"proxytype": "napalm","driver": "ios","host": "192.168.43.2","username": "cognizant","password": "automation"}} return res inside our module like above. it will the connect. Not sure if external pillar works with salt-proxy like this way. Kindly guide us in this.

Set4now avatar Aug 23 '17 18:08 Set4now

@Set4now i just tested with external pilar of git and it worked fine in my proxy setup.

If you test this custom external pillar with a normal minion setup does it work?

also @cro might have some insight here as well

Ch3LL avatar Aug 25 '17 14:08 Ch3LL

Hey. It has been resolved. It came out to be an issue with the API proxy data. Thanks am closing this out.

Set4now avatar Aug 26 '17 08:08 Set4now