fengjian
作者fengjian·2022-03-30 14:50
系统工程师·ips

使用Ansible HMC module完成 K1 Power分区迁移(LPM)

字数 2716阅读 1006评论 0赞 1

Ansible 是 Red Hat 赞助的一个开源社区项目,是实现 IT 自动化运维的最简单的方法,同时也是一种可以从系统运维人员到开发人员的跨整个 IT 团队使用的自动化语言。通过使用 Ansible 的自动化能力,能为系统管理员节省宝贵的时间,减轻运维负担的同时也降低了运维风险。目前, Ansible 已完全支持 K1 Power ,红帽在其官网及开源社区都发布了针对 K1 Power 平台的 Ansible 套件,包括可用于 AIX 、 IBM i 、 VIOS 、 HMC 的各种模块,

Ansible HMC collection 中的 powervm_lpar_migration 模块可以用来管理 K1 Power 的在线分区迁移功能,包括 Validate 和 Migrate 。以下是针对 HMC 的 powervm_lpar_migration 模块的测试。

测试示例如下:

1.安装 Ansible 、 python3 和 lxml (略)

2.使用 ansible-galaxy 安装 Ansible HMC collection

安装前查看 COLLECTIONS_PATHS

ansible-config dump | grep collections
COLLECTIONS_PATHS(default) = ['/.ansible/collections', '/usr/share/ansible/collections']

ansible-galaxy 默认使用第一路径,如果要安装到后面的目录,使用 -p 参数设置,安装命令如下

ansible-galaxy collection install --force ibm.power_hmc
Process install dependency map 
Starting collection install process 
Installing 'ibm.power_hmc:1.4.0' to '/.ansible/collections/ansible_collections/ibm/power_hmc'

当前 collection 版本 1.4.0 ,安装目录为 /.ansible/collections/ansible_collections/ibm/power_hmc

3.准备 playbook ,分别实现分区启停、创建分区、删除分区功能

使用 powervm_lpar_migration 进行分区检查和在线分区迁移,代码如下:**

- hosts: 
  - localhost

  tasks:

  - name: GET Partition Status
    ibm.power_hmc.powervm_lpar_instance:
      hmc_host: '172.16.100.23'
      hmc_auth:
         username: hscroot
         password: ********
      system_name: "{{ SRC }}"
      vm_name: aix_vmr-b1
      state: facts
    register: lpar_status

  - name: Print Partition State
    debug: msg="Partition AssociatedManagedSystem is {{ lpar_status.partition_info.AssociatedManagedSystem }}"

  - name: Validate that the input partitions can be migrated to the destination
    ibm.power_hmc.powervm_lpar_migration:
      hmc_host: '172.16.100.23'
      hmc_auth:
        username: hscroot
        password: ********
      src_system: "{{ SRC }}"
      dest_system: "{{ DESC }}"
      vm_names:
        - aix_vmr-b1
      action: validate

  - name: Migrate partitions to the destination
    ibm.power_hmc.powervm_lpar_migration:
      hmc_host: '172.16.100.23'
      hmc_auth:
        username: hscroot
        password: *********
      src_system: "{{ SRC }}"
      dest_system: "{{ DESC }}"
      vm_names:
        - aix_vmr-b1
      action: migrate

  - name: GET Partition Status
    ibm.power_hmc.powervm_lpar_instance:
      hmc_host: '172.16.100.23'
      hmc_auth:
         username: hscroot
         password: *********
      system_name: "{{ DESC }}"
      vm_name: aix_vmr-b1
      state: facts
    register: lpar_status

  - name: Print Partition State
    debug: msg="Partition AssociatedManagedSystem is {{ lpar_status.partition_info.AssociatedManagedSystem }}"

分区迁移执行结果:

ansible-playbook -e 'DESC="Power-S924-11-SN7874C30" SRC="K1-Power-S922-SN785DEE0"' ./hmc_migrate_lpar.yml

如果觉得我的文章对您有用,请点赞。您的支持将鼓励我继续创作!

1

添加新评论0 条评论

Ctrl+Enter 发表

作者其他文章

相关文章

相关问题

相关资料

X社区推广