Home > Servers > Systems Management > White Papers > Dell PowerEdge: Getting Started with Redfish Ansible Modules > Getting PowerEdge server inventory
The redfish-ansible-module repository comes with a myriad of playbook examples to perform various tasks, such as getting the hardware inventory, power cycling, creating users, enabling lockdown mode, and so on.
Here is the playbook to get the complete inventory of a server:
---
- hosts: myhosts
connection: local
name: Inventory
gather_facts: False
vars:
ansible_python_interpreter: "/usr/bin/env python"
datatype: SystemAll
tasks:
- name: Set output file
include_tasks: create_output_file.yml
- name: Get Inventory
community.general.redfish_info:
category: Systems
command: all
baseuri: "{{ baseuri }}"
username: "{{ username}}"
password: "{{ password }}"
register: result
- name: Copy results to output file
ansible.builtin.copy:
content: "{{ result | to_nice_json }}"
dest: "{{ template }}.json"
This playbook proceeds as follows:
Running the ansible-playbook -i <inventory file> ./get_system_inventory_all.yml command creates the following output:
Looking at the output of the command, we can see that our inventory file contains two hosts: zeus1053 and zeus1054. The result of the command against zeus1053 is stored under the ~/inventory_files/zeus1053 in a file called zeus1053_SystemAll_<timestamp>.json. Similarly, the result for zeus1054 is stored under the ~/inventory_files/zeus1054 in a file called zeus1054_SystemAll_<timestamp>.json.
Each JSON file contains the complete hardware inventory of the server, including the part number of each memory DIMM, the component health status, and virtual disk information.