os: Debian Jessie
version:
salt-common 2015.5.3+ds-1~bpo8+1
salt-master 2015.5.3+ds-1~bpo8+1
Hi,
I try to create my own external pillar. And to use it. But until now,
I've bee unable to get something working.
I have modified /etc/salt/master as follow:
```
extension_modules: /srv/salt/module
pillar_roots:
base:
- /srv/salt/pillar
ext_pillar:
- my_pillar.py
```
Then I wrote a pillar script in python, that resides in
/srv/salt/module/my_pillar.py.
```
#!/usr/bin/python3
import logging
#### LOG STUFF
logger = logging.getLogger('pillar_ext')
logger.setLevel(logging.DEBUG)
# create console handler with a higher log level
fh = logging.FileHandler('/var/log/salt/pillar_test.log')
fh.setLevel(logging.DEBUG)
# create console handler with a higher log level
ch = logging.StreamHandler()
ch.setLevel(logging.ERROR)
# create formatter and add it to the handlers
formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
fh.setFormatter(formatter)
ch.setFormatter(formatter)
# add the handlers to the logger
logger.addHandler(fh)
logger.addHandler(ch)
####
logger.info("File pillar.py loaded")
def ext_pillar(id, pillar, *args, **kv):
logger.info("id: {}".format(id))
logger.info("pillar: {}".format(pillar))
logger.info("args: {}".format(args))
logger.info("kv: {}".format(kv))
return {"my_key_from_ext_pillar":"my_value_from_ext_pillar"}
if "__main__" == __name__:
my_dict=ext_pillar("42", "a_pillar", "A", "B", C="C", D="D")
logger.info("my_dict={}".format(my_dict))
```
I've also tested the script to see if it runs well. It does ! I can see in the log:
/var/log/salt/pillar_test.log
```
2016-07-26 09:02:00,645 - pillar_ext - INFO - File pillar.py loaded
2016-07-26 09:02:00,645 - pillar_ext - INFO - id: 42
2016-07-26 09:02:00,645 - pillar_ext - INFO - pillar: a_pillar
2016-07-26 09:02:00,645 - pillar_ext - INFO - args: ('A', 'B')
2016-07-26 09:02:00,645 - pillar_ext - INFO - kv: {'C': 'C', 'D': 'D'}
2016-07-26 09:02:00,646 - pillar_ext - INFO - my_dict={'my_key_from_ext_pillar': 'my_value_from_ext_pillar'}
```
Now my_pillar.py is the only file in /srv/salt/module directory:
```
ls -la /srv/salt/module/
drwxr-xr-x 8 root root 4096 Jul 25 08:15 .
drwxr-xr-x 6 root root 4096 Jul 22 10:50 ..
-rwxr-xr-x 1 root root 1014 Jul 25 13:44 /srv/salt/module/my_pillar.py
```
Then I restarted the salt-master wishing to see new pillar :
{'my_key_from_ext_pillar': 'my_value_from_ext_pillar'}
But the cmd: "salt a_node pillar.raw | grep my_" show me nothing.
What am I missing ?
Thanks in advance.
cED