Upgrade to Foreman 3.4 / non-kettelo - Failed

Problem:
I upgraded Foreman to 3.4 over the weekend as well as updated Salt to version 3005 (tiamat) one-dir. There were no errors that came up during the upgrade, but now I can no longer manage Salt Keys nor can I read reports in Foreman.

For the Salt-Keys, it appears the link is no longer there. I go to Infrastructure -> Smart Proxies -> Click on ServerName. Than click on the Actiondrop down and nosalt-keysbutton. If I click on theAutosign` button nothing happens.

Expected outcome:
To be able to see reports on host
To be able to Accept/Reject/Delete Minion keys

Foreman and Proxy versions:
3.4.0 / 3.4.0

Foreman and Proxy plugin versions:
Foreman version: 3.4.0
Plugins:

  • foreman-tasks 7.0.0
  • foreman_bootdisk 19.0.5
  • foreman_discovery 21.0.1
  • foreman_hooks 0.3.17
  • foreman_puppet 4.0.1
  • foreman_remote_execution 7.1.0
  • foreman_salt 15.1.0

Distribution and version:
Single Server
AlmaLinux 8.6

Features
Puppet CA, Puppet, Logs, DNS, TFTP, DHCP, Discovery, Salt, and Dynflow

Other relevant data:
Only the report action generates an error when you try to read the report. Here is the rake output for that.

foreman-rake errors:fetch_log request_id=b413fb1b
2022-09-13T06:59:19 [I|app|b413fb1b] Started GET "/job_invocations/60" for 10.39.68.86 at 2022-09-13 06:59:19 -0700
2022-09-13T06:59:19 [I|app|b413fb1b] Processing by JobInvocationsController#show as HTML
2022-09-13T06:59:19 [I|app|b413fb1b]   Parameters: {"id"=>"60"}
2022-09-13T06:59:20 [I|app|b413fb1b]   Rendered /usr/share/gems/gems/foreman_remote_execution-7.1.0/app/views/job_invocations/show.html.erb within layouts/application (Duration: 166.7ms | Allocations: 8351)
2022-09-13T06:59:20 [I|app|b413fb1b]   Rendered layout layouts/application.html.erb (Duration: 167.0ms | Allocations: 8404)
2022-09-13T06:59:20 [W|app|b413fb1b] undefined method `template_inputs' for nil:NilClass
2022-09-13T06:59:20 [I|app|b413fb1b] Backtrace for 'undefined method `template_inputs' for nil:NilClass' error (ActionView::Template::Error): undefined method `template_inputs' for nil:NilClass
 b413fb1b | /usr/share/gems/gems/foreman_remote_execution-7.1.0/app/helpers/remote_execution_helper.rb:249:in `job_report_template'
 b413fb1b | /usr/share/gems/gems/foreman_remote_execution-7.1.0/app/helpers/remote_execution_helper.rb:67:in `job_invocation_task_buttons'
 b413fb1b | /usr/share/gems/gems/foreman_remote_execution-7.1.0/app/views/job_invocations/show.html.erb:12:in `_3558cf7d48c9a95b59d9a5280d98421d'
 b413fb1b | /usr/share/gems/gems/actionview-6.1.6.1/lib/action_view/base.rb:247:in `public_send'
 b413fb1b | /usr/share/gems/gems/actionview-6.1.6.1/lib/action_view/base.rb:247:in `_run'
 b413fb1b | /usr/share/gems/gems/actionview-6.1.6.1/lib/action_view/template.rb:154:in `block in render'
 b413fb1b | /usr/share/gems/gems/activesupport-6.1.6.1/lib/active_support/notifications.rb:205:in `instrument'
 b413fb1b | /usr/share/gems/gems/actionview-6.1.6.1/lib/action_view/template.rb:345:in `instrument_render_template'
 b413fb1b | /usr/share/gems/gems/actionview-6.1.6.1/lib/action_view/template.rb:152:in `render'
 b413fb1b | /usr/share/gems/gems/deface-1.5.3/lib/deface/action_view_extensions.rb:43:in `render'
 b413fb1b | /usr/share/gems/gems/actionview-6.1.6.1/lib/action_view/renderer/template_renderer.rb:61:in `block (2 levels) in render_template'
 b413fb1b | /usr/share/gems/gems/activesupport-6.1.6.1/lib/active_support/notifications.rb:203:in `block in instrument'
 b413fb1b | /usr/share/gems/gems/activesupport-6.1.6.1/lib/active_support/notifications/instrumenter.rb:24:in `instrument'
 b413fb1b | /usr/share/gems/gems/activesupport-6.1.6.1/lib/active_support/notifications.rb:203:in `instrument'
 b413fb1b | /usr/share/gems/gems/actionview-6.1.6.1/lib/action_view/renderer/template_renderer.rb:56:in `block in render_template'
 b413fb1b | /usr/share/gems/gems/actionview-6.1.6.1/lib/action_view/renderer/template_renderer.rb:71:in `block in render_with_layout'
 b413fb1b | /usr/share/gems/gems/activesupport-6.1.6.1/lib/active_support/notifications.rb:203:in `block in instrument'
 b413fb1b | /usr/share/gems/gems/activesupport-6.1.6.1/lib/active_support/notifications/instrumenter.rb:24:in `instrument'
 b413fb1b | /usr/share/gems/gems/activesupport-6.1.6.1/lib/active_support/notifications.rb:203:in `instrument'
 b413fb1b | /usr/share/gems/gems/actionview-6.1.6.1/lib/action_view/renderer/template_renderer.rb:70:in `render_with_layout'
 b413fb1b | /usr/share/gems/gems/actionview-6.1.6.1/lib/action_view/renderer/template_renderer.rb:55:in `render_template'
 b413fb1b | /usr/share/gems/gems/actionview-6.1.6.1/lib/action_view/renderer/template_renderer.rb:11:in `render'
 b413fb1b | /usr/share/gems/gems/actionview-6.1.6.1/lib/action_view/renderer/renderer.rb:61:in `render_template_to_object'
 b413fb1b | /usr/share/gems/gems/actionview-6.1.6.1/lib/action_view/renderer/renderer.rb:29:in `render_to_object'
 b413fb1b | /usr/share/gems/gems/actionview-6.1.6.1/lib/action_view/rendering.rb:117:in `block in _render_template'
 b413fb1b | /usr/share/gems/gems/actionview-6.1.6.1/lib/action_view/base.rb:273:in `in_rendering_context'
 b413fb1b | /usr/share/gems/gems/actionview-6.1.6.1/lib/action_view/rendering.rb:116:in `_render_template'
 b413fb1b | /usr/share/gems/gems/actionpack-6.1.6.1/lib/action_controller/metal/streaming.rb:218:in `_render_template'
 b413fb1b | /usr/share/gems/gems/actionview-6.1.6.1/lib/action_view/rendering.rb:103:in `render_to_body'
 b413fb1b | /usr/share/gems/gems/actionpack-6.1.6.1/lib/action_controller/metal/rendering.rb:52:in `render_to_body'
 b413fb1b | /usr/share/gems/gems/actionpack-6.1.6.1/lib/action_controller/metal/renderers.rb:142:in `render_to_body'
 b413fb1b | /usr/share/gems/gems/actionpack-6.1.6.1/lib/abstract_controller/rendering.rb:25:in `render'
 b413fb1b | /usr/share/gems/gems/actionpack-6.1.6.1/lib/action_controller/metal/rendering.rb:36:in `render'
 b413fb1b | /usr/share/gems/gems/actionpack-6.1.6.1/lib/action_controller/metal/instrumentation.rb:46:in `block (2 levels) in render'
 b413fb1b | /usr/share/ruby/benchmark.rb:308:in `realtime'
 b413fb1b | /usr/share/gems/gems/activesupport-6.1.6.1/lib/active_support/core_ext/benchmark.rb:14:in `ms'
 b413fb1b | /usr/share/gems/gems/actionpack-6.1.6.1/lib/action_controller/metal/instrumentation.rb:46:in `block in render'
 b413fb1b | /usr/share/gems/gems/actionpack-6.1.6.1/lib/action_controller/metal/instrumentation.rb:86:in `cleanup_view_runtime'
 b413fb1b | /usr/share/gems/gems/activerecord-6.1.6.1/lib/active_record/railties/controller_runtime.rb:34:in `cleanup_view_runtime'
 b413fb1b | /usr/share/gems/gems/actionpack-6.1.6.1/lib/action_controller/metal/instrumentation.rb:45:in `render'
 b413fb1b | /usr/share/gems/gems/actionpack-6.1.6.1/lib/action_controller/metal/implicit_render.rb:35:in `default_render'
 b413fb1b | /usr/share/gems/gems/actionpack-6.1.6.1/lib/action_controller/metal/basic_implicit_render.rb:6:in `block in send_action'
 b413fb1b | /usr/share/gems/gems/actionpack-6.1.6.1/lib/action_controller/metal/basic_implicit_render.rb:6:in `tap'
 b413fb1b | /usr/share/gems/gems/actionpack-6.1.6.1/lib/action_controller/metal/basic_implicit_render.rb:6:in `send_action'
 b413fb1b | /usr/share/gems/gems/actionpack-6.1.6.1/lib/abstract_controller/base.rb:228:in `process_action'
 b413fb1b | /usr/share/gems/gems/actionpack-6.1.6.1/lib/action_controller/metal/rendering.rb:30:in `process_action'
 b413fb1b | /usr/share/gems/gems/actionpack-6.1.6.1/lib/abstract_controller/callbacks.rb:42:in `block in process_action'
 b413fb1b | /usr/share/gems/gems/activesupport-6.1.6.1/lib/active_support/callbacks.rb:117:in `block in run_callbacks'
 b413fb1b | /usr/share/foreman/app/controllers/concerns/foreman/controller/timezone.rb:10:in `set_timezone'
 b413fb1b | /usr/share/gems/gems/activesupport-6.1.6.1/lib/active_support/callbacks.rb:126:in `block in run_callbacks'
 b413fb1b | /usr/share/foreman/app/models/concerns/foreman/thread_session.rb:32:in `clear_thread'
 b413fb1b | /usr/share/gems/gems/activesupport-6.1.6.1/lib/active_support/callbacks.rb:126:in `block in run_callbacks'
 b413fb1b | /usr/share/foreman/app/controllers/concerns/foreman/controller/topbar_sweeper.rb:12:in `set_topbar_sweeper_controller'
 b413fb1b | /usr/share/gems/gems/activesupport-6.1.6.1/lib/active_support/callbacks.rb:126:in `block in run_callbacks'
 b413fb1b | /usr/share/gems/gems/audited-4.10.0/lib/audited/sweeper.rb:14:in `around'
 b413fb1b | /usr/share/gems/gems/activesupport-6.1.6.1/lib/active_support/callbacks.rb:126:in `block in run_callbacks'
 b413fb1b | /usr/share/gems/gems/audited-4.10.0/lib/audited/sweeper.rb:14:in `around'
 b413fb1b | /usr/share/gems/gems/activesupport-6.1.6.1/lib/active_support/callbacks.rb:126:in `block in run_callbacks'
 b413fb1b | /usr/share/gems/gems/activesupport-6.1.6.1/lib/active_support/callbacks.rb:137:in `run_callbacks'
 b413fb1b | /usr/share/gems/gems/actionpack-6.1.6.1/lib/abstract_controller/callbacks.rb:41:in `process_action'
 b413fb1b | /usr/share/gems/gems/actionpack-6.1.6.1/lib/action_controller/metal/rescue.rb:22:in `process_action'
 b413fb1b | /usr/share/gems/gems/actionpack-6.1.6.1/lib/action_controller/metal/instrumentation.rb:34:in `block in process_action'
 b413fb1b | /usr/share/gems/gems/activesupport-6.1.6.1/lib/active_support/notifications.rb:203:in `block in instrument'
 b413fb1b | /usr/share/gems/gems/activesupport-6.1.6.1/lib/active_support/notifications/instrumenter.rb:24:in `instrument'
 b413fb1b | /usr/share/gems/gems/activesupport-6.1.6.1/lib/active_support/notifications.rb:203:in `instrument'
 b413fb1b | /usr/share/gems/gems/actionpack-6.1.6.1/lib/action_controller/metal/instrumentation.rb:33:in `process_action'
 b413fb1b | /usr/share/gems/gems/actionpack-6.1.6.1/lib/action_controller/metal/params_wrapper.rb:249:in `process_action'
 b413fb1b | /usr/share/gems/gems/activerecord-6.1.6.1/lib/active_record/railties/controller_runtime.rb:27:in `process_action'
 b413fb1b | /usr/share/gems/gems/actionpack-6.1.6.1/lib/abstract_controller/base.rb:165:in `process'
 b413fb1b | /usr/share/gems/gems/actionview-6.1.6.1/lib/action_view/rendering.rb:39:in `process'
 b413fb1b | /usr/share/gems/gems/actionpack-6.1.6.1/lib/action_controller/metal.rb:190:in `dispatch'
 b413fb1b | /usr/share/gems/gems/actionpack-6.1.6.1/lib/action_controller/metal.rb:254:in `dispatch'
 b413fb1b | /usr/share/gems/gems/actionpack-6.1.6.1/lib/action_dispatch/routing/route_set.rb:50:in `dispatch'
 b413fb1b | /usr/share/gems/gems/actionpack-6.1.6.1/lib/action_dispatch/routing/route_set.rb:33:in `serve'
 b413fb1b | /usr/share/gems/gems/actionpack-6.1.6.1/lib/action_dispatch/journey/router.rb:50:in `block in serve'
 b413fb1b | /usr/share/gems/gems/actionpack-6.1.6.1/lib/action_dispatch/journey/router.rb:32:in `each'
 b413fb1b | /usr/share/gems/gems/actionpack-6.1.6.1/lib/action_dispatch/journey/router.rb:32:in `serve'
 b413fb1b | /usr/share/gems/gems/actionpack-6.1.6.1/lib/action_dispatch/routing/route_set.rb:842:in `call'
 b413fb1b | /usr/share/gems/gems/apipie-dsl-2.5.0/lib/apipie_dsl/static_dispatcher.rb:67:in `call'
 b413fb1b | /usr/share/gems/gems/apipie-rails-0.5.20/lib/apipie/static_dispatcher.rb:66:in `call'
 b413fb1b | /usr/share/gems/gems/apipie-rails-0.5.20/lib/apipie/extractor/recorder.rb:137:in `call'
 b413fb1b | /usr/share/gems/gems/actionpack-6.1.6.1/lib/action_dispatch/middleware/static.rb:24:in `call'
 b413fb1b | /usr/share/gems/gems/actionpack-6.1.6.1/lib/action_dispatch/middleware/static.rb:24:in `call'
 b413fb1b | /usr/share/gems/gems/actionpack-6.1.6.1/lib/action_dispatch/middleware/static.rb:24:in `call'
 b413fb1b | /usr/share/gems/gems/actionpack-6.1.6.1/lib/action_dispatch/middleware/static.rb:24:in `call'
 b413fb1b | /usr/share/gems/gems/actionpack-6.1.6.1/lib/action_dispatch/middleware/static.rb:24:in `call'
 b413fb1b | /usr/share/gems/gems/actionpack-6.1.6.1/lib/action_dispatch/middleware/static.rb:24:in `call'
 b413fb1b | /usr/share/foreman/lib/foreman/middleware/libvirt_connection_cleaner.rb:9:in `call'
 b413fb1b | /usr/share/foreman/lib/foreman/middleware/telemetry.rb:10:in `call'
 b413fb1b | /usr/share/gems/gems/apipie-rails-0.5.20/lib/apipie/middleware/checksum_in_headers.rb:27:in `call'
 b413fb1b | /usr/share/gems/gems/rack-2.2.4/lib/rack/tempfile_reaper.rb:15:in `call'
 b413fb1b | /usr/share/gems/gems/rack-2.2.4/lib/rack/etag.rb:27:in `call'
 b413fb1b | /usr/share/gems/gems/rack-2.2.4/lib/rack/conditional_get.rb:27:in `call'
 b413fb1b | /usr/share/gems/gems/rack-2.2.4/lib/rack/head.rb:12:in `call'
 b413fb1b | /usr/share/gems/gems/actionpack-6.1.6.1/lib/action_dispatch/http/permissions_policy.rb:22:in `call'
 b413fb1b | /usr/share/gems/gems/actionpack-6.1.6.1/lib/action_dispatch/http/content_security_policy.rb:19:in `call'
 b413fb1b | /usr/share/foreman/lib/foreman/middleware/logging_context_session.rb:22:in `call'
 b413fb1b | /usr/share/gems/gems/rack-2.2.4/lib/rack/session/abstract/id.rb:266:in `context'
 b413fb1b | /usr/share/gems/gems/rack-2.2.4/lib/rack/session/abstract/id.rb:260:in `call'
 b413fb1b | /usr/share/gems/gems/actionpack-6.1.6.1/lib/action_dispatch/middleware/cookies.rb:689:in `call'
 b413fb1b | /usr/share/gems/gems/actionpack-6.1.6.1/lib/action_dispatch/middleware/callbacks.rb:27:in `block in call'
 b413fb1b | /usr/share/gems/gems/activesupport-6.1.6.1/lib/active_support/callbacks.rb:98:in `run_callbacks'
 b413fb1b | /usr/share/gems/gems/actionpack-6.1.6.1/lib/action_dispatch/middleware/callbacks.rb:26:in `call'
 b413fb1b | /usr/share/gems/gems/actionpack-6.1.6.1/lib/action_dispatch/middleware/actionable_exceptions.rb:18:in `call'
 b413fb1b | /usr/share/gems/gems/actionpack-6.1.6.1/lib/action_dispatch/middleware/debug_exceptions.rb:29:in `call'
 b413fb1b | /usr/share/gems/gems/actionpack-6.1.6.1/lib/action_dispatch/middleware/show_exceptions.rb:33:in `call'
 b413fb1b | /usr/share/gems/gems/railties-6.1.6.1/lib/rails/rack/logger.rb:37:in `call_app'
 b413fb1b | /usr/share/gems/gems/railties-6.1.6.1/lib/rails/rack/logger.rb:28:in `call'
 b413fb1b | /usr/share/gems/gems/sprockets-rails-3.4.2/lib/sprockets/rails/quiet_assets.rb:13:in `call'
 b413fb1b | /usr/share/foreman/lib/foreman/middleware/logging_context_request.rb:11:in `call'
 b413fb1b | /usr/share/gems/gems/actionpack-6.1.6.1/lib/action_dispatch/middleware/remote_ip.rb:81:in `call'
 b413fb1b | /usr/share/gems/gems/actionpack-6.1.6.1/lib/action_dispatch/middleware/request_id.rb:26:in `call'
 b413fb1b | /usr/share/gems/gems/rack-2.2.4/lib/rack/method_override.rb:24:in `call'
 b413fb1b | /usr/share/gems/gems/rack-2.2.4/lib/rack/runtime.rb:22:in `call'
 b413fb1b | /usr/share/gems/gems/activesupport-6.1.6.1/lib/active_support/cache/strategy/local_cache_middleware.rb:29:in `call'
 b413fb1b | /usr/share/gems/gems/actionpack-6.1.6.1/lib/action_dispatch/middleware/executor.rb:14:in `call'
 b413fb1b | /usr/share/gems/gems/actionpack-6.1.6.1/lib/action_dispatch/middleware/static.rb:24:in `call'
 b413fb1b | /usr/share/gems/gems/rack-2.2.4/lib/rack/sendfile.rb:110:in `call'
 b413fb1b | /usr/share/gems/gems/actionpack-6.1.6.1/lib/action_dispatch/middleware/ssl.rb:77:in `call'
 b413fb1b | /usr/share/gems/gems/actionpack-6.1.6.1/lib/action_dispatch/middleware/host_authorization.rb:142:in `call'
 b413fb1b | /usr/share/gems/gems/secure_headers-6.3.4/lib/secure_headers/middleware.rb:11:in `call'
 b413fb1b | /usr/share/gems/gems/railties-6.1.6.1/lib/rails/engine.rb:539:in `call'
 b413fb1b | /usr/share/gems/gems/railties-6.1.6.1/lib/rails/railtie.rb:207:in `public_send'
 b413fb1b | /usr/share/gems/gems/railties-6.1.6.1/lib/rails/railtie.rb:207:in `method_missing'
 b413fb1b | /usr/share/gems/gems/rack-2.2.4/lib/rack/urlmap.rb:74:in `block in call'
 b413fb1b | /usr/share/gems/gems/rack-2.2.4/lib/rack/urlmap.rb:58:in `each'
 b413fb1b | /usr/share/gems/gems/rack-2.2.4/lib/rack/urlmap.rb:58:in `call'
 b413fb1b | /usr/share/gems/gems/puma-5.6.4/lib/puma/configuration.rb:252:in `call'
 b413fb1b | /usr/share/gems/gems/puma-5.6.4/lib/puma/request.rb:77:in `block in handle_request'
 b413fb1b | /usr/share/gems/gems/puma-5.6.4/lib/puma/thread_pool.rb:340:in `with_force_shutdown'
 b413fb1b | /usr/share/gems/gems/puma-5.6.4/lib/puma/request.rb:76:in `handle_request'
 b413fb1b | /usr/share/gems/gems/puma-5.6.4/lib/puma/server.rb:441:in `process_client'
 b413fb1b | /usr/share/gems/gems/puma-5.6.4/lib/puma/thread_pool.rb:147:in `block in spawn_thread'
 b413fb1b | /usr/share/gems/gems/logging-2.3.1/lib/logging/diagnostic_context.rb:474:in `block in create_with_logging_context'
