> For the complete documentation index, see [llms.txt](https://docs.ionos.com/cloud/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.ionos.com/cloud/ansible/tutorials/09__a_quick_introduction_to_dbaas/03__clean_up.yml.md).

# 03\_\_clean\_up.yml.md

The source files for this tutorial can be downloaded from its [GitHub repository](https://github.com/ionos-cloud/module-ansible/tree/master/docs/), or cloned into your current working directory using the command `git clone https://github.com/ionos-cloud/module-ansible.git` before changing into the `module-ansible/docs/tutorials/09__a_quick_introduction_to_dbaas` sub-directory.

{% code title="01\_\_create\_jumpbox\_and\_nlb.yml" overflow="wrap" lineNumbers="true" %}

```yml
---
- hosts: localhost
  connection: local
  gather_facts: false

  vars_files:
    - ../vars.yml
    - vars.yml

  


  tasks:
    # =======================================================================
    - name: Get information about 'Postgres Cluster for {{ datacenter_name }}'
      ionoscloudsdk.ionoscloud.postgres_cluster_info:
        filters: "{ 'properties.display_name': 'Postgres Cluster for {{ datacenter_name }}' }"
      register: postgres_clusters_response


    - name: Get information about 'MongoDB Cluster for {{ datacenter_name }}'
      ionoscloudsdk.ionoscloud.mongo_cluster_info:
        filters: "{ 'properties.display_name': 'MongoDB Cluster for {{ datacenter_name }}' }"
      register: mongo_clusters_response




    # =======================================================================
    - name: Wait for user confirmation
      ansible.builtin.pause:
        prompt: "About to delete '{{ datacenter_name }}' and all of its contents. Press <Enter> to proceed..."


    - name: Delete Postgres Cluster
      ionoscloudsdk.ionoscloud.postgres_cluster:
        postgres_cluster: "{{ postgres_clusters_response.postgres_clusters[0].id }}"
        state: absent

        wait: true
        wait_timeout: "{{ wait_timeout }}"
      when: postgres_clusters_response.postgres_clusters | length > 0


    - name: Delete MongoDB Cluster
      ionoscloudsdk.ionoscloud.mongo_cluster:
        mongo_cluster: "{{ mongo_clusters_response.mongo_clusters[0].id }}"
        state: absent

        wait: true
        wait_timeout: "{{ wait_timeout }}"
      when: mongo_clusters_response.mongo_clusters | length > 0




    - name: Pause for an additional 15 seconds
      ansible.builtin.pause:
        seconds: 15
        

    - name: Delete the datacenter '{{ datacenter_name }}' and everything contained therein
      ionoscloudsdk.ionoscloud.datacenter:
        datacenter: "{{ datacenter_name }}"
        state: absent


    - name: Delete the IP Block corresponding to this example
      ionoscloudsdk.ionoscloud.ipblock:
        name: "IP Block for {{ datacenter_name }}"
        state: absent
      when: ENABLE_EXPLICITLY_UNSUPPORTED_CONFIGURATIONS


    - name: And finally delete any 'temporary' or run-time files
      ansible.builtin.file:
        path: "{{ item }}"
        state: absent
      with_items:
        - ssh_config
        - ssh_known_hosts_tmp
        - temporary_id_rsa
        - temporary_id_rsa.pub

```

{% endcode %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.ionos.com/cloud/ansible/tutorials/09__a_quick_introduction_to_dbaas/03__clean_up.yml.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
