Dell服务器通过Ansible批量配置Raid0

  1. 安装Dell-Ansible
  2. playbook example
    1. inventory文件 hosts
    2. playbook文件 makeraid.yml
    3. 执行playbook
    4. 验证

安装Dell-Ansible

环境要求

Ansible >= 2.13.0
Python >= 3.9.6

pip install omsdk --upgrade

playbook example

这里给192.168.40.1(idrac地址10.10.16.121:443)新增的12块HDD盘配置raid0

inventory文件 hosts

[dell]
127.0.0.1

[dell:vars]
ansible_ssh_user='root'
ansible_ssh_port=22
ansible_ssh_pass='xxxxxxxxxxxx'
idrac_username='root'
idrac_password='xxxxxxxxxxxx'

playbook文件 makeraid.yml

## https://github.com/dell/dellemc-openmanage-ansible-modules/blob/collections/docs/modules/redfish_storage_volume.rst
- hosts: dell
  connection: local
  name: Conversion Disk To RAID0
  gather_facts: False

  tasks:
    - name: Create a volume with minimum options
      dellemc.openmanage.redfish_storage_volume:
        baseuri: "10.10.16.121:443"
        username: "{{ idrac_username }}"
        password: "{{ idrac_password }}"
        validate_certs: False
        state: "present"
        # 每个逻辑硬盘的磁盘名称
        name: "Virtual-Disk-{{ item|int - 1 }}"
        controller_id: "RAID.SL.3-1"
        volume_type: "NonRedundant"
        drives:
          # 待制作raid0物理盘名称
          - "Disk.Bay.{{ item }}:Enclosure.Internal.0-1:RAID.SL.3-1"
      # item范围从2-13,因为系统盘已经用磁盘0及磁盘1做了raid0了,待做raid的磁盘id就是2至13
      with_sequence: 2-13
      loop_control:
        # 每次硬盘制作raid任务等待2分钟,因为idrac上的raid任务只能单线程
        pause: 120
      tags:
        - convert-raid

执行playbook

ansible -i hosts makeraid.yml

验证

运行过程中及运行完成后,可以在idrac任务列表中查看制作结果


转载请注明来源, 欢迎对文章中的引用来源进行考证, 欢迎指出任何有错误或不够清晰的表达, 可以邮件至 chinaops666@gmail.com
相册