Closed Set4now closed 7 years ago
beacons:
clouds:
engines:
grains:
log_handlers:
modules:
- modules.renderv1
output:
proxymodules:
renderers:
returners:
sdb:
states:
utils:
root@cri-server5:/usr/lib/python2.7/dist-packages/salt/modules# salt master renderv1.run_query master: 'renderv1.run_query' is not available. ERROR: Minions returned with non-zero exit code
So far I haven't been able to reproduce this, can you provide what the custom module looks like?
from sqlalchemy import * from jinja2 import Template import json import ast import inspect
def run_query(template, user, host, password, dbtype, dbname, **pillar): with open('/home/cloudadmin/jinja/' + template) as f: a=f.read() t=Template(a) if bool(pillar): for i in pillar.iteritems(): str=i[1]
result=t.render(str)
#result=t.render(tablename=pillar["tablename"], key=pillar["col_name"], value=pillar["value"])
db_url = "{}+pymysql://{}:{}@{}/{}?charset=utf8mb4&use_unicode=0".format(dbtype,user,password,host,dbname) engine = create_engine(db_url, pool_recycle=3600) connection = engine.connect() try: res=engine.execute(result) if res.returns_rows: output=[] for r in res: output.append(dict(r)) return json.dumps(output, indent=3) else: if res.class: return "Success" except: return "Invalid Query"
Hi, i have a custom module and copied it under /srv/salt/_modules then i did a salt master saltutil.sync_all, modules etc.. also restarted the salt-minion. still its showing 'renderv1' (module name) is not available. I also copied it under /usr/lib/python2.7/dist-packages/salt/modules/ and tried to run it, still no luck, restarted the salt-master, still no luck Please let me know what else can be checked. salt 2017.7.0 (Nitrogen)