guillaumewatteeux / ansible-centreon

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

centreon_hosts should allow null values #5

Closed C-Bam closed 5 years ago

C-Bam commented 6 years ago

Issue

- name: Add host to Centreon
      centreon_host:
        url: "{{ centreon_url }}"
        username: "{{ centreon_api_user }}"
        password: "{{ centreon_api_pass }}"
        #...#
        # Without hostgroups

Actual Result

fatal: [localhost -> localhost]: FAILED! => {
    "changed": false,
    "invocation": {
        "module_args": {
        #...#       
            "hostgroups": null,
            "hostgroups_action": "add",
        #...#
    },
    "msg": "Create: "
}

Expected Result Ignore the hostgroup

Hints

I narrowed down to centreon_host.py (maybe line 284 block)

centreon.host.add(
                name,
                alias,
                ipaddr,
                hosttemplates,
                instance,
                hostgroups
            )
C-Bam commented 6 years ago

In fact, I think it does not come from your script but rather from centreonapi

https://github.com/centreon/centreon-sdk-python/blob/master/centreonapi/webservice/configuration/host.py

I don't know if '|'.join(hgname) returns something if hgname is null.

I'm not sure, but I guess the join() method throws when null value is happened

Therefore it should be tested before

guillaumewatteeux commented 5 years ago

Hi, fix on dev branch. HostGroups, HostTemplates is optional params