Hello,
Can someone help me understand why my ansible role fails when I try to add a host?
Here is my ansible role:
- name: Add host to icinga
community.general.icinga2_host:
validate_certs: no
url: "https://icinga"
url_username: "my-user"
url_password: "my-password"
state: present
name: "{{ ansible_fqdn }}"
ip: "{{ ansible_default_ipv4.address }}"
variables:
foo: "bar"
delegate_to: 127.0.0.1
Here is the error:
fatal: [hosttest01]: FAILED! => {
"changed": false,
"invocation": {
"module_args": {
"accept_config": true,
"address": "192.168.27.27",
"address6": null,
"append": null,
"check_command": null,
"check_interval": null,
"check_period": null,
"check_timeout": null,
"client_cert": null,
"client_key": null,
"command_endpoint": null,
"disabled": false,
"display_name": "hosttest01",
"enable_active_checks": null,
"enable_event_handler": null,
"enable_flapping": null,
"enable_notifications": null,
"enable_passive_checks": null,
"enable_perfdata": null,
"event_command": null,
"flapping_threshold_high": null,
"flapping_threshold_low": null,
"force": false,
"force_basic_auth": false,
"groups": [
"compute-linux-standard-servers",
"Security checks"
],
"has_agent": null,
"http_agent": "ansible-httpget",
"icon_image": null,
"icon_image_alt": null,
"imports": [
"compute-linux-host"
],
"master_should_connect": null,
"max_check_attempts": null,
"notes": null,
"notes_url": null,
"object_name": "hosttest01",
"retry_interval": null,
"state": "present",
"url": "https://192.168.27.28:5665/v1/objects/hosts/hosttest01",
"url_password": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER",
"url_username": "my-user",
"use_proxy": true,
"validate_certs": false,
"vars": null,
"volatile": null,
"zone": null
}
},
"msg": "bad return code while creating: 401. Error message: 401.0"
}
Thanks,
David