HMC & CMC

 View Only

Ansible Collection for Power HMC

By Navinakumar Kandakur posted 5 days ago

  


 The IBM® Power Hardware Management Console™ is rapidly evolving, with major advances being made across Power Systems.  In today’s Information Technology world, automation is of paramount importance to save time and increase efficiencies.

 In this blog, we are pleased to share the details of the Red Hat® Ansible® content for Power HMC, which includes the power_hmc collection and is now available in the open-source repository Ansible Galaxy and Red Hat’s Ansible Automation Platform® Ansible Automation Hub as a supported, certified collection by Red Hat.This is part of IBM’s continuous efforts to adapt HMC to the ever-evolving automation trends in the IT infrastructure administration landscape.

 Power HMC Ansible content helps administrators include Power HMC as part of their automation strategies through the Ansible ecosystem. Using Power HMC Ansible content in IT automation helps maintain a consistent and convenient management of multiple Power HMCs and Power servers.

 Power HMC Ansible content ‘ibm-power_hmc-1.5.0’ modules can be leveraged to do Power HMC patch management, Logical Partition management, Power Server management, password policy configurations and HMC-based Power systems dynamic inventory building.

 Here is a summary of modules currently supported. Check out the documentation and a detailed demo of each module which showcases them in action: 

  • hmc_update_upgrade: HMC patch management module can be used to perform update or upgrade of HMC.
  • powervm_lpar_instance: Logical partition management module helps with the creation, deletion, activate, and shutdown of logical partitions.
  • power_system: Power System management module can be used to power cycle the system, modify configurations, and modify resources.
  • powervm_lpar_migration: Logical partition migration module can be used to validate, and migrate logical partitions.
  • vios: Virtual IO Server module helps to create and install Virtual I/O Server.
  • hmc_command: This module can be used to run HMC commands. 
  • hmc_pwdpolicy: Password policy module is to manage the Power HMC password policy.
  • powervm_inventory: This is a dynamic inventory plugin which helps in dynamically building inventory of Power Systems and partitions connected to HMC.

Some of the use cases that can be realized with version 1.5.0 of the HMC collection are:

Patch management of HMC

 The patch management module, hmc_update_upgrade, is essentially designed to support all the update and upgrade requirements of HMC. The module supports the centralized fashion of patch management where IT administrators can keep upgrade files, service packs and security fixes in SFTP or FTP or NFS servers. The module also allows the HMC images to be kept on the Ansible control node and can be configured as the image source for patch management.

- name: Upgrade the HMC from 910 to 950
  hosts: hmcs
  collections:
      - ibm.power_hmc
  connection: local
  vars:
    curr_hmc_auth:
      username: <hmc_username>
      password: <hmc_password>

tasks:
  - name: Update the 910 HMC with 9.1.910.6 PTF
    hmc_update_upgrade:
        hmc_host: '{{ inventory_hostname }}'
        hmc_auth: '{{ curr_hmc_auth }}'
        build_config: 
        	location_type: ftp
        	hostname: <FTP_Server_IP>
        	userid: <FTP_Server_uname>
        	passwd: <FTP_Server_pwd>
        	build_file: HMC9.1.910.6/2010170040/x86_64/MH01857-9.1.910.6-2010170040-x86_64.iso 
        state: updated
        
  - name: Upgrade the 910 HMC with 950 image
    hmc_update_upgrade:
        hmc_host: '{{ inventory_hostname }}'
        hmc_auth: '{{ curr_hmc_auth }}'
        build_config:
		location_type: nfs
        	hostname: <NFS_Hostname/IP>
        	mount_location: <upgrade_img_mount_loc>
        	build_file: /HMC9.2.950.0/2010230054/x86_64/network_install
        state: upgraded

From the above snippet in a playbook, there are two tasks defined where hmc_update_upgrade module name is referred for each one of them. The first task takes care of updating the PTF image stored in FTP server on HMC running in 9.1.910 level and the second task upgrades the HMC to 9.2.950 level using an image stored in NFS server.

 To update an HMC the task state should be defined as updated and to upgrade an HMC task state should be defined as upgraded. Both states support NFS, FTP, SFTP and Disk (keeping the image in controller node) HMC image repositories.

Usage of dynamic inventory plugin along with HMC or AIX or IBM Collection to manage respective AIX or IBM i partitions 

 The dynamic inventory plugin, powervm_inventory, helps to collect the inventory of all available virtual machines in the public or private cloud infrastructure managed by HMC. This saves the administrator from maintaining a multitude of static inventory. This dynamic plugin facilitates the consolidation of the partitions into various groups and it can be further fine-tuned according to its property. That means you can now dynamically group and manage these partitions according to data center policy. An example use case can be  to apply specific patches only to a targeted version of AIX partition by using the respective group created by this dynamic inventory management plugin.

plugin: ibm.power_hmc.powervm_inventory
hmc_hosts:
  "<hmc_host_name>":
    user: <hmc_username>
    password: <hmc_password>
filters:
    PartitionState: 'running'
groups:
    AIX_72: "'7.2' in OperatingSystemVersion"

This playbook helps to dynamically create a group of all the running AIX partitions with OS version 7.2, and the same can be used as an inventory input to perform patching, OS upgrade etc.

