boto_route53 __salt__ not defined.
Error
----------
ID: register_to_route53
Function: boto_route53.present
Name: prd_artdb01.arterra.local
Result: False
Comment: An exception occurred in this state: Traceback (most recent call last):
File "/usr/lib/python2.6/site-packages/salt/state.py", line 1682, in call
**cdata['kwargs'])
File "/usr/lib/python2.6/site-packages/salt/loader.py", line 1582, in wrapper
return f(*args, **kwargs)
File "/usr/lib/python2.6/site-packages/salt/states/boto_route53.py", line 157, in present
private_zone)
File "/usr/lib/python2.6/site-packages/salt/modules/boto_route53.py", line 241, in get_record
conn = _get_conn(region=region, key=key, keyid=keyid, profile=profile)
File "/usr/lib/python2.6/site-packages/salt/utils/boto.py", line 178, in get_connection
keyid, profile)
File "/usr/lib/python2.6/site-packages/salt/utils/boto.py", line 98, in _get_profile
if not key and __salt__['config.option'](service + '.key'):
NameError: global name '__salt__' is not defined
Started: 12:42:55.588665
Duration: 1.487 ms
Changes:
minion version:
[akhter.ali@ip-10-25-36-35 ~]$ salt-minion --versions-report
Salt Version:
Salt: 2015.8.3-4743-g59bf118
Dependency Versions:
Jinja2: 2.2.1
M2Crypto: 0.20.2
Mako: Not Installed
PyYAML: 3.11
PyZMQ: 14.5.0
Python: 2.6.6 (r266:84292, May 22 2015, 08:34:51)
RAET: Not Installed
Tornado: 4.2.1
ZMQ: 4.0.5
cffi: Not Installed
cherrypy: Not Installed
dateutil: 2.4.2
gitdb: Not Installed
gitpython: Not Installed
ioflo: Not Installed
libnacl: Not Installed
msgpack-pure: Not Installed
msgpack-python: 0.4.6
mysql-python: Not Installed
pycparser: Not Installed
pycrypto: 2.6.1
pygit2: Not Installed
python-gnupg: Not Installed
smmap: Not Installed
timelib: Not Installed
System Versions:
dist: redhat 6.7 Santiago
machine: x86_64
release: 2.6.32-573.el6.x86_64
system: Red Hat Enterprise Linux Server 6.7 Santiago
[akhter.ali@ip-10-25-36-35 ~]$
Master version:
[akhter.ali@ip-10-25-31-28 ~]$ salt-master --versions-report
Salt Version:
Salt: 2015.8.3-4522-g893b30d
Dependency Versions:
Jinja2: 2.2.1
M2Crypto: 0.20.2
Mako: Not Installed
PyYAML: 3.11
PyZMQ: 14.5.0
Python: 2.6.6 (r266:84292, May 22 2015, 08:34:51)
RAET: Not Installed
Tornado: 4.2.1
ZMQ: 4.0.5
cffi: Not Installed
cherrypy: Not Installed
dateutil: 2.4.2
gitdb: Not Installed
gitpython: Not Installed
ioflo: Not Installed
libnacl: Not Installed
msgpack-pure: Not Installed
msgpack-python: 0.4.6
mysql-python: Not Installed
pycparser: Not Installed
pycrypto: 2.6.1
pygit2: Not Installed
python-gnupg: Not Installed
smmap: Not Installed
timelib: Not Installed
System Versions:
dist: redhat 6.7 Santiago
machine: x86_64
release: 2.6.32-573.el6.x86_64
system: Red Hat Enterprise Linux Server 6.7 Santiago
saltstate:
include:
- base: boto
register_to_route53:
boto_route53.present:
- name: {{ grains['id'] }}
- zone: {{ grains['domain'] }}.
- ttl: 60
- record_type: A
- region: us-east-1
- value: {{ grains['ip4_interfaces']['eth0'] }}
Boto is installed and is 2.38.
Works fine in 'minion: 2015.8.3-4701-g998b55b'
Thanks @AkhterAli for filing this - I believe I broke this with #30158, and should be fixed with #30279. Can you apply #30279 and see if that clears up this issue for you?
What's the correct way to get around this issue? The current version of salt still has this problem, and it's breaking my bootstraps.
@ralphrodkey What version of salt are you seeing this on? I know you said "current version" but there are many installation paths, so I want to be sure we're talking about the same thing. This should be fixed at the HEAD of the 2015.8 branch, as well as the 2015.8.4 release, which should be coming out soon.
The 2015.8.4 release has been tagged, and I think it's even available in the repo.saltstack.com site. You should be able to access it from there, depending on your distribution, or you can bootstrap from the git tag, v2015.8.4. Does that help?
I installed via apt-get first and got 2015.8.4. Since that was erroring, I uninstalled it via "apt-get remove salt-minion" and reinstalled with
curl -L https://bootstrap.saltstack.com -o install_salt.sh sudo sh install_salt.sh -P
That also installed version 2015.8.4, and the problem was still present.
Since "salt-minion --versions-report" looks like the right way to report what's on my system, this is what I see:
Salt Version: Salt: 2015.8.4
Dependency Versions: Jinja2: 2.7.2 M2Crypto: Not Installed Mako: 0.9.1 PyYAML: 3.10 PyZMQ: 14.0.1 Python: 2.7.6 (default, Jun 22 2015, 17:58:13) RAET: Not Installed Tornado: 4.2.1 ZMQ: 4.0.4 cffi: Not Installed cherrypy: Not Installed dateutil: 1.5 gitdb: Not Installed gitpython: Not Installed ioflo: Not Installed libgit2: Not Installed libnacl: Not Installed msgpack-pure: Not Installed msgpack-python: 0.3.0 mysql-python: 1.2.3 pycparser: Not Installed pycrypto: 2.6.1 pygit2: Not Installed python-gnupg: Not Installed smmap: Not Installed timelib: Not Installed
System Versions: dist: Ubuntu 14.04 trusty machine: x86_64 release: 3.13.0-48-generic system: Ubuntu 14.04 trusty
The error I get during state.highstate is:
ID: XXXXXXXXXXXXXXX Function: boto_route53.present Result: False Comment: An exception occurred in this state: Traceback (most recent call last): File "/usr/lib/python2.7/dist-packages/salt/state.py", line 1624, in call **cdata['kwargs']) File "/usr/lib/python2.7/dist-packages/salt/loader.py", line 1491, in wrapper return f(*args, **kwargs) File "/usr/lib/python2.7/dist-packages/salt/states/boto_route53.py", line 157, in present private_zone) File "/usr/lib/python2.7/dist-packages/salt/modules/boto_route53.py", line 226, in get_record conn = _get_conn(region=region, key=key, keyid=keyid, profile=profile) File "/usr/lib/python2.7/dist-packages/salt/utils/boto.py", line 176, in get_connection keyid, profile) File "/usr/lib/python2.7/dist-packages/salt/utils/boto.py", line 96, in _get_profile if not key and __salt__['config.option'](service + '.key'): NameError: global name '__salt__' is not defined Started: 19:41:03.780492 Duration: 1.497 ms Changes:
Thanks for the updated information @al-ralphrodkey. I just gave this a try and it appears the original fix I mentioned wasn't as all-encompassing as I had originally thought. I am able to reproduce this issue.
@cachedout Let's chat about this when you get a moment.
#30808 and #30843 are also related to this issue.
Any idea on when this might be fixed?
We're looking into it right now.
Any immediate work around/patch ?
@scbunn hacky option is to drop in salt/utils/boto.py from the 2015.8.3 tag to revert the specific change temporarily. Not a good thing to do really though. Try installing the old debian packages (asuming Ubuntu)
Apologies for the breakage that was caused here. The workaround for this issue is to patch your boto modules with a pack variable. For the boto_route53 module in particular, the change looks like this:
# git diff
diff --git a/salt/modules/boto_route53.py b/salt/modules/boto_route53.py
index 3ffeb11..66705b4 100644
--- a/salt/modules/boto_route53.py
+++ b/salt/modules/boto_route53.py
@@ -85,10 +85,10 @@ def __virtual__():
return True
-def __init__(opts):
+def __init__(opts, pack=None):
salt.utils.compat.pack_dunder(__name__)
if HAS_BOTO:
- __utils__['boto.assign_funcs'](__name__, 'route53')
+ __utils__['boto.assign_funcs'](__name__, 'route53', pack=pack)
Can anyone in this thread test the fix I've submitted in #30867 and confirm this fixes the issue for you?
This did not fix my issue for boto_elb.py
@rallytime I tried that patch myself a few hours ago after stepping back through the commits and it didn't work. Threw a pack is None error. Will try again tomorrow morning and post full trace.
Is it worth adding the _options() back in utils/boto.py and making the _profile() function aware of the two methods forgetting the config?
@rallytime just tried it again, I was wrong, it still throws the same exception for me.
Comment: An exception occurred in this state: Traceback (most recent call last):
File "/usr/lib/python2.7/dist-packages/salt/state.py", line 1624, in call
**cdata['kwargs'])
File "/usr/lib/python2.7/dist-packages/salt/loader.py", line 1491, in wrapper
return f(*args, **kwargs)
File "/usr/lib/python2.7/dist-packages/salt/states/boto_route53.py", line 157, in present
private_zone)
File "/usr/lib/python2.7/dist-packages/salt/modules/boto_route53.py", line 226, in get_record
conn = _get_conn(region=region, key=key, keyid=keyid, profile=profile)
File "/usr/lib/python2.7/dist-packages/salt/utils/boto.py", line 176, in get_connection
keyid, profile)
File "/usr/lib/python2.7/dist-packages/salt/utils/boto.py", line 96, in _get_profile
if not key and __salt__['config.option'](service + '.key'):
NameError: global name '__salt__' is not defined
I'm guessing this is because pack is still None and the setting of the global __salt__ only gets set if pack is True?
@dizzythinks Can you post the output of salt --versions? And also what your state looks like (with sensitive information removed)? I wasn't able to reproduce the error after applying this fix, but maybe I am setting something up differently than you.
@rallytime
master
Salt Version:
Salt: 2015.8.4
Dependency Versions:
Jinja2: 2.7.2
M2Crypto: Not Installed
Mako: 0.9.1
PyYAML: 3.10
PyZMQ: 14.0.1
Python: 2.7.6 (default, Jun 22 2015, 17:58:13)
RAET: Not Installed
Tornado: 4.2.1
ZMQ: 4.0.4
cffi: Not Installed
cherrypy: 3.2.2
dateutil: 2.4.2
gitdb: 0.5.4
gitpython: 0.3.2 RC1
ioflo: Not Installed
libgit2: Not Installed
libnacl: Not Installed
msgpack-pure: Not Installed
msgpack-python: 0.3.0
mysql-python: 1.2.3
pycparser: Not Installed
pycrypto: 2.6.1
pygit2: Not Installed
python-gnupg: Not Installed
smmap: 0.8.2
timelib: Not Installed
System Versions:
dist: Ubuntu 14.04 trusty
machine: x86_64
release: 3.13.0-48-generic
system: Ubuntu 14.04 trusty
minion
Salt Version:
Salt: 2015.8.4
Dependency Versions:
Jinja2: 2.7.2
M2Crypto: Not Installed
Mako: 0.9.1
PyYAML: 3.10
PyZMQ: 14.0.1
Python: 2.7.6 (default, Jun 22 2015, 17:58:13)
RAET: Not Installed
Tornado: 4.2.1
ZMQ: 4.0.4
cffi: Not Installed
cherrypy: Not Installed
dateutil: 2.4.2
gitdb: Not Installed
gitpython: Not Installed
ioflo: Not Installed
libgit2: Not Installed
libnacl: Not Installed
msgpack-pure: Not Installed
msgpack-python: 0.3.0
mysql-python: 1.2.3
pycparser: Not Installed
pycrypto: 2.6.1
pygit2: Not Installed
python-gnupg: Not Installed
smmap: Not Installed
timelib: Not Installed
System Versions:
dist: Ubuntu 14.04 trusty
machine: x86_64
release: 3.13.0-48-generic
system: Ubuntu 14.04 trusty
When setting up the record I have the following which I build from tags - which are still working it seems. All was good until the update to 8.4
dnsrecord:
boto_route53.present:
- name: {{fqdnplusdot}}
- value: {{ec2hostname}}
- zone: mydomain.com.
- ttl: 60
- record_type: CNAME
- region: {{region}}
One thing to note, I am using instance profile roles so I have no credentials in pillar or anywhere else. I've only been doing Salt for four weeks but tracing back through the changes it feels like it may be related to this but as I say, I don't know the code that well.
edit: stupid markdown!
@dizzythinks Ok, instead of changing pack=None and then pack=pack, just pass pack=__salt__ into the __utils__['boto.assign_funcs'](__name__, 'route53', pack=__salt__) line in the __init__ function. Does that get rid of the __salt__ error for you?
It should look like this:
# git diff
diff --git a/salt/modules/boto_route53.py b/salt/modules/boto_route53.py
index 3ffeb11..aaac51b 100644
--- a/salt/modules/boto_route53.py
+++ b/salt/modules/boto_route53.py
@@ -88,7 +88,7 @@ def __virtual__():
def __init__(opts):
salt.utils.compat.pack_dunder(__name__)
if HAS_BOTO:
- __utils__['boto.assign_funcs'](__name__, 'route53')
+ __utils__['boto.assign_funcs'](__name__, 'route53', pack=__salt__)
Score! Worked a treat.