Ansible modules managing a IBM Z via the HMC Web Services API.
Project description
zhmc-ansible-modules - Ansible modules for the IBM Z HMC Web Services API
Moving to Ansible Galaxy
Starting with version 0.9.0, the zhmc Ansible modules are no longer distributed as the zhmc-ansible-modules package on Pypi, but as the ibm.ibm_zhmc collection on Galaxy.
Overview
The zhmc-ansible-modules Python package contains Ansible modules that can manage platform resources on IBM Z and LinuxONE machines that are in the Dynamic Partition Manager (DPM) operational mode.
The goal of this package is to be able to utilize the power and ease of use of Ansible for the management of IBM Z platform resources.
The IBM Z resources that can be managed include Partitions, HBAs, NICs, and Virtual Functions.
The Ansible modules in the zhmc-ansible-modules package are fully idempotent, following an important principle for Ansible modules.
The idempotency of a module allows Ansible playbooks to specify the desired end state for a resource, regardless of what the current state is. For example, a IBM Z partition can be specified to have state=active which means that it must exist and be in the active operational status. Depending on the current state of the partition, actions will be taken by the module to reach this desired end state: If the partition does not exist, it will be created and started. If it exists but is not active, it will be started. If it is already active, nothing will be done. Other initial states including transitional states such as starting or stopping also will be taken care of.
The idempotency of modules makes Ansible playbooks restartable: If an error happens and some things have been changed already, the playbook can simply be re-run and will automatically do the right thing, because the initial state does not matter for reaching the desired end state.
The Ansible modules in the zhmc-ansible-modules package are written in Python and interact with the Web Services API of the Hardware Management Console (HMC) of the machines to be managed, by using the API of the zhmcclient Python package.
Documentation
This version of the project has its documentation on RTD: http://zhmc-ansible-modules.readthedocs.io/en/stable/
Starting with version 0.9.0, the documentation is available on GitHub Pages: https://zhmcclient.github.io/zhmc-ansible-modules/
Playbook examples
Here are some examples for using the Ansible modules in this project:
Create a stopped partition
This task ensures that a partition with this name exists, is in the stopped status and has certain property values.
---
- hosts: localhost
tasks:
- name: Ensure a partition exists and is stopped
zhmc_partition:
hmc_host: "10.11.12.13"
hmc_auth: "{{ hmc_auth }}"
cpc_name: P000S67B
name: "my partition 1"
state: stopped
properties:
description: "zhmc Ansible modules: partition 1"
ifl_processors: 2
initial_memory: 1024
maximum_memory: 1024
minimum_ifl_processing_weight: 50
maximum_ifl_processing_weight: 800
initial_ifl_processing_weight: 200
... # all partition properties are supported
Start a partition
If this task is run after the previous one shown above, no properties need to be specified. If it is possible that the partition first needs to be created, then properties would be specified, as above.
---
- hosts: localhost
tasks:
- name: Ensure a partition exists and is active
zhmc_partition:
hmc_host: "10.11.12.13"
hmc_auth: "{{ hmc_auth }}"
cpc_name: P000S67B
name: "my partition 1"
state: active
properties:
... # see above
Delete a partition
This task ensures that a partition with this name does not exist. If it currently exists, it is stopped (if needed) and deleted.
---
- hosts: localhost
tasks:
- name: Ensure a partition does not exist
zhmc_partition:
hmc_host: "10.11.12.13"
hmc_auth: "{{ hmc_auth }}"
cpc_name: P000S67B
name: "my partition 1"
state: absent
Create an HBA in a partition
---
- hosts: localhost
tasks:
- name: Ensure HBA exists in the partition
zhmc_hba:
hmc_host: "10.11.12.13"
hmc_auth: "{{ hmc_auth }}"
cpc_name: P000S67B
partition_name: "my partition 1"
name: "hba 1"
state: present
properties:
adapter_name: "fcp 1"
adapter_port: 0
description: The HBA to our storage
device_number: "023F"
... # all HBA properties are supported
Create a NIC in a partition
---
- hosts: localhost
tasks:
- name: Ensure NIC exists in the partition
zhmc_nic:
hmc_host: "10.11.12.13"
hmc_auth: "{{ hmc_auth }}"
cpc_name: P000S67B
partition_name: "my partition 1"
name: "nic 1"
state: present
properties:
adapter_name: "osa 1"
adapter_port: 1
description: The NIC to our data network
device_number: "013F"
... # all NIC properties are supported
Create a Virtual Function in a partition
---
- hosts: localhost
tasks:
- name: Ensure virtual function for zEDC adapter exists in the partition
zhmc_virtual_function:
hmc_host: "10.11.12.13"
hmc_auth: "{{ hmc_auth }}"
cpc_name: P000S67B
partition_name: "my partition 1"
name: "vf 1"
state: present
properties:
adapter_name: "zedc 1"
description: The virtual function for our accelerator adapter
device_number: "043F"
... # all VF properties are supported
Configure partition for booting from FCP LUN
---
- hosts: localhost
tasks:
- name: Configure partition for booting via HBA
zhmc_partition:
hmc_host: "10.11.12.13"
hmc_auth: "{{ hmc_auth }}"
cpc_name: P000S67B
name: "my partition 1"
state: stopped
properties:
boot_device: storage-adapter
boot_storage_hba_name: "hba 1"
boot_logical_unit_number: "0001"
boot_world_wide_port_name: "00cdef01abcdef01"
Configure crypto config of a partition
---
- hosts: localhost
tasks:
- name: Ensure crypto config for partition
zhmc_partition:
hmc_host: "10.11.12.13"
hmc_auth: "{{ hmc_auth }}"
cpc_name: P000S67B
name: "my partition 1"
state: stopped
properties:
crypto_configuration:
crypto_adapter_names:
- "crypto 1"
crypto_domain_configurations:
- domain_index: 17
access_mode: "control-usage"
- domain_index: 19
access_mode: "control"
Quickstart
For installation instructions, see Installation of zhmc-ansible-modules package.
After having installed the zhmc-ansible-modules package, you can download and run the example playbooks in folder ‘playbooks’ of the Git repository:
create_partition.yml creates a partition with a NIC, HBA and virtual function to an accelerator adapter.
delete_partition.yml deletes a partition.
vars_example.yml is an example variable file defining variables such as CPC name, partition name, etc.
vault_example.yml is an example password vault file defining variables for authenticating with the HMC.
Before you run a playbook, copy vars_example.yml to vars.yml and vault_example.yml to vault.yml and change the variables in those files as needed.
Then, run the example playbooks:
$ 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
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file zhmc-ansible-modules-0.8.4.tar.gz
.
File metadata
- Download URL: zhmc-ansible-modules-0.8.4.tar.gz
- Upload date:
- Size: 123.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.54.0 CPython/3.9.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7f029af2834587d1256dbaad4ad3f1ff6e99064a1aa016c7a246cd766e1839a2 |
|
MD5 | 56013d75f0b9d27600b8f5bed4fbfb41 |
|
BLAKE2b-256 | 246a598394039f7f1461d3ccdec0218c57b621bee1c0e6b2c29933056c82a80d |
File details
Details for the file zhmc_ansible_modules-0.8.4-py2.py3-none-any.whl
.
File metadata
- Download URL: zhmc_ansible_modules-0.8.4-py2.py3-none-any.whl
- Upload date:
- Size: 82.8 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.54.0 CPython/3.9.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ed6027cde0d3a00838624e3372afd90ccd0ca29de67539c353fd73de47e9012f |
|
MD5 | d39eef6e019b1ed4d1538a7cc5696882 |
|
BLAKE2b-256 | 3f7d598c531d6d3735d73ea39e4b406bb42421e408b16dc2bd1476abf1b2a279 |