get server info
Get server hostname, private IP, public IP, private MAC address, public MAC address, service tag, os, model. put hardware.sls into /srv/salt/
run command:
salt '*' state.sls hardware | grep -A1 stdout | egrep -iv 'stdout|--'
or
salt 'minion_id' state.sls hardware | grep -A1 stdout | egrep -iv 'stdout|--'
or
salt -N group_name salt '*' state.sls hardware | grep -A1 stdout | egrep -iv 'stdout|--'Then you can copy and paste the output list to Excel.
{% if grains['os'] == 'Windows' %}
{% set macs = [] -%}
{% set ips = [] -%}
{% for ifname,ip in grains['ip4_interfaces'].iteritems() %}
{% do ips.insert(0,ip[0]) if ip[0].split('.')[0] == '10' -%}
{% do ips.append(ip[0]) if ip[0].split('.')[0] != '10' -%}
{% do macs.insert(0,grains['hwaddr_interfaces'][ifname]) if ip[0].split('.')[0] == '10' %}
{% do macs.append(grains['hwaddr_interfaces'][ifname]) if ip[0].split('.')[0] != '10' %}
{% endfor %}
echo {{ grains['nodename'] }} , {{ ips | join(' , ') }} , {{ macs | join(' , ') }} , {{ grains['serialnumber'] }} , {{ grains['osfullname'] }} , {{ grains['mem_total'] }} , {{ grains['productname'] }}:
cmd.run
{% endif %}
{% if grains['os'] == 'CentOS' %}
{% set macs = [] -%}
{% set ips = [] -%}
{% for ifname,ip in grains['ip4_interfaces'].iteritems() %}
{% if ifname == 'em1' or ifname == 'em2' %}
{% do ips.insert(0,ip[0]) if ip[0].split('.')[0] == '10' -%}
{% do ips.append(ip[0]) if ip[0].split('.')[0] != '10' -%}
{% do macs.insert(0,grains['hwaddr_interfaces'][ifname]) if ip[0].split('.')[0] == '10' %}
{% do macs.append(grains['hwaddr_interfaces'][ifname]) if ip[0].split('.')[0] != '10' %}
{% endif %}
{% endfor %}
echo {{ grains['nodename'] }} , {{ ips | join(' , ') }} , {{ macs | join(' , ') }} , {{ grains['serialnumber'] }} , {{ grains['osfullname'] }} , {{ grains['mem_total'] }} , {{ grains['productname'] }}:
cmd.run
{% endif %}Below is the command to get hardware spec:
Windows Server
Linux Server
get MAC address
get user info (win)
get user info (cent)
get machine type (cent)
Last updated