2022-09-13T06:59:20 [I|app|b413fb1b]   Rendered common/500.html.erb within layouts/application (Duration: 35.8ms | Allocations: 5951)
2022-09-13T06:59:20 [I|app|b413fb1b]   Rendered layouts/base.html.erb (Duration: 24.9ms | Allocations: 7540)
2022-09-13T06:59:20 [I|app|b413fb1b]   Rendered layout layouts/application.html.erb (Duration: 82.2ms | Allocations: 24603)
2022-09-13T06:59:20 [I|app|b413fb1b] Completed 500 Internal Server Error in 919ms (Views: 83.0ms | ActiveRecord: 20.9ms | Allocations: 40843)

Foreman version: 3.4.0
Plugins: 
 - foreman-tasks 7.0.0
 - foreman_bootdisk 19.0.5
 - foreman_discovery 21.0.1
 - foreman_hooks 0.3.17
 - foreman_puppet 4.0.1
 - foreman_remote_execution 7.1.0
 - foreman_salt 15.1.0

Also if it helps I found /usr/sbin/upload_salt_reports and read its contents and noticed the shebang points to the system python interpreter. However, Salt 3005 Tiamat packages python and all of salts dep’s in one dir location. Furthermore I noticed that in that script you have yaml.load(file,), but Salt’s python 3.9 requires you use yaml.load(file, Loader=FullLoader). I will add the script below with the changes I made.

