关于使用Ansible配置戴尔服务器AC电源恢复为开启状态的技术咨询
关于使用Ansible配置戴尔服务器AC电源恢复为开启状态的技术咨询
你好,我明白你在配置戴尔服务器AC电源恢复时遇到的困扰——确实,早期版本的dellemc.openmanage集合里没有直接提供配置AC电源恢复的专用模块,而redfish_powerstate只能执行单次的电源状态操作,没法设置断电后自动恢复的持久策略。不过我们可以通过Ansible的redfish_config模块来实现这个需求,它能直接修改服务器BIOS里的电源恢复设置,让配置持久生效。
具体实现步骤:
1. 确认依赖环境
- 确保你的Ansible环境已经安装了
community.general集合(redfish_config属于这个集合),如果没安装可以用这条命令安装:ansible-galaxy collection install community.general - 确保目标戴尔服务器已经启用了Redfish API,并且你拥有管理员级别的访问权限。
2. 查询准确的BIOS属性名(可选但推荐)
不同型号的戴尔服务器,AC电源恢复对应的BIOS属性名可能略有差异,你可以先用redfish_info模块查询确认:
- name: 查询服务器BIOS属性,确认AC电源恢复的参数名 hosts: dell_servers gather_facts: false tasks: - name: 获取BIOS属性列表 community.general.redfish_info: baseuri: "{{ server_redfish_uri }}" # 示例:https://192.168.1.100 username: "{{ redfish_username }}" password: "{{ redfish_password }}" category: Systems command: GetBiosAttributes register: bios_attributes - name: 打印BIOS属性,查看AC电源恢复相关参数 debug: var: bios_attributes.redfish_firmware.bios_attributes
通常戴尔服务器里这个参数是AcPowerRecovery,可能的值包括On(断电恢复后自动开机)、Off(保持关机)、Last(恢复到断电前的状态)。
3. 编写Playbook配置AC电源恢复为On
确认参数名后,用redfish_config模块修改BIOS设置:
- name: 配置戴尔服务器AC电源恢复为自动开机状态 hosts: dell_servers gather_facts: false tasks: - name: 设置AC电源恢复属性为On community.general.redfish_config: baseuri: "{{ server_redfish_uri }}" username: "{{ redfish_username }}" password: "{{ redfish_password }}" category: Systems command: SetBiosAttributes bios_attributes: AcPowerRecovery: "On" # 请与你查询到的参数名保持一致 register: config_result - name: 打印配置结果 debug: var: config_result
补充说明
- 配置完成后,服务器需要重启才能让BIOS设置生效,你可以在playbook里追加
redfish_powerstate模块来触发重启(如果业务允许的话)。 - 如果你使用的是戴尔OpenManage Enterprise (OME),也可以考虑用
dellemc.openmanage.ome_server_profile模块来配置服务器配置文件,但Redfish的方式更通用,无需依赖OME服务器。
备注:内容来源于stack exchange,提问作者chyzhykio
相关产品推荐
相关产品推荐

