Repository: ansible-collections/community.general

Issue:
syslog_json output plugin is broken
<!--- Verify first that your issue is not already reported on GitHub -->
<!--- Also test if the latest release and devel branch are affected too -->
<!--- Complete *all* sections as described, this form is processed automatically -->

##### SUMMARY
<!--- Explain the problem briefly below -->
Output callback syslog_json is broken. Reported on https://github.com/ansible/ansible/issues/69686

##### ISSUE TYPE
- Bug Report

##### COMPONENT NAME
<!--- Write the short name of the module, plugin, task or feature below, use your best guess if unsure -->
syslog_json.py

##### ANSIBLE VERSION
<!--- Paste verbatim output from "ansible --version" between quotes -->
```paste below
ansible 2.9.7
  config file = /etc/ansible/ansible.cfg
  configured module search path = [u'/home/ansible/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python2.7/site-packages/ansible
  executable location = /usr/bin/ansible
  python version = 2.7.5 (default, Apr  2 2020, 13:16:51) [GCC 4.8.5 20150623 (Red Hat 4.8.5-39)]
```

##### CONFIGURATION
<!--- Paste verbatim output from "ansible-config dump --only-changed" between quotes -->
```paste below
DEFAULT_CALLBACK_WHITELIST(/etc/ansible/ansible.cfg) = [u'debug', u'syslog_json']
DEFAULT_GATHER_TIMEOUT(/etc/ansible/ansible.cfg) = 30
DEFAULT_TIMEOUT(/etc/ansible/ansible.cfg) = 30
PERSISTENT_COMMAND_TIMEOUT(/etc/ansible/ansible.cfg) = 60
PERSISTENT_CONNECT_TIMEOUT(/etc/ansible/ansible.cfg) = 60
```

##### OS / ENVIRONMENT
<!--- Provide all relevant information below, e.g. target OS versions, network device firmware, etc. -->
Centos 7.8

##### STEPS TO REPRODUCE
<!--- Describe exactly how to reproduce the problem, using a minimal test-case -->
Just set the output callback to use syslog_json

<!--- Paste example playbooks or commands between quotes below -->
```yaml
ANSIBLE_STDOUT_CALLBACK=syslog_json ansible-playbook -vvv -i inv_file.yml playbooks.yml
```

<!--- HINT: You can paste gist.github.com links for larger files -->

##### EXPECTED RESULTS
<!--- Describe what you expected to happen when running the steps above -->
it wouldn't throw an exception

##### ACTUAL RESULTS
<!--- Describe what actually happened. If possible run with extra verbosity (-vvvv) -->

<!--- Paste verbatim command output between quotes -->
```paste below
ERROR! Unexpected Exception, this is probably a bug: 'CallbackModule' object has no attribute '_load_name'
the full traceback was:

Traceback (most recent call last):  File "/bin/ansible-playbook", line 123, in <module>
    exit_code = cli.run()
  File "/usr/lib/python2.7/site-packages/ansible/cli/playbook.py", line 127, in run
    results = pbex.run()
  File "/usr/lib/python2.7/site-packages/ansible/executor/playbook_executor.py", line 99, in run
    self._tqm.load_callbacks()
  File "/usr/lib/python2.7/site-packages/ansible/executor/task_queue_manager.py", line 134, in load_callbacks
    self._stdout_callback = callback_loader.get(self._stdout_callback)
  File "/usr/lib/python2.7/site-packages/ansible/plugins/loader.py", line 578, in get
    obj = obj(*args, **kwargs)
  File "/usr/lib/python2.7/site-packages/ansible/plugins/callback/syslog_json.py", line 70, in __init__
    self.set_options()
  File "/usr/lib/python2.7/site-packages/ansible/plugins/callback/__init__.py", line 99, in set_options
    self._plugin_options = C.config.get_plugin_options(get_plugin_class(self), self._load_name, keys=task_keys, variables=var_options, direct=direct)
AttributeError: 'CallbackModule' object has no attribute '_load_name'
```



Discussion:
Files identified in the description:
* [`plugins/callback/syslog_json.py`](https://github.com/ansible-collections/community.general/blob/master/plugins/callback/syslog_json.py)

If these files are inaccurate, please update the `component name` section of the description or use the `!component` bot command.

[click here for bot help](https://github.com/ansible/ansibullbot/blob/master/ISSUE_HELP.md)
<!--- boilerplate: components_banner --->

Resolving patch:
diff --git a/plugins/callback/syslog_json.py b/plugins/callback/syslog_json.py
--- a/plugins/callback/syslog_json.py
+++ b/plugins/callback/syslog_json.py
@@ -66,7 +66,9 @@ def __init__(self):
 
         super(CallbackModule, self).__init__()
 
-        self.set_options()
+    def set_options(self, task_keys=None, var_options=None, direct=None):
+
+        super(CallbackModule, self).set_options(task_keys=task_keys, var_options=var_options, direct=direct)
 
         syslog_host = self.get_option("server")
         syslog_port = int(self.get_option("port"))


Test patch: