splunk / splunk-ansible

Ansible playbooks for configuring and managing Splunk Enterprise and Universal Forwarder deployments

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Getting issue with splunk 8.1+ and function getSplunkbaseToken (requests.content bytes vs string)

jmohr01 opened this issue · comments

Cannot upgrade to latest splunk versions due to an issue when launching the splunk container via K8s. The issue is below:

│ splunk python version = 3.7.10 (default, Mar 9 2021, 17:42:18) [GCC 8.3.1 20191121 (Red Hat 8.3.1-5)]
│ splunk Traceback (most recent call last):
│ splunk File “inventory/environ.py”, line 821, in
│ splunk main()
│ splunk File “inventory/environ.py”, line 807, in main
│ splunk getSplunkInventory(inventory)
│ splunk File “inventory/environ.py”, line 95, in getSplunkInventory
│ splunk inventory[“all”][“vars”] = getDefaultVars()
│ splunk File “inventory/environ.py”, line 147, in getDefaultVars
│ splunk getSplunkbaseToken(defaultVars)
│ splunk File “inventory/environ.py”, line 354, in getSplunkbaseToken
│ splunk splunkbase_token = re.search(“(.*)“, output, re.IGNORECASE)
│ splunk File “/usr/lib/python3.7/re.py”, line 185, in search
│ splunk return _compile(pattern, flags).search(string)
│ splunk TypeError: cannot use a string pattern on a bytes-like object
│ splunk splunkd.pid file is unreadable.

8.0.7 is the last working version, this is because 8.0.8 merges in changes from 8.1. I believe this occurs when setting the default python.version from 2 -> 3.7

Further analysis shows, I believe, that requests.content is a bytes-like string, and re.search expects a string, so it throws a typeerror. Maybe consider using requests.text. Or find a way to decode requests.content

The workaround at the moment, as per line 348 in inventory/environ.py, it does the following check:

if vars_scope["splunkbase_username"] and vars_scope["splunkbase_password"]:

So do not specify splunkbase_username and splunkbase_password in the ENV variables or default.yml. This then skips the function.

Could you try splunk/splunk:edge? This should've been fixed with #610