cat /usr/sbin/upload-salt-reports 
#!/usr/bin/salt python    <===New Shebang
# Uploads reports from the Salt job cache to Foreman

from __future__ import print_function

LAST_UPLOADED = '/etc/salt/last_uploaded'
FOREMAN_CONFIG = '/etc/salt/foreman.yaml'
LOCK_FILE = '/var/lock/salt-report-upload.lock'

try:
    from http.client import HTTPConnection, HTTPSConnection
except ImportError:
    from httplib import HTTPSConnection, HTTPSConnection
import ssl
import json
import yaml
import io
import os
import sys
import base64
import traceback
import salt.config
import salt.runner

if sys.version_info.major == 3:
    unicode = str


def salt_config():
    with io.open(FOREMAN_CONFIG, 'r') as f:
        config = yaml.load(f.read(), Loader=yaml.FullLoader)    <===== YAML change
    return config


def get_job(job_id):
    result = run('jobs.lookup_jid', [job_id])
    # If any minion's results are strings, they're exceptions
    # and should be wrapped in a list like other errors

    for minion, value in result.items():
        try:
            if isinstance(value,str):
                result[minion] = [value]
            elif isinstance(value,list):
                result[minion] = value
            else:
                for key, entry in value.items():
                    if key.startswith('module_') and '__id__' in entry and entry['__id__'] == 'state.highstate':
                        result[minion] = entry['changes']['ret']
                        break
        except KeyError:
            traceback.print_exc()

    return {'job':
             {
               'result': result,
               'function': 'state.highstate',
               'job_id': job_id
             }
           }


def read_last_uploaded():
    if not os.path.isfile(LAST_UPLOADED):
        return 0
    else:
        with io.open(LAST_UPLOADED, 'r') as f:
            result = f.read().strip()
        if len(result) == 20:
            try:
                return int(result)
            except ValueError:
                return 0
        else:
            return 0


def write_last_uploaded(last_uploaded):
    with io.open(LAST_UPLOADED, 'w+') as f:
        f.write(unicode(last_uploaded))


def run(*args, **kwargs):
    __opts__ = salt.config.master_config(
            os.environ.get('SALT_MASTER_CONFIG', '/etc/salt/master'))

    runner = salt.runner.Runner(__opts__)
    with io.open(os.devnull, 'w') as f:
        stdout_bak, sys.stdout = sys.stdout, f
        try:
            ret = runner.cmd(*args, **kwargs)
        finally:
            sys.stdout = stdout_bak
    return ret['data'] if 'data' in ret else ret


def jobs_to_upload():
    jobs = run('jobs.list_jobs', kwarg={
        "search_function": ["state.highstate","state.template_str"],
    })
    last_uploaded = read_last_uploaded()

    job_ids = [jid for jid in jobs.keys() if int(jid) > last_uploaded]

    for job_id in sorted(job_ids):
        yield job_id, get_job(job_id)


