Repository: ansible/ansible

Issue:
Using callback plugins breaks ansible-playbook
##### ISSUE TYPE
 - Bug Report

##### COMPONENT NAME
callback plugins

##### ANSIBLE VERSION
```
ansible 2.5.0 (devel a40ce1ba5e) last updated 2017/11/17 16:31:10 (GMT +1000)
  config file = /etc/ansible/ansible.cfg
  configured module search path = [u'/home/will/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
  ansible python module location = /home/will/src/ansible/lib/ansible
  executable location = /home/will/src/ansible/bin/ansible
  python version = 2.7.14 (default, Nov  2 2017, 18:42:05) [GCC 7.2.1 20170915 (Red Hat 7.2.1-2)]

```

##### CONFIGURATION
```
[defaults]
callback_whitelist = profile_tasks,timer
```

##### OS / ENVIRONMENT

##### SUMMARY

See reproduction steps.

##### STEPS TO REPRODUCE
With the above configuration file, a minimal playbook suffices
<!--- Paste example playbooks or commands between quotes below -->
```yaml
- hosts: localhost
  connection: local

  tasks:
    - debug:
        msg: hello
```

<!--- You can also paste gist.github.com links for larger files -->

##### EXPECTED RESULTS
```
$ ansible-playbook test_play.yml
 [WARNING]: Could not match supplied host pattern, ignoring: all

 [WARNING]: provided hosts list is empty, only localhost is available


PLAY [localhost] *********************************************************************************************************************************************

TASK [Gathering Facts] ***************************************************************************************************************************************
ok: [localhost]

TASK [debug] *************************************************************************************************************************************************
ok: [localhost] => {
    "msg": "hello"
}

PLAY RECAP ***************************************************************************************************************************************************
localhost                  : ok=2    changed=0    unreachable=0    failed=0   
```
##### ACTUAL RESULTS
```
$ ansible-playbook test_play.yml -vvv
ansible-playbook 2.5.0 (devel a40ce1ba5e) last updated 2017/11/17 16:31:10 (GMT +1000)
  config file = /home/will/src/ansible/ansible.cfg
  configured module search path = [u'/home/will/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
  ansible python module location = /home/will/src/ansible/lib/ansible
  executable location = /home/will/src/ansible/bin/ansible-playbook
  python version = 2.7.14 (default, Nov  2 2017, 18:42:05) [GCC 7.2.1 20170915 (Red Hat 7.2.1-2)]
Using /home/will/src/ansible/ansible.cfg as config file
Parsed /etc/ansible/hosts inventory source with ini plugin
 [WARNING]: Could not match supplied host pattern, ignoring: all

 [WARNING]: provided hosts list is empty, only localhost is available

ERROR! Unexpected Exception, this is probably a bug: set_options() takes exactly 2 arguments (1 given)
the full traceback was:

Traceback (most recent call last):
  File "/home/will/src/ansible/bin/ansible-playbook", line 109, in <module>
    exit_code = cli.run()
  File "/home/will/src/ansible/lib/ansible/cli/playbook.py", line 130, in run
    results = pbex.run()
  File "/home/will/src/ansible/lib/ansible/executor/playbook_executor.py", line 90, in run
    self._tqm.load_callbacks()
  File "/home/will/src/ansible/lib/ansible/executor/task_queue_manager.py", line 210, in load_callbacks
    callback_obj.set_options()
TypeError: set_options() takes exactly 2 arguments (1 given)

```



Discussion:
`git bisect` shows this comes from the latest configuration and plugins refactor in #31024

Resolving patch:
diff --git a/lib/ansible/plugins/callback/foreman.py b/lib/ansible/plugins/callback/foreman.py
--- a/lib/ansible/plugins/callback/foreman.py
+++ b/lib/ansible/plugins/callback/foreman.py
@@ -90,9 +90,9 @@ def __init__(self):
         self.items = defaultdict(list)
         self.start_time = int(time.time())
 
-    def set_options(self, options):
+    def set_options(self, task_keys=None, var_options=None, direct=None):
 
-        super(CallbackModule, self).set_options(options)
+        super(CallbackModule, self).set_options(task_keys=task_keys, var_options=var_options, direct=direct)
 
         self.FOREMAN_URL = self._plugin_options['url']
         self.FOREMAN_SSL_CERT = (self._plugin_options['ssl_cert'], self._plugin_options['ssl_key'])


Test patch: