通过HMC Web Services API管理一个IBM Z模块。
zhmc-ansible-modules的Python项目详细描述
概述
zhmc ansible modules python包包含可以 管理中的IBM Z和LinuxONE计算机上的平台资源 动态分区管理器(DPM)操作模式。
此软件包的目标是能够利用电源和易用性 负责ibm z平台资源的管理。
可以管理的IBM Z资源包括分区、hba、NICs和 虚拟功能。
zhmc ansible modules包中的ansible模块是完全的 idempotent, 遵循一个重要的原则,负责模块。
模块的幂等性允许ansible playbooks指定所需的结束 资源的状态,不管当前状态是什么。例如,一个 可以指定IBM Z分区具有state=active,这意味着 它必须存在并处于活跃的运行状态。取决于电流 分区的状态,模块将采取操作来达到此状态 期望的结束状态:如果分区不存在,它将被创建 起动。如果它存在但不活动,它将启动。如果它已经 活动,什么都不做。其他初始状态,包括过渡 启动或停止等状态也将得到照顾。
模块的幂等性使得ansible playbooks可以重新启动:如果出现错误 发生了一些事情已经改变了,剧本可以简单地 重新运行并自动执行正确的操作,因为初始状态 达到所需的最终状态并不重要
zhmc ansible modules包中的ansible模块是用python编写的 并与硬件管理控制台(hmc)的web服务api交互 通过使用zhmcclientpython的api 包裹。
文件
本项目的完整文件在RTD上: http://zhmc-ansible-modules.readthedocs.io/en/stable/
行动手册示例
以下是在本项目中使用Ansible模块的一些示例:
创建一个停止的分区
此任务确保存在此名称的分区,处于停止状态 并具有一定的财产价值。
----hosts:localhosttasks:-name:Ensure a partition exists and is stoppedzhmc_partition:hmc_host:"10.11.12.13"hmc_auth:"{{hmc_auth}}"cpc_name:P000S67Bname:"mypartition1"state:stoppedproperties:description:"zhmcAnsiblemodules:partition1"ifl_processors:2initial_memory:1024maximum_memory:1024minimum_ifl_processing_weight:50maximum_ifl_processing_weight:800initial_ifl_processing_weight:200...# all partition properties are supported
启动分区
如果此任务在上面显示的上一个任务之后运行,则不需要属性 被指定。如果有可能首先需要创建分区, 然后指定属性,如上所述。
----hosts:localhosttasks:-name:Ensure a partition exists and is activezhmc_partition:hmc_host:"10.11.12.13"hmc_auth:"{{hmc_auth}}"cpc_name:P000S67Bname:"mypartition1"state:activeproperties:...# see above
删除分区
此任务确保不存在具有此名称的分区。如果它 当前存在,它被停止(如果需要)并被删除。
----hosts:localhosttasks:-name:Ensure a partition does not existzhmc_partition:hmc_host:"10.11.12.13"hmc_auth:"{{hmc_auth}}"cpc_name:P000S67Bname:"mypartition1"state:absent
在分区中创建一个hba
----hosts:localhosttasks:-name:Ensure HBA exists in the partitionzhmc_hba:hmc_host:"10.11.12.13"hmc_auth:"{{hmc_auth}}"cpc_name:P000S67Bpartition_name:"mypartition1"name:"hba1"state:presentproperties:adapter_name:"fcp1"adapter_port:0description:The HBA to our storagedevice_number:"023F"...# all HBA properties are supported
在分区中创建NIC
----hosts:localhosttasks:-name:Ensure NIC exists in the partitionzhmc_nic:hmc_host:"10.11.12.13"hmc_auth:"{{hmc_auth}}"cpc_name:P000S67Bpartition_name:"mypartition1"name:"nic1"state:presentproperties:adapter_name:"osa1"adapter_port:1description:The NIC to our data networkdevice_number:"013F"...# all NIC properties are supported
在分区中创建虚拟函数
----hosts:localhosttasks:-name:Ensure virtual function for zEDC adapter exists in the partitionzhmc_virtual_function:hmc_host:"10.11.12.13"hmc_auth:"{{hmc_auth}}"cpc_name:P000S67Bpartition_name:"mypartition1"name:"vf1"state:presentproperties:adapter_name:"zedc1"description:The virtual function for our accelerator adapterdevice_number:"043F"...# all VF properties are supported
配置从fcp lun启动的分区
----hosts:localhosttasks:-name:Configure partition for booting via HBAzhmc_partition:hmc_host:"10.11.12.13"hmc_auth:"{{hmc_auth}}"cpc_name:P000S67Bname:"mypartition1"state:stoppedproperties:boot_device:storage-adapterboot_storage_hba_name:"hba1"boot_logical_unit_number:"0001"boot_world_wide_port_name:"00cdef01abcdef01"
配置分区的加密配置
----hosts:localhosttasks:-name:Ensure crypto config for partitionzhmc_partition:hmc_host:"10.11.12.13"hmc_auth:"{{hmc_auth}}"cpc_name:P000S67Bname:"mypartition1"state:stoppedproperties:crypto_configuration:crypto_adapter_names:-"crypto1"crypto_domain_configurations:-domain_index:17access_mode:"control-usage"-domain_index:19access_mode:"control"
快速启动
有关安装说明,请参见Installation of zhmc-ansible-modules package。
在安装了zhmc ansible modules包之后,您可以下载并 在folder ‘playbooks’ of the Git repository:
中运行示例剧本- create_partition.yml创建一个带有NIC、HBA和virtual的分区 加速器适配器的功能
- delete_partition.yml删除一个分区。
- vars_example.yml是定义变量的示例变量文件,例如 CPC名称、分区名称等
- vault_example.yml是定义变量的密码保管库文件示例 用于通过hmc进行身份验证。
在运行剧本之前,将vars_example.yml复制到vars.yml并 vault_example.yml到vault.yml并更改这些文件中的变量 根据需要。
然后,运行示例剧本:
$ ansible-playbook create_partition.yml PLAY [localhost] ********************************************************** TASK [Gathering Facts] **************************************************** ok: [127.0.0.1] TASK [Ensure partition exists and is stopped] ***************************** changed: [127.0.0.1] TASK [Ensure HBA exists in the partition] ********************************* changed: [127.0.0.1] TASK [Ensure NIC exists in the partition] ********************************* changed: [127.0.0.1] TASK [Ensure virtual function exists in the partition] ******************** changed: [127.0.0.1] TASK [Configure partition for booting via HBA] **************************** changed: [127.0.0.1] PLAY RECAP **************************************************************** 127.0.0.1 : ok=6 changed=5 unreachable=0 failed=0 $ ansible-playbook delete_partition.yml PLAY [localhost] ********************************************************** TASK [Gathering Facts] **************************************************** ok: [127.0.0.1] TASK [Ensure partition does not exist] ************************************ changed: [127.0.0.1] PLAY RECAP **************************************************************** 127.0.0.1 : ok=2 changed=1 unreachable=0 failed=0