ansible+redfish+idrac管理DELL服务器

背景描述

  Drac(Dell Remote Access Controlle)戴尔远程远程访问控制是访问DELL服务器管理的一款很好的平台。基于WEB界面访问,可以友好的查看服务器的硬件资源,同时利用虚拟控制台可以模拟终端访问操作系统。但是如何批量的管理就成了一个问题。为此DELL开发了基于Redfish APIs的外带OOB的ansible模块。

于是利用redfish通过OOB-controller就可以不用通过web方式获取到服务器相关信息,甚至做一些修改操作,同时利用ansible的特性完成批量管理

运行实现

运行实现的过程如下图

ansible+redfish+idrac管理DELL服务器

完成的功能

  1. Inventory: Manages system inventory
  2. Update: Manages system firmware
  3. System: Manages power and BIOS settings
  4. Chassis: Manages the system chassis
  5. Manager: Manages OOB controller settings
    6.Accounts: Manages OOB controller users

实现前的依赖

DELL服务器

DELL服务器配最小化的iDRAC 7/8/9 固件版本要在2.40.40.40以上

可以在DRAC概述中查看,如下是不符合的
ansible+redfish+idrac管理DELL服务器

要想实现这个功能就是要升级固件,
方法是首先在DELL官方下载固件,然后IDrac设置-更新和回滚-更新上传文件路径,上载即可
ansible+redfish+idrac管理DELL服务器
升级期间有一个等待的过程,根据经验不会中断系统的运行。关于升级固件,可能会在另一篇文章中描述

这个就是升级后达到条件的服务器了
ansible+redfish+idrac管理DELL服务器

有人可能会有疑问,为什么要升级固件?其实升级固件除了修改安全漏洞外,本次的目标就是增加redfish

你可以在网络-服务中看到增加了Redfish模块,如下截图
ansible+redfish+idrac管理DELL服务器
同时要保证开启了该模块
ansible+redfish+idrac管理DELL服务器

Redfish(红鱼)简介 是一种标准API,旨在为融合的混合IT和软件定义数据中心(SDDC)提供简单安全的管理。Redfish兼具人类可读性和机器能力,利用通用的Internet和Web服务标准将信息直接暴露给现代工具链。

好吧,看上貌似蛮概念化的,你可以理解为就是一个借口就行。

控制端准备

  1. 在一台系统上安装ansible(过程略)
  2. 该系统可以访问idrac

    只要网络层可以通信即可,不是真要用浏览器去登录idrac

  3. 安装 redfish-ansible-module
    1、git clone https://github.com/dell/redfish-ansible-module.git
    2、cd redfish-ansible-module/
    3、python install.py 

    准备工作完成

实操前的准备

因为play-books已经是现成的,所以在ansible的hosts做一下配置,格式大致如下

[myhosts]
# hostname OOB controller IP/NAME
webserver1 baseuri=192.168.0.101
webserver2 baseuri=192.168.0.102
dbserver1 baseuri=192.168.0.103

oob controller IP 一开始我也有点迷糊,实际上就是idrac地址,idrac默认地址是192.168.0.120,根据你实际的idrac地址进行配置即可

正式操作

以上准备工作完成以后就可以正式测试使用了,进入到redfish-ansible-module/playbooks 目录后可以看到已经完成的playbooks剧本了
ansible+redfish+idrac管理DELL服务器

我们先执行一个get_disk_inventory.yml 看看

ansible-playbook get_disk_inventory.yml

哇哦,我相信你会报如下错误的
TASK [Get disk inventory] *****
Thursday 05 July 2018 09:06:44 +0800 (0:00:00.322) 0:00:00.515 *

fatal: [webserver1]: FAILED! => {"changed": false, "msg": "HTTP Error: 401"}

401错误是什么鬼? 还记得上面的图吧?因为使用了OOB就是idrac地址,所以ansible不是利用SSH去执行的,而是利用redfish接口,所以我们要像登录WEB一样加上idrac用户名和密码的参数 -e 就可以了

ansible-playbook get_disk_inventory.yml -e "user=root password=123456"

请根据自己实际情况填写用户名和密码

输出的结果大致如下

PLAY [Get disk inventory] *************************************************************************************************************

TASK [Define output file] *************************************************************************************************************
Thursday 05 July 2018  09:11:57 +0800 (0:00:00.063)       0:00:00.063 ********* 
included: /root/redfish-ansible-module/playbooks/create_output_file.yml for webserver1

TASK [Define timestamp] ***************************************************************************************************************
Thursday 05 July 2018  09:11:57 +0800 (0:00:00.025)       0:00:00.088 ********* 
ok: [webserver1]

TASK [Define file to place results] ***************************************************************************************************
Thursday 05 July 2018  09:11:57 +0800 (0:00:00.053)       0:00:00.141 ********* 
ok: [webserver1]

TASK [Create dropoff directory for host] **********************************************************************************************
Thursday 05 July 2018  09:11:57 +0800 (0:00:00.035)       0:00:00.177 ********* 
ok: [webserver1]

TASK [Get disk inventory] *************************************************************************************************************
Thursday 05 July 2018  09:11:57 +0800 (0:00:00.281)       0:00:00.458 ********* 
ok: [webserver1]

TASK [Copy results to output file] ****************************************************************************************************
Thursday 05 July 2018  09:12:05 +0800 (0:00:07.865)       0:00:08.324 ********* 
changed: [webserver1]

PLAY RECAP ****************************************************************************************************************************
webserver1                 : ok=6    changed=1    unreachable=0    failed=0   

Thursday 05 July 2018  09:12:05 +0800 (0:00:00.532)       0:00:08.857 ********* 
=============================================================================== 
Get disk inventory ------------------------------------------------------------------------------------------------------------- 7.87s
Copy results to output file ---------------------------------------------------------------------------------------------------- 0.53s
Create dropoff directory for host ---------------------------------------------------------------------------------------------- 0.28s
Define timestamp --------------------------------------------------------------------------------------------------------------- 0.05s
Define file to place results --------------------------------------------------------------------------------------------------- 0.04s
Define output file ------------------------------------------------------------------------------------------------------------- 0.03s

你的可能和我的有点不太一样,但是我们看到任务全部是OK的,这时候会在

<rootdir>/webserver1 生成一个json
ansible+redfish+idrac管理DELL服务器

大致内容如下:
ansible+redfish+idrac管理DELL服务器

我们甚至可以通过jq工具过滤出想要的字段,简单例子如下
ansible+redfish+idrac管理DELL服务器

猜你喜欢

转载自blog.51cto.com/z00w00/2136380