---
- name: Dell OpenManage Ansible device operations.
  hosts: ome
  gather_facts: false

  tasks:
    - name: Refresh Inventory
      dellemc.openmanage.ome_devices:
        hostname: "{{ hostname }}"
        username: "{{ username }}"
        password: "{{ password }}"
        ca_path: "/path/to/ca_cert.pem"
        device_action: refresh_inventory
        device_service_tags:
          - 2HB7NX2
      delegate_to: localhost

    - name: Clear iDRAC job queue
      dellemc.openmanage.ome_devices:
        hostname: "{{ hostname }}"
        username: "{{ username }}"
        password: "{{ password }}"
        ca_path: "/path/to/ca_cert.pem"
        device_action: clear_idrac_job_queue
        device_service_tags:
          - 2HB7NX2
      delegate_to: localhost

    - name: Reset iDRAC using the service tag
      dellemc.openmanage.ome_devices:
        hostname: "{{ hostname }}"
        username: "{{ username }}"
        password: "{{ password }}"
        ca_path: "/path/to/ca_cert.pem"
        device_action: reset_idrac
        device_service_tags:
          - 2H7HNX2
      delegate_to: localhost

    - name: Remove devices using servicetags
      dellemc.openmanage.ome_devices:
        hostname: "{{ hostname }}"
        username: "{{ username }}"
        password: "{{ password }}"
        ca_path: "/path/to/ca_cert.pem"
        state: absent
        device_service_tags:
          - SVCTAG1
          - SVCTAF2
      delegate_to: localhost

    - name: Remove devices using IDs
      dellemc.openmanage.ome_devices:
        hostname: "{{ hostname }}"
        username: "{{ username }}"
        password: "{{ password }}"
        ca_path: "/path/to/ca_cert.pem"
        state: absent
        device_ids:
          - 10235
      delegate_to: localhost
