Re: API not working as expected in Ansible
Posted: Thu Aug 08, 2019 1:59 pm
I had broken out the creation of the user because I thought that maybe I had to have it existing BEFORE applying config but that was only a test and I forgot to restore the check back. Sorry for the confusion!
I re-read your ansible config and I must have looked at it 10 times and COMPLETELY MISSED the command vs contact! That was the issue!
Looks like it works well now!
Now that it is working I have 2 related followup questions if you could assist.
1. the documentation shows adding a user looking like this:
But I think it should look like this:
Can you confirm?
2. Is there a way to check to see if the API call was successful and update to "changed" if I see a "success" to the API call? Unless it totally bombs, I am not sure if it worked or not unless I check it in the GUI. I was hoping you may have an example.
Thanks!
I re-read your ansible config and I must have looked at it 10 times and COMPLETELY MISSED the command vs contact! That was the issue!
Looks like it works well now!
Now that it is working I have 2 related followup questions if you could assist.
1. the documentation shows adding a user looking like this:
Code: Select all
- name: Add sns_critical user to OnShoreITNotificationGroup contact group in Nagios XI
uri:
url: http://{{ ansible_host }}/nagiosxi/api/v1/config/contactgroup/testcontactgroup?apikey={{ NagiosAPIKey }}&pretty=1&contactgroup_name=OnshoreITNotificationGroup&members=sns_critical
method: PUT
validate_certs: no
timeout: 30Code: Select all
- name: Add sns_critical user to OnShoreITNotificationGroup contact group in Nagios XI
uri:
url: http://{{ ansible_host }}/nagiosxi/api/v1/config/contactgroup/testcontactgroup?apikey={{ NagiosAPIKey }}&pretty=1
body: contactgroup_name=OnshoreITNotificationGroup&members=sns_critical
method: PUT
validate_certs: no
timeout: 302. Is there a way to check to see if the API call was successful and update to "changed" if I see a "success" to the API call? Unless it totally bombs, I am not sure if it worked or not unless I check it in the GUI. I was hoping you may have an example.
Thanks!