saltstack/salt — Issue #814: "__opts__" dict not always available in modules
Author: archme
Created: 2012-03-02 09:52:00+00:00
State: open

How to reproduce:
1) put mytest module to sync dir on the master:

$cat /srv/salt/_modules/mytest.py
from pprint import pprint

#__opts__ = {}
pprint(__opts__)

def mytest():
return __opts__

2) salt '\*' saltutil.sync_modules
3) stop the minion(s)
4) delete mytest.py from cache dir on minion(s):
5) start the minion(s)
6) salt '\*' saltutil.sync_modules
7) bug 1: there is nothing to sync (is this a bug ?)
8) change something in mytest
9) salt '\*' saltutil.sync_modules
10) bug 2: check minion(s) log:

[salt.loader ][WARNING ] Failed to import module mytest, this is due most likely to a syntax error: name '\__opts\__' is not defined

How to get out of this "state":
1) uncomment "_opts__ = {}" in mytest
2) salt '\*' saltutil.sync_modules
3) comment "_opts__ = {}" in mytest
4) salt '\*' saltutil.sync_modules
5) salt '\*' mytest.mytest

Hope this procedure is not to "insane" to be considered as a bug.

lg,
Archme