0

Can anyone help me with the error deleting obsolete replication agents using the aem_agent module (https://github.com/lean-delivery/ansible-modules-aem/blob/master/aem_agent.py)?

I face an error:

"msg": "failed to delete agent: 405 - "

Here is a task:

- name: Remove dispatcher flush agents
  aem_agent:
    name: "{{ obsolete_dispatcher }}"
    state: absent
    folder: 'agents.publish'
    admin_user: '{{ admin_login }}'
    admin_password: '{{ admin_password }}'
    host: 'http://localhost'
    port: '4502'

From the error.log:

XX.XX.XXXX XX:XX:XX.XXX *ERROR* [127.0.0.1 [XXXXXXXXXXXXX] DELETE /etc/replication/agents.publish/ip-XX-XX-XXX-XXX-XX-XXXX-X-compute-internal-dispatcher HTTP/1.1] org.apache.sling.servlets.resolver.internal.SlingServletResolver handleError: Recursive invocation. Not further handling status 405(Method DELETE not supported)

fireman777
  • 134
  • 1
  • 15
  • From the parameter description in the source file, I suspect `host` is expecting only a hostname without a scheme `http://localhost` => `localhost`. If this does not fix your issue and without any further details on a so confidential custom module, I'm afraid no one here will be able to help you. Your best chance is probably to add an issue directly on the github repository you linked above. – Zeitounator Mar 01 '21 at 16:25
  • Thanks for the reply. Looks like it can't deleted: Method DELETE not supported – fireman777 Mar 01 '21 at 17:13
  • I tried to delete **https://** but it throws an error. – fireman777 Mar 02 '21 at 08:30

2 Answers2

1

The HTTP DELETE method isn't supported when you disable the WebDav bundles per the security checklist. You can either re-enable WebDAV or modify the code in the Ansible aemagent project to delete using the Sling POST servlet instead. The request would be a POST with parameter ":operation=delete" to the path.

For examples, see the Sling documentation.

Andrew Khoury
  • 408
  • 3
  • 9
  • Thanks for the reply. I've tried to activate bundle **org.apache.sling.jcr.webdav** but it didn't help, unfortunately. – fireman777 Mar 01 '21 at 19:29
  • 2
    Updating the code helped me. So, I 1) changed the request method from delete => post and 2) added data : **{':operation': 'delete'}**. It works for me. Thank you, Andrew Khoury, very much! – fireman777 Mar 02 '21 at 10:39
0

As was advised, I modified a code (delete_agent function). Changes:

  1. request method from delete => post
  2. added data to the request: {':operation': 'delete'}
  3. also, I've created PR to add these changes in the code.

It works for me. Thank you, Andrew Khoury, very much!

fireman777
  • 134
  • 1
  • 15