Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failure using method (v2_runner_on_ok) in callback plugin - foreman #51799

Closed
prabhakaran2304 opened this issue Feb 6, 2019 · 10 comments
Closed
Labels
affects_2.7 This issue/PR affects Ansible v2.7 bug This issue/PR relates to a bug. foreman Foreman community needs_info This issue requires further information. Please answer any outstanding questions. support:community This issue/PR relates to code supported by the Ansible community.

Comments

@prabhakaran2304
Copy link

SUMMARY

**I am trying to add the local and remote host to foreman but getting error like **

[WARNING]: Failure using method (v2_runner_on_ok) in callback plugin

ISSUE TYPE
  • Bug Report
COMPONENT NAME
**Foreman-1.20.1**
ANSIBLE VERSION
  config file = /etc/ansible/ansible.cfg
  configured module search path = [u'/etc/ansible/my_modules']
  ansible python module location = /usr/lib/python2.7/site-packages/ansible
  executable location = /usr/bin/ansible
  python version = 2.7.5 (default, Apr 11 2018, 07:36:10) [GCC 4.8.5 20150623 (Red Hat 4.8.5-28)]

CONFIGURATION
COLOR_DEBUG(/etc/ansible/ansible.cfg) = dark gray
COLOR_DEPRECATE(/etc/ansible/ansible.cfg) = purple
COLOR_DIFF_ADD(/etc/ansible/ansible.cfg) = green
COLOR_DIFF_LINES(/etc/ansible/ansible.cfg) = cyan
COLOR_DIFF_REMOVE(/etc/ansible/ansible.cfg) = red
COLOR_ERROR(/etc/ansible/ansible.cfg) = red
COLOR_HIGHLIGHT(/etc/ansible/ansible.cfg) = white
COLOR_OK(/etc/ansible/ansible.cfg) = green
COLOR_SKIP(/etc/ansible/ansible.cfg) = cyan
COLOR_UNREACHABLE(/etc/ansible/ansible.cfg) = red
COLOR_VERBOSE(/etc/ansible/ansible.cfg) = blue
COLOR_WARN(/etc/ansible/ansible.cfg) = bright purple
DEFAULT_CALLBACK_PLUGIN_PATH(/etc/ansible/ansible.cfg) = [u'/usr/share/ansible/plugins/callback']
DEFAULT_HOST_LIST(/etc/ansible/ansible.cfg) = [u'/etc/ansible/hosts', u'/etc/ansible/playbooks/inventory/linux', u'/etc/ansible/playbooks/
DEFAULT_LOAD_CALLBACK_PLUGINS(/etc/ansible/ansible.cfg) = True
DEFAULT_LOCAL_TMP(/etc/ansible/ansible.cfg) = /root/.ansible/tmp/ansible-local-4438hRNoqO
DEFAULT_LOG_PATH(/etc/ansible/ansible.cfg) = /var/log/ansible.log
DEFAULT_MODULE_PATH(/etc/ansible/ansible.cfg) = [u'/etc/ansible/my_modules']
DEFAULT_MODULE_UTILS_PATH(/etc/ansible/ansible.cfg) = [u'/etc/ansible/my_module_utils']
DEFAULT_ROLES_PATH(/etc/ansible/ansible.cfg) = [u'/etc/ansible/roles', u'/usr/share/ansible/roles']
HOST_KEY_CHECKING(/etc/ansible/ansible.cfg) = False


OS / ENVIRONMENT

Operating System: CentOS Linux 7.5 (Core) with Foreman - 1.20.1
Kernel: Linux 3.10.0-862.el7.x86_64
Architecture: x86-64

STEPS TO REPRODUCE
  • Install Foreman
  • Install the Foreman callback plugin - ansible, remote execution
ansible -m setup localhost
ACTUAL RESULTS
root@foremansat ansible]# ansible -m setup localhost
plugin foreman_callback.pyc: SSL verification of https://foremansat.sysadm.com disabled
 [WARNING]: Failure using method (v2_runner_on_ok) in callback plugin (<ansible.plugins.callback.minimal.CallbackModule object at
0x7f0aeeb042d0>): 'module' object has no attribute 'dumps'

 [WARNING]: Failure using method (v2_runner_on_ok) in callback plugin
(<ansible.plugins.callback./usr/share/ansible/plugins/callback/foreman_callback.CallbackModule object at 0x7f0af789b250>): 'module_name'

 [WARNING]: Failure using method (v2_playbook_on_stats) in callback plugin
(<ansible.plugins.callback./usr/share/ansible/plugins/callback/foreman_callback.CallbackModule object at 0x7f0af789b250>): 'module'
object has no attribute 'dumps'


@ansibot
Copy link
Contributor

ansibot commented Feb 6, 2019

Files identified in the description:
None

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

@ansibot ansibot added affects_2.7 This issue/PR affects Ansible v2.7 bug This issue/PR relates to a bug. needs_triage Needs a first human triage before being processed. support:core This issue/PR relates to code supported by the Ansible Engineering Team. labels Feb 6, 2019
@prabhakaran2304
Copy link
Author

COMPONENT NAME

ansible.plugins.callback.minimal.CallbackModule object at 0x7fa6688c2550
callback_plugin : #foreman_ansible

Description

trying to add the host to foreman getting error like

root@foremansat ansible]# ansible -m setup localhost -vvv
[WARNING]: Failure using method (v2_runner_on_ok) in callback plugin (<ansible.plugins.callback.minimal.CallbackModule object at
0x7fa6688c2550>): 'module' object has no attribute 'dumps'
Callback Exception:
  File "/usr/lib/python2.7/site-packages/ansible/executor/task_queue_manager.py", line 375, in send_callback
    method(*new_args, **kwargs)
   File "/usr/lib/python2.7/site-packages/ansible/plugins/callback/minimal.py", line 68, in v2_runner_on_ok
    self._display.display("%s | %s => %s" % (result._host.get_name(), state, self._dump_results(result._result, indent=4)), color=color)
   File "/usr/lib/python2.7/site-packages/ansible/plugins/callback/__init__.py", line 125, in _dump_results
    return json.dumps(abridged_result, cls=AnsibleJSONEncoder, indent=indent, ensure_ascii=False, sort_keys=sort_keys)

META: ran handlers
META: ran handlers

@ansibot

@Akasurde
Copy link
Member

Akasurde commented Feb 6, 2019

!component =lib/ansible/plugins/callback/foreman.py

@Akasurde
Copy link
Member

Akasurde commented Feb 6, 2019

@prabhakaran2304 What is the Ansible version ? also, can you run

$ cat test.py
import json
print(json.__file__)
print(json.dumps({}))

needs_info

@ansibot
Copy link
Contributor

ansibot commented Feb 6, 2019

Files identified in the description:

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

@ansibot ansibot added support:community This issue/PR relates to code supported by the Ansible community. needs_info This issue requires further information. Please answer any outstanding questions. and removed support:core This issue/PR relates to code supported by the Ansible Engineering Team. labels Feb 6, 2019
@sivel
Copy link
Member

sivel commented Feb 6, 2019

The foreman callback found at https://github.com/theforeman/foreman_ansible/blob/master/extras/foreman_callback.py is not maintained by the ansible team.

However, the cause to the issue, is that we have a callback named json which can interfere with importing the python json library. To resolve this issue, the "foreman_callback.py" callback must contain at least:

from __future__ import absolute_import

If you have further questions please stop by IRC or the mailing list:

@sivel sivel closed this as completed Feb 6, 2019
@prabhakaran2304
Copy link
Author

prabhakaran2304 commented Feb 7, 2019

@prabhakaran2304 What is the Ansible version ? also, can you run

ansible 2.7.6

$ cat test.py
import json
print(json.__file__)
print(json.dumps({}))

needs_info

root@foreman]# python test.py
/usr/lib64/python2.7/json/__init__.pyc
{}

@Akasurde

@Akasurde
Copy link
Member

Akasurde commented Feb 7, 2019

@prabhakaran2304 Are you using plugin from Ansible repo or Foreman repo ?

Also, does @sivel suggestion works for you ? Thanks.

@prabhakaran2304
Copy link
Author

@prabhakaran2304 Are you using plugin from Ansible repo or Foreman repo ?
i am using foreman repo https://github.com/theforeman/foreman_ansible/blob/master/extras/foreman_callback.py
Also, does @sivel suggestion works for you ? Thanks.

thank u

@dagwieers dagwieers added the foreman Foreman community label Feb 8, 2019
@sivel sivel removed the needs_triage Needs a first human triage before being processed. label Feb 12, 2019
@jchammons
Copy link

Thank you @sivel -- that worked for me!

@ansible ansible locked and limited conversation to collaborators Jul 25, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
affects_2.7 This issue/PR affects Ansible v2.7 bug This issue/PR relates to a bug. foreman Foreman community needs_info This issue requires further information. Please answer any outstanding questions. support:community This issue/PR relates to code supported by the Ansible community.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants