Skip to content

Instantly share code, notes, and snippets.

@ooboyle
ooboyle / gist:fea14cbe79cddcbad305def57f72b476
Created May 17, 2018 18:56
Python 3 urllib related stacktrace in custom grain that works despite stacktrace. Grain works without stacktrace in python2.
ERROR after running salt-call grains.item test_grain:
module 'urllib' has no attribute 'urlopen'
This error has not be encountered yet. Please report it to the Operations group.
[CRITICAL] Failed to load grains defined in grain file show_current_loc_py3.urle
ncode in function <function urlencode at 0x0000000002F29950>, error:
Traceback (most recent call last):
File "C:\salt\bin\lib\site-packages\salt\loader.py", line 756, in grains
ret = funcs[key]()
@ooboyle
ooboyle / gist:5aea10a0b68f8e38cb50b0dd3b778b62
Created October 27, 2017 19:21
ooboyle - custom grain
import salt.modules.network
__salt__ = {
'network.subnets': salt.modules.network.subnets
}
def addCustomGrains():
# initialize a grains dictionary
grains = {}
@ooboyle
ooboyle / gist:7201e58c32f9fc4e339c80163328deb4
Created October 27, 2017 19:18
ooboyle - network.subnets trace
[ERROR ] An un-handled exception was caught by salt's global exception handler
:
TypeError: can't serialize <function subnets at 0x0000000005846E48>
Traceback (most recent call last):
File "C:\salt\bin\Scripts\salt-call", line 11, in <module>
salt_call()
File "C:\salt\bin\lib\site-packages\salt\scripts.py", line 379, in salt_call
client.run()
File "C:\salt\bin\lib\site-packages\salt\cli\call.py", line 48, in run
caller = salt.cli.caller.Caller.factory(self.config)
{% if grains['osrelease'] == '2016Server' %}
cbdefense:
'2.1.0.11':
full_name: 'Cb Defense Sensor 64-bit'
installer: 'salt://installers/CbDefense/installer_vista_win7_win8-64-2.1.0.11.msi'
uninstaller: 'salt://installers/CbDefense/installer_vista_win7_win8-64-2.1.0.11.msi'
install_flags: '/q /L* msi.log Company_Code=1DKTMLZF'
uninstall_flags: '/q'
msiexec: True
locale: en_US
@ooboyle
ooboyle / gist:96ee60da68f9e9414bdd9ba62e0f03b9
Created September 13, 2017 18:13
Master version report (pkg module issue)
salt --versions-report
Salt Version:
Salt: 2016.11.5
Dependency Versions:
cffi: Not Installed
cherrypy: Not Installed
dateutil: 2.4.2
docker-py: Not Installed
gitdb: 0.6.4
@ooboyle
ooboyle / gist:097a1d4b5db0640e5d2ccb00a9d3c95c
Created September 13, 2017 18:11
minion version report (pkg module issue)
C:\salt>salt-call --versions-report
Salt Version:
Salt: 2017.7.1
Dependency Versions:
cffi: 1.10.0
cherrypy: 10.2.1
dateutil: 2.6.0
docker-py: Not Installed
gitdb: 2.0.2
@ooboyle
ooboyle / gist:be7dfec9d88c6cf1c0b5e4b0cf846a12
Created September 13, 2017 18:10
pkg module not functioning with minion 2017.7.1 Py3
# salt myPC pkg.list_pkgs
myPC:
Passed invalid arguments to pkg.list_pkgs: 'bool' object is not subscriptable
List the packages currently installed
Args:
version_as_list (bool): Returns the versions as a list
Kwargs:
@ooboyle
ooboyle / gist:b639b75f9995baf01992b1f8d4caae0d
Created September 12, 2017 14:16
traceback after running: salt-run manage.bootstrap_psexec hosts='<myIP>' username='<myDomain>\<myAdministrator>'
Exception occurred in runner manage.bootstrap_psexec: Traceback (most recent call last):
File "/usr/lib/python2.7/dist-packages/salt/client/mixins.py", line 395, in _low
data['return'] = self.functions[fun](*args, **kwargs)
File "/usr/lib/python2.7/dist-packages/salt/runners/manage.py", line 852, in bootstrap_psexec
for path, ver, plat, date in salty_rx.findall(source)],
File "/usr/lib/python2.7/_strptime.py", line 478, in _strptime_time
return _strptime(data_string, format)[0]
File "/usr/lib/python2.7/_strptime.py", line 332, in _strptime
(data_string, format))
Exception occurred in runner manage.bootstrap_psexec: Traceback (most recent call last):
File "/usr/lib/python2.7/dist-packages/salt/client/mixins.py", line 395, in _low
data['return'] = self.functions[fun](*args, **kwargs)
File "/usr/lib/python2.7/dist-packages/salt/runners/manage.py", line 852, in bootstrap_psexec
for path, ver, plat, date in salty_rx.findall(source)],
File "/usr/lib/python2.7/_strptime.py", line 478, in _strptime_time
return _strptime(data_string, format)[0]
File "/usr/lib/python2.7/_strptime.py", line 332, in _strptime
(data_string, format))
ValueError: time data '2015-12-04 03:01' does not match format '%d-%b-%Y %H:%M'