Fatal error while creating a folder with Ansible

CMK version: 2.2.0p39
OS version: Appliance 1.1.17

Error message: fatal: [myhost → localhost]: FAILED! => {“changed”: false, “msg”: “412 - If-Match header doesn’t match the object’s ETag Details: b’{"title": "Precondition failed", "status": 412, "detail": "ETag didn\‘t match. Expected 79316f35a8c8198bc9f69ef0d6d927847a267b13dc851fabd106deb3aecc1bee. Probable cause: Object changed by another user."}’”}

My Ansible code:

- name: "Create folder Local Monitoring in main"
  checkmk.general.folder:
    server_url: "{{ checkmk_master_url }}"
    validate_certs: true
    site: "{{ checkmk_master_site }}"
    automation_user: "{{ checkmk_automation_user }}"
    automation_secret: "{{ __checkmk_automation_key }}"
    path: "/local_monitoring/"
    name: "Local Monitoring"
    attributes:
      site: "{{ checkmk_master_site }}"
    state: "present"
  delegate_to: localhost
  become: false
  notify: "Activate Changes"

The folder exist already. In our test system I dont get this error but on productive system. Could it be that its related to changes in subsequent folders?
How can I prevent this?

Any help is much appreciated

Thanks

Michael

Hi @mike1098, sorry for the late reply, I am watching the “ansible” tag, but that was not on your post (I added it now). :slight_smile:

Just from the looks of it, I would assume, that the folder itself was changed somehow. The error is not specific to the Ansible Collection, but should also happen on plain REST API calls. Is this a persistent error, or does it happen only transiently? If it is a persistent error: Can you reproduce the error directly through the API? Is it a specific folder, or all folders, or does it happen randomly?

Hi Robin, thanks for your questions. My colleague will do some test.
What I can tell it happens on the base folder of our tree which is never changed. Basically no on touches the properties of the folders. Folders only created via http API and in the future via Ansible (http API in the back of course) and after creation never touched.

regards

Michael