def upload(jobs):
    config = salt_config()
    headers = {'Accept': 'application/json',
               'Content-Type': 'application/json'}

    if config[':proto'] == 'https':
        ctx = ssl.create_default_context()
        ctx.load_cert_chain(certfile=config[':ssl_cert'], keyfile=config[':ssl_key'])
        if config[':ssl_ca']:
            ctx.load_verify_locations(cafile=config[':ssl_ca'])
        connection = HTTPSConnection(config[':host'],
                                     port=config[':port'], context=ctx)
    else:
        connection = HTTPConnection(config[':host'],
                                    port=config[':port'])
        if ':username' in config and ':password' in config:
            auth = '{}:{}'.format(config[':username'], config[':password'])
            if not isinstance(auth, bytes):
                auth = auth.encode('UTF-8')
            token = base64.b64encode(auth)
            headers['Authorization'] = 'Basic {}'.format(token)

    for job_id, job in jobs:

        if job['job']['result'] == {}:
            continue

        connection.request('POST', '/salt/api/v2/jobs/upload',
                json.dumps(job), headers)
        response = connection.getresponse()

        if response.status == 200:
            write_last_uploaded(job_id)
            print("Success %s: %s" % (job_id, response.read()))
        else:
            print("Unable to upload job - aborting report upload")
            print(response.read())


def get_lock():
    if os.path.isfile(LOCK_FILE):
        raise Exception("Unable to obtain lock.")
    else:
        io.open(LOCK_FILE, 'w+').close()


def release_lock():
    if os.path.isfile(LOCK_FILE):
        os.remove(LOCK_FILE)


if __name__ == '__main__':
    try:
        get_lock()
        upload(jobs_to_upload())
        release_lock()
    except:
        release_lock()
        traceback.print_exc()

Anyways at this point Im not sure where to go to fix things. So hoping someone here can help me out.

Thanks

Shawn OG