Dell provide an Ansible module to query IDRAC. You can use this to get information on the server. The example below fetches the tag.
pip3 install ansible ansible-lint
ansible-galaxy collection install git+https://github.com/dell/dellemc-openmanage-ansible-modules.git,collections
pip3 install omsdk --upgrade
---
- hosts: localhost
tasks:
- name: Get System Inventory
dellemc.openmanage.idrac_system_info:
idrac_ip: "192.168.0.1"
idrac_user: "admin"
idrac_password: "admin"
validate_certs: false
register: system_info
- name: Debug output
debug:
msg: "{{ system_info.system_info.System[0].ServiceTag }}"
ansible-playbook idrac.yaml