Create / Power cycle / Delete of PowerVM partition

 The powervm_lpar_instance module part of the collection is equipped to create, manage, and delete the partitions through HMC. Currently create partition supports storage devices either through Virtual SCSI or NPIV,  virtual network via network bridge (shared Ethernet adapter) and Physical IO Adapters. 

 One example use case can be like the power cycle or deletion of multiple partitions across multiple servers using a simple playbook.  Another use case can be creating a partition with all the resources of the Power server.

- name: Create Logical Partition with All the resources
  hosts: hmcs
  collections:
      - ibm.power_hmc
  connection: local
  vars:
    curr_hmc_auth:
      username: <hmc_username>
      password: <hmc_password>

tasks:
  - name: Create logical partition with All resources
    powervm_lpar_instance:
      hmc_host: '{{ inventory_hostname }}'
      hmc_auth: "{{ curr_hmc_auth }}"
      system_name: <System_Name>
      vm_name: <Partition_Name>
      all_resource: true
      os_type: ibmi
      state: present

Delete of PowerVM partition using dynamic inventory plugin and powervm_lpar_instance module

 The combination of dynamic inventory plugin (powervm_inventory) and powervm_lpar_instance module can be used to delete a set of PowerVM partitions which belong to the specific group created by dynamic inventory plugin.

 One example is to create an unknowns group using dynamic inventory plugin which includes all the partitions which don’t contain RMC IPAddress (valid for AIX/Linux/VIOS) and in not running state (valid for IBM i) and injecting the same group of partitions to PowerVM partitions deletion playbook built using the powervm_lpar_instance module.

 Below is the dynamic inventory code snippet to create a group of partitions which are not in active running state, to be grouped as “unknowns” group.

plugin: ibm.power_hmc.powervm_inventory
hmc_hosts:
  "<hmc_host_name>":
    user: <hmc_username>
    password: <hmc_password>
identify_unknown_by: PartitionName
Below is the delete partition playbook code snippet to delete the PowerVM partitions belonging to “unknowns” group
- name: HMC delete partition
  hosts: unknowns
  collections:
      - ibm.power_hmc
  connection: local
  vars:
    curr_hmc_auth:
      username: <hmc_username>
      password: <hmc_password>

  tasks:
  - name: Delete logical partition along with VIOS disk mapping and associated vdisk
    powervm_lpar_instance:
      hmc_host: <hmcip>
      hmc_auth: "{{ curr_hmc_auth }}"
      system_name: <systemName>
      vm_name: '{{ inventory_hostname }}'
      retain_vios_cfg: False
      delete_vdisks: True
      state: absent

Power cycle/ change config/ change resource of power server

The Power System Management module power_system can power on, power off, change system configuration and change hardware resources of power systems through HMC. Currently this module supports changing system name and power off and on policy config change and configuring system memory region size .

          You can find an example playbook which powers off  the system to make configuration changes and then powers on the system here.

Provisioning of new bare metal Power server through migration of workloads from an existing Power server

This use case requires two modules from HMC collection as below

Provisioning of Virtual IO Server

 You can create many VIOSes using the “vios” module that has the ability to provide an end to end provisioning solution from creating a Virtual IO Server partition with user defined configurations, install Virtual IO Server using NIM Server and accept the License.

Validate and migrate PowerVM partitions

 From the existing Power Systems, you can pick the partitions that need to be migrated or all partitions to new Power server using powervm_lpar_migrate module. This module can validate, migrate and recover one or many partitions within or across the HMCs. 

 Below is an example of a playbook to provision a bare metal Power server which includes the series of task to create VIOS, installing VIOS, VIOS license accept and then migration of all the partitions from existing Power server to new Power server.

- name: Provision a new Power Server
  hosts: hmcs
  collections:
      - ibm.power_hmc
  connection: local
  vars:
    curr_hmc_auth:
      username: <hmc_username>
      password: <hmc_password>

tasks:
  - name: Create VIOS with user defined profile_name and io_slots
    vios:
      hmc_host: '{{ inventory_hostname }}'
      hmc_auth: "{{ curr_hmc_auth }}"
      system_name: <System_Name>
      name: <vios_Name>
      settings:
        profile_name: <>
        io_slots: 21010010/none/0,21010018/none/0
      state: present

  - name: Install VIOS through nim server
    vios:
      hmc_host: '{{ inventory_hostname }}'
      hmc_auth: "{{ curr_hmc_auth }}"
      system_name: <System_Name>
      name: <vios_Name>
      nim_IP: <NIM_Server_IP>
      nim_gateway: <Gateway_IP>
      vios_IP: <VIOS_IP>
      nim_subnetmask: <Subnetmask_IP>
      action: install

  - name: Accept VIOS License
    vios:
      hmc_host: '{{ inventory_hostname }}'
      hmc_auth: "{{ curr_hmc_auth }}"
      system_name: <System_Name>
      name: <VIOS_Name>
      action: accept_license

  - name: migrate all  partitions of the Managed System
    powervm_lpar_migration:
      hmc_host: '{{ inventory_hostname }}'
      hmc_auth: "{{ curr_hmc_auth }}"
      src_system: <Source_Managed_System>
      dest_system: <Destination_Managed_System>
      all_vms: true
      action: migrate

 In summary, power_hmc ansible collection provides a plethora of modules which can be used to automate Power Systems infrastructure actions and help in managing the infrastructure better as data centers scale up.

Contacting the PowerVM Team

Have questions for the PowerVM team or want to learn more?  Follow our discussion group on LinkedIn IBM PowerVM or IBM Community Discussions

 

0 comments
79 views

Permalink