guillaumewatteeux / ansible-centreon

Ansible modules for CLAPI REST (Centreon API)
GNU General Public License v3.0
10 stars 12 forks source link

"Unable to get poller list message" when run Playbook #6

Open sudoerss opened 5 years ago

sudoerss commented 5 years ago

The full traceback is:

WARNING: The below traceback may *not* be related to the actual failure.
  File "/tmp/ansible_centreon_host_payload_eGlT6L/__main__.py", line 173, in main
    if not centreon.exists_poller(instance):
  File "/usr/local/lib/python2.7/dist-packages/centreonapi/centreon.py", line 59, in exists_poller
    self.availablePoller = self.poller.list()
  File "/usr/local/lib/python2.7/dist-packages/centreonapi/webservice/configuration/poller.py", line 26, in list
    return self.webservice.call_clapi('show', 'INSTANCE')
  File "/usr/local/lib/python2.7/dist-packages/centreonapi/webservice/__init__.py", line 80, in call_clapi
    self.auth()
  File "/usr/local/lib/python2.7/dist-packages/centreonapi/webservice/__init__.py", line 59, in auth
    'password': self.authpass
  File "/usr/lib/python2.7/dist-packages/requests/api.py", line 110, in post
    return request('post', url, data=data, json=json, **kwargs)
  File "/usr/lib/python2.7/dist-packages/requests/api.py", line 56, in request
    return session.request(method=method, url=url, **kwargs)
  File "/usr/lib/python2.7/dist-packages/requests/sessions.py", line 488, in request
    resp = self.send(prep, **send_kwargs)
  File "/usr/lib/python2.7/dist-packages/requests/sessions.py", line 609, in send
    r = adapter.send(request, **kwargs)
  File "/usr/lib/python2.7/dist-packages/requests/adapters.py", line 497, in send
    raise SSLError(e, request=request)

fatal: [localhost -> localhost]: FAILED! =>

"msg": "Unable to get poller list"
guillaumewatteeux commented 5 years ago

Hi,

Could you paste your playbook ?

Do you have a correct SSL certificate on your platform ?

I think a auto signed certificate don't work with current version.

File "/usr/lib/python2.7/dist-packages/requests/adapters.py", line 497, in send
raise SSLError(e, request=request)
sudoerss commented 5 years ago

Hi,

Here is the Playbook

- name: Integrate Host in CENTREON
  hosts: localhost
  vars:
    centreon_url: "http://10.0.40.100/centreon"
    centreon_api_user: "admin"
    centreon_api_pass: "centreon"

    handlers:
    - name: "centreon api applycfg"
      centreon_poller:
        url: "{{ centreon_url }}"
        username: "{{ centreon_api_user }}"
        password: "{{ centreon_api_pass }}"
      listen: centreon api applycfg
      delegate_to: localhost

  tasks:
  - name: Create host in Centreon
    centreon_host:
      url: "{{ centreon_url }}"
      username: "{{ centreon_api_user }}"
      password: "{{ centreon_api_pass }}"
      name: cert-vm1
      alias: cert-vm1
      ipaddr: 10.0.48.25
      hosttemplates:
      - generic-host
      - WINDOWS_WITH_DISK_C
      hostgroups:
      - HOSTGROUP_TEST
      hostgroups_action: set
      instance: Central
      status: enabled
      state: present
      applycfg: False
    delegate_to: localhost
    notify: "centreon api applycfg"
guillaumewatteeux commented 5 years ago

Hi,

I'm refacto sdk project, but feu with this commit https://github.com/guillaumewatteeux/centreon-sdk-python/commit/eaa757898e32450510b8460ccd481be3c61c186c

If work, i'll publish new release (0.0.3) To close this issue.

sbraz commented 5 years ago

What is the official repo for the Python API then? Is it your fork or centreon's one? Also, would it be possible to upload the new release to PyPI?

guillaumewatteeux commented 5 years ago

Hi,

Centreon is the official repo. But I'm working on it and so quickly for me to work on my repo.

After confirmation about SSL issue , I'll push this commit on official repo, upload on pypi.

sbraz commented 5 years ago

I debugged the issue with @sudoerss and it was an SSL certificate verification issue indeed. Do you want us to try the commit you linked earlier after distrusting the certificate?

camilleturiel commented 5 years ago

Well I'm getting into the same issue

camilleturiel commented 5 years ago

Sorry guys, it was actually another issue that had nothing to do with it, however leading to the same error message (http_proxy env var was improperly set in my case)

guillaumewatteeux commented 5 years ago

HI,

I've just install centreon 18.10 on VM

$ cd centreon-sdk-python
$ git checkout eaa757898e32450510b8460ccd481be3c61c186c
$ pip install .
$ ipython
In [1]: from centreonapi.webservice import Webservice

In [2]: con1 = Webservice.getInstance("http://192.168.189.130/centreon", "admin", "centreon", check_ssl=False)

In [3]: con1.call_clapi('show', 'INSTANCE')
Out[3]:
{'result': [{'id': '1',
   'name': 'Central',
   'localhost': '1',
   'ip address': '127.0.0.1',
   'activate': '1',
   'status': '-',
   'init script': 'centengine',
   'bin': '/usr/sbin/centengine',
   'stats bin': '/usr/sbin/centenginestats',
   'ssh port': '22'}]}

In [4]: con2 = Webservice.getInstance("http://192.168.189.130/centreon", "admin", "centreon", check_ssl=True)

In [5]: con2.call_clapi('show', 'INSTANCE')
Out[5]:
{'result': [{'id': '1',
   'name': 'Central',
   'localhost': '1',
   'ip address': '127.0.0.1',
   'activate': '1',
   'status': '-',
   'init script': 'centengine',
   'bin': '/usr/sbin/centengine',
   'stats bin': '/usr/sbin/centenginestats',
   'ssh port': '22'}]}

Could you test with this command ?

sbraz commented 5 years ago

Works fine with your commit and master (guillaumewatteeux/centreon-sdk-python@a2eb536fbf82f9c159158a85afd144ebe3e07060) but I still see warnings (that are supposed to be disabled by this):

/usr/local/lib/python2.7/dist-packages/urllib3/connectionpool.py:847: InsecureRequestWarning: Unverified HTTPS request is being made. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/latest/advanced-usage.html#ssl-warnings
  InsecureRequestWarning)
/usr/local/lib/python2.7/dist-packages/urllib3/connectionpool.py:847: InsecureRequestWarning: Unverified HTTPS request is being made. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/latest/advanced-usage.html#ssl-warnings
  InsecureRequestWarning)

Test code:

args = […]
from centreonapi.webservice import Webservice
Webservice.getInstance(*args, check_ssl=False).call_clapi("show", "INSTANCE")