---
- name: Dell OpenManage Ansible iDRAC Session Management.
  hosts: idrac
  gather_facts: false

  tasks:
    - name: Create a session
      dellemc.openmanage.idrac_session:
        hostname: 198.162.0.1
        username: username
        password: password
        state: present
      register: session
      delegate_to: localhost

    - name: Delete a session
      dellemc.openmanage.idrac_session:
        hostname: 198.162.0.1
        state: absent
        auth_token: "{{ session.x_auth_token }}"
        session_id: "{{ session.session_data.Id }}"
      delegate_to: localhost
