Checking your solution I think the problems was that I was passing everything on the url using put while in your example you use POST and divide the call in url + body. It seems the url limit is only for the url itself but not the body as my hostgroup got updated from 260 host to 388 using that api call.
I adapted your example to Ansible and now it works OK as expected.
Code: Select all
- name: "[ADDING TO NAGIOS] Append {{ inventory_hostname }} to hostgroup {{OS}}"
ansible.builtin.uri:
url: "https://192.168.1.20/nagiosxi/api/v1/config/hostgroup?apikey={{ xi_api_key }}&pretty=1"
method: POST
body: "hostgroup_name={{OS}}&alias={{OS}}&members={{ hostgroup_add.json[0].members | flatten | join (',') }},{{ inventory_hostname }}"
validate_certs: no
status_code: 200
delegate_to: localhost
register: new_hostsgroup
failed_when: hostgroup_add.json.error is defined
when: hostgroup_add.json[0].members is defined or hostgroup_add.exception is defined