Browse Source

fix: 主机硬件信息硬盘大小避免多次挂载重复计入

pull/13662/head
mmagi 5 months ago committed by Bryan
parent
commit
60f7cbef9a
  1. 7
      apps/assets/automations/gather_facts/host/posix/main.yml

7
apps/assets/automations/gather_facts/host/posix/main.yml

@ -12,7 +12,12 @@
cpu_cores: "{{ ansible_processor_cores }}"
cpu_vcpus: "{{ ansible_processor_vcpus }}"
memory: "{{ ansible_memtotal_mb / 1024 | round(2) }}"
disk_total: "{{ (ansible_mounts | map(attribute='size_total') | sum / 1024 / 1024 / 1024) | round(2) }}"
disk_total: |-
{% set ns = namespace(total=0) %}
{%- for name, dev in ansible_devices.items() if dev.removable == '0' and dev.host != '' -%}
{%- set ns.total = ns.total + ( dev.sectors | int * dev.sectorsize | int ) -%}
{%- endfor -%}
{{- (ns.total / 1024 / 1024 / 1024) | round(2) -}}
distribution: "{{ ansible_distribution }}"
distribution_version: "{{ ansible_distribution_version }}"
arch: "{{ ansible_architecture }}"

Loading…
Cancel
Save