Hi =)
I just upgraded from 24.10.2 to 24.10.3 last week, and I just found a change of behavior of the CLAPI.
I think I’m “stretching” the use of the CLAPI and maybe I’m not following best practices, so feel free to give me feedback on how you would do those tasks
When I create a new project / new VMs in an existing project, I like to check if the host already exists via this CLAPI, to only apply my “auto_checks_conf” to newcommers and not get an error message like “This host already exists”
I used to check with commands like this one :
centreon -u admin -p '*****' -o HOST -a show -v "{{ Hostname }}"
What I used to get as a return when there were no existing hosts :
id;name;alias;address;activate
What I have now :
id;name;alias;address;activate
Return code end :
Here is a more complete show of what I try to do in the end (ansible, I’d understand to not have help on this part as this is not directly related to centreon) :
- name: check si host existe
shell: centreon -u admin -p '*****' -o HOST -a show -v "{{ Hostname }}"
delegate_to: centreon
register: command_output
- name: creation du host (si résultat précédent vide)
shell: centreon -u admin -p '*****' -o HOST -a add -v "{{ Hostname }};;{{ ipHost }};{{ templateHost }};Central;"
delegate_to: centreon
when: command_output.stdout == "id;name;alias;address;activate"
I check mainly if hosts and hostgroups exists, and i try to compare the stdout with a defined string that is returned, because the return wasn’t empty.
Is there a more elegant way to do so, that would be future proof as we can see the output can change ?
Thanks in advance, and if anyone is automating the deployment of supervision, feel free to respond here or talk about it further in dm =)