生成硬件报告

    生成硬件报告

    创建一个名为 /home/curtis/ansible/hwreport.yml 的 playbook ,它将在所有受管节点上生成含有以下信息的输出文件 /root/hwreport.txt :

        清单主机名称

        以 MB 表示的总内存大小

        BIOS 版本

        磁盘设备 vda 的大小

        磁盘设备 vdb 的大小

        输出文件中的每一行含有一个 key=value 对。

    您的 playbook 应当:

        从 http://rhgls.area12.example.com/materials/hwreport.empty 下载文件,并将它保存为 /root/hwreport.txt

        使用正确的值改为 /root/hwreport.txt

        如果硬件项不存在,相关的值应设为 NONE

 

wget http://rhgls.area12.example.com/materials/hwreport.empty
cat hwreport.empty

vim hwreport.yml 
- hosts: all
  tasks:
          - get_url:
                  url: http://rhgls.area12.example.com/materials/hwreport.empty
                  dest: /root/hwreport.txt
          - replace:
                  path: /root/hwreport.txt
                  regexp: inventoryhostname
                  replace: "{{ ansible_hostname | default (none)}}"
          - replace:
                  path: /root/hwreport.txt
                  regexp: memory_in_MB
                  replace: "{{ ansible_memtotal_mb | default (none)}}"
          - replace:
                  path: /root/hwreport.txt
                  regexp: BIOS_version
                  replace: "{{ ansible_bios_version | default (none)}}"
          - replace:
                  path: /root/hwreport.txt
                  regexp: disk_vda_size
                  replace: "{{ ansible_devices.vda.size | default (none)}}"
          - replace:
                  path: /root/hwreport.txt
                  regexp: disk_vdb_size
                  replace: "{{ ansible_devices.vdb.size | default (none)}}"

 

 

ansible-playbook hwreport.yml

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

编程浪漫史

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值