HTTP 405 Error when running ansible role checkmk.general.agent

CMK version: 2.2.0p21.cme
OS version: RHEL9

Error message:

RUNNING HANDLER [checkmk.general.agent : Activate changes] **********************************************************************************************************************************************************************
task path:xxx/ansible_collections/checkmk/general/roles/agent/handlers/main.yml:2
fatal: [rhel9-host-2 -> localhost]: FAILED! => {"changed": false, "msg": "405 - This request is only allowed with other HTTP methods Details: b'{\"title\": \"Method Not Allowed\", \"status\": 405, \"detail\": \"405 Method Not Allowed: The method is not allowed for the requested URL.\"}'"}

Im trying to provision a new VM with the checkmk Ansible role. Everything seems to be working (fetching and installing agent, creating host) until the role tries to activate the changes. Then we get a 405 Method not allowed Error.

If i then Log into the WebUI, the host that was supposedly create is not there, and there are no changes to activate.

Does anyone have an idea what i am doing wrong?

heres the ansible play:

- name: run checkmk general agent role
  hosts: checkmk
  tags: checkmk
  collections:
    - checkmk.general
  roles:
    - agent
  vars:
    checkmk_agent_version: "2.2.0p21"
    checkmk_agent_edition: "cme"
    checkmk_agent_user: "automation"
    checkmk_agent_secret: "xxx"
    checkmk_agent_protocol: https
    checkmk_agent_server: xxx.xxx.xxx.xxx
    checkmk_agent_site: "xxx"
    checkmk_agent_update: 'true'
    checkmk_agent_tls: 'true'
    checkmk_agent_auto_activate: 'true'
    checkmk_agent_add_host: 'true'
    checkmk_agent_discover: 'true'
    checkmk_agent_host_name: "{{inventory_hostname}}"
    checkmk_agent_host_ip: "{{ hostvars[inventory_hostname]['ansible_default_ipv4']['address'] }}"
    checkmk_agent_folder: "/site/path/to/folder"
    checkmk_agent_configure_firewall: 'false'
    checkmk_agent_host_attributes:
        ipaddress: "{{ checkmk_agent_host_ip | default(omit) }}"

and here the final two task with debug output

TASK [checkmk.general.agent : Linux: Create host on server.] ********************************************************************************************************************************************************************
task path:xxx/ansible_collections/checkmk/general/roles/agent/tasks/Linux.yml:54

Notification for handler Activate changes has been saved.
changed: [rhel9-host-2 -> localhost] => {
    "changed": true,
    "failed_when_result": false,
    "invocation": {
        "module_args": {
            "add_nodes": null,
            "attributes": {
                "ipaddress": "xxx.xxx.xxx.xxx"
            },
            "automation_secret": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER",
            "automation_user": "automation",
            "extended_functionality": true,
            "folder": "/site/path/to/folder",
            "name": "rhel9-host-2",
            "nodes": null,
            "remove_attributes": null,
            "remove_nodes": null,
            "server_url": "http://xxx:80/",
            "site": "site",
            "state": "present",
            "update_attributes": null,
            "validate_certs": true
        }
    },
    "msg": "200 - Host created"
}

TASK [checkmk.general.agent : Trigger activation of changes.] *******************************************************************************************************************************************************************
task path: xxx/ansible_collections/checkmk/general/roles/agent/tasks/Linux.yml:77
NOTIFIED HANDLER checkmk.general.agent : Activate changes for rhel9-host-2
META: triggered running handlers for rhel9-host-2

RUNNING HANDLER [checkmk.general.agent : Activate changes] **********************************************************************************************************************************************************************
task path:xxx/ansible_collections/checkmk/general/roles/agent/handlers/main.yml:2
fatal: [rhel9-host-2 -> localhost]: FAILED! => {
    "changed": false,
    "invocation": {
        "module_args": {
            "automation_secret": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER",
            "automation_user": "automation",
            "force_foreign_changes": false,
            "redirect": true,
            "server_url": "http://xxx:80/",
            "site": "site",
            "sites": [],
            "validate_certs": true
        }
    },
    "msg": "405 - This request is only allowed with other HTTP methods Details: b'{\"title\": \"Method Not Allowed\", \"status\": 405, \"detail\": \"405 Method Not Allowed: The method is not allowed for the requested URL.\"}'"
}

Are you talking to your central site, or a remote site?

We are talking to the Central Site

The error was caused by a wrong VAR in the play:

checkmk_agent_protocol: https

should have been

checkmk_agent_server_protocol: https

though i cannot fathom why that would cause this error

1 Like

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed. Contact an admin if you think this should be re-opened.