From f3cdab31dfdf2daa0287aeae732cc14b4f04898e Mon Sep 17 00:00:00 2001 From: Andreas Maier Date: Thu, 22 Jun 2023 13:13:49 +0200 Subject: [PATCH] zhmc: Restructured sample playbooks Details: * Restructured the sample playbooks as follows: - Renamed them so that the resource they work on appears first in the file name, and then the action. This orders them in the directory listing in a more meaningful way. - Changed the variable that selects the inventory entry from 'host' to 'hmc'. - Removed the 'cpc_name' variable from the vault file, since it is different for any HMC anyway, and it is easier to understand if it does not appear defined by magic. The CPC is now defined in each playbook with the 'cpc' variable and thus can be overridden from the command line with '-e cpc=mycpc'. - Simplified the variable names that specify resource names to remove '_name' for easier use with the '-e' option. - Added 'gather_facts: no' to the playbooks. - Added a zhmc log file 'zhmc.log' to the playbooks. * Simplifications in the inventory and vault files: - Added the 'verify' variable to the example vault file. - Removed 'ansible_connection: local' from the example inventory file since it is not needed, when the tasks specify 'delegate_to: local'. - Improved the documentation in the example inventory and vault files. * Major improvements in the z_systems_administration/zhmc/README.md file that documents how to use the sample playbooks. Signed-off-by: Andreas Maier --- z_systems_administration/zhmc/README.md | 234 ++++++++---------- .../zhmc/playbooks/README.md | 3 + .../zhmc/playbooks/inventory_example.yml | 12 +- .../zhmc/playbooks/module_adapter_facts.yml | 35 +++ .../zhmc/playbooks/module_adapter_rename.yml | 38 +++ .../zhmc/playbooks/module_adapter_set.yml | 38 +++ .../playbooks/module_attach_crypto_any.yml | 30 --- .../playbooks/module_attach_crypto_byname.yml | 31 --- .../playbooks/module_attach_storage_group.yml | 28 --- .../zhmc/playbooks/module_cpc_facts.yml | 33 +++ .../zhmc/playbooks/module_cpc_set.yml | 36 +++ .../module_create_hipersockets_adapter.yml | 29 --- .../playbooks/module_create_partition.yml | 34 --- .../playbooks/module_create_storage_group.yml | 33 --- .../module_create_storage_volume.yml | 31 --- .../playbooks/module_crypto_attach_any.yml | 39 +++ .../playbooks/module_crypto_attach_byname.yml | 40 +++ .../module_crypto_attachment_facts.yml | 35 +++ .../zhmc/playbooks/module_crypto_detach.yml | 35 +++ .../module_delete_hipersockets_adapter.yml | 26 -- .../playbooks/module_delete_partition.yml | 26 -- .../playbooks/module_delete_storage_group.yml | 26 -- .../module_delete_storage_volume.yml | 28 --- .../zhmc/playbooks/module_detach_crypto.yml | 26 -- .../playbooks/module_detach_storage_group.yml | 28 --- .../zhmc/playbooks/module_facts_adapter.yml | 26 -- .../zhmc/playbooks/module_facts_cpc.yml | 23 -- .../module_facts_crypto_attachment.yml | 26 -- .../zhmc/playbooks/module_facts_partition.yml | 26 -- .../playbooks/module_facts_storage_group.yml | 28 --- .../module_facts_storage_group_attachment.yml | 28 --- .../playbooks/module_facts_storage_volume.yml | 28 --- .../zhmc/playbooks/module_facts_user.yml | 26 -- .../playbooks/module_hipersockets_create.yml | 38 +++ .../playbooks/module_hipersockets_delete.yml | 35 +++ .../playbooks/module_partition_create.yml | 43 ++++ .../playbooks/module_partition_delete.yml | 35 +++ .../zhmc/playbooks/module_partition_facts.yml | 35 +++ .../zhmc/playbooks/module_rename_adapter.yml | 29 --- .../zhmc/playbooks/module_set_adapter.yml | 28 --- .../zhmc/playbooks/module_set_cpc.yml | 25 -- .../playbooks/module_storagegroup_attach.yml | 37 +++ .../module_storagegroup_attachment_facts.yml | 37 +++ .../playbooks/module_storagegroup_create.yml | 42 ++++ .../playbooks/module_storagegroup_delete.yml | 35 +++ .../playbooks/module_storagegroup_detach.yml | 37 +++ .../playbooks/module_storagegroup_facts.yml | 36 +++ .../playbooks/module_storagevolume_create.yml | 40 +++ .../playbooks/module_storagevolume_delete.yml | 37 +++ .../playbooks/module_storagevolume_facts.yml | 37 +++ .../zhmc/playbooks/module_user_facts.yml | 34 +++ .../zhmc/playbooks/vault_example.yml | 8 +- 52 files changed, 1009 insertions(+), 804 deletions(-) create mode 100644 z_systems_administration/zhmc/playbooks/module_adapter_facts.yml create mode 100644 z_systems_administration/zhmc/playbooks/module_adapter_rename.yml create mode 100644 z_systems_administration/zhmc/playbooks/module_adapter_set.yml delete mode 100644 z_systems_administration/zhmc/playbooks/module_attach_crypto_any.yml delete mode 100644 z_systems_administration/zhmc/playbooks/module_attach_crypto_byname.yml delete mode 100644 z_systems_administration/zhmc/playbooks/module_attach_storage_group.yml create mode 100644 z_systems_administration/zhmc/playbooks/module_cpc_facts.yml create mode 100644 z_systems_administration/zhmc/playbooks/module_cpc_set.yml delete mode 100644 z_systems_administration/zhmc/playbooks/module_create_hipersockets_adapter.yml delete mode 100644 z_systems_administration/zhmc/playbooks/module_create_partition.yml delete mode 100644 z_systems_administration/zhmc/playbooks/module_create_storage_group.yml delete mode 100644 z_systems_administration/zhmc/playbooks/module_create_storage_volume.yml create mode 100644 z_systems_administration/zhmc/playbooks/module_crypto_attach_any.yml create mode 100644 z_systems_administration/zhmc/playbooks/module_crypto_attach_byname.yml create mode 100644 z_systems_administration/zhmc/playbooks/module_crypto_attachment_facts.yml create mode 100644 z_systems_administration/zhmc/playbooks/module_crypto_detach.yml delete mode 100644 z_systems_administration/zhmc/playbooks/module_delete_hipersockets_adapter.yml delete mode 100644 z_systems_administration/zhmc/playbooks/module_delete_partition.yml delete mode 100644 z_systems_administration/zhmc/playbooks/module_delete_storage_group.yml delete mode 100644 z_systems_administration/zhmc/playbooks/module_delete_storage_volume.yml delete mode 100644 z_systems_administration/zhmc/playbooks/module_detach_crypto.yml delete mode 100644 z_systems_administration/zhmc/playbooks/module_detach_storage_group.yml delete mode 100644 z_systems_administration/zhmc/playbooks/module_facts_adapter.yml delete mode 100644 z_systems_administration/zhmc/playbooks/module_facts_cpc.yml delete mode 100644 z_systems_administration/zhmc/playbooks/module_facts_crypto_attachment.yml delete mode 100644 z_systems_administration/zhmc/playbooks/module_facts_partition.yml delete mode 100644 z_systems_administration/zhmc/playbooks/module_facts_storage_group.yml delete mode 100644 z_systems_administration/zhmc/playbooks/module_facts_storage_group_attachment.yml delete mode 100644 z_systems_administration/zhmc/playbooks/module_facts_storage_volume.yml delete mode 100644 z_systems_administration/zhmc/playbooks/module_facts_user.yml create mode 100644 z_systems_administration/zhmc/playbooks/module_hipersockets_create.yml create mode 100644 z_systems_administration/zhmc/playbooks/module_hipersockets_delete.yml create mode 100644 z_systems_administration/zhmc/playbooks/module_partition_create.yml create mode 100644 z_systems_administration/zhmc/playbooks/module_partition_delete.yml create mode 100644 z_systems_administration/zhmc/playbooks/module_partition_facts.yml delete mode 100644 z_systems_administration/zhmc/playbooks/module_rename_adapter.yml delete mode 100644 z_systems_administration/zhmc/playbooks/module_set_adapter.yml delete mode 100644 z_systems_administration/zhmc/playbooks/module_set_cpc.yml create mode 100644 z_systems_administration/zhmc/playbooks/module_storagegroup_attach.yml create mode 100644 z_systems_administration/zhmc/playbooks/module_storagegroup_attachment_facts.yml create mode 100644 z_systems_administration/zhmc/playbooks/module_storagegroup_create.yml create mode 100644 z_systems_administration/zhmc/playbooks/module_storagegroup_delete.yml create mode 100644 z_systems_administration/zhmc/playbooks/module_storagegroup_detach.yml create mode 100644 z_systems_administration/zhmc/playbooks/module_storagegroup_facts.yml create mode 100644 z_systems_administration/zhmc/playbooks/module_storagevolume_create.yml create mode 100644 z_systems_administration/zhmc/playbooks/module_storagevolume_delete.yml create mode 100644 z_systems_administration/zhmc/playbooks/module_storagevolume_facts.yml create mode 100644 z_systems_administration/zhmc/playbooks/module_user_facts.yml diff --git a/z_systems_administration/zhmc/README.md b/z_systems_administration/zhmc/README.md index 8ba07dca2..160e5aa37 100644 --- a/z_systems_administration/zhmc/README.md +++ b/z_systems_administration/zhmc/README.md @@ -12,26 +12,41 @@ to clone this Git repository to your local system. The sample playbooks for the IBM Z HMC Collection are located in the directory ``z_systems_administration/zhmc/playbooks`` of the cloned repository. -## Creating a vault file +The sample playbooks make use of an inventory file and a vault file that are +briefly described in the next sections. -The sample playbooks use a vault file named ``vault.yml`` that defines -HMC authentication data and other variables that are used in the sample playbooks. +## Creating an inventory file -In order to ensure that the vault file used by developers of this repository -is not stored in the repository by mistake, the ``vault.yml`` file is excluded -from Git, and the playbook directory contains an example copy of that file under -the name: +The sample playbooks of the IBM Z HMC Collection are designed to run with an +Ansible inventory file that specifies the HMCs to run against. -* ``vault_example.yml`` +The format of Ansible inventory files is described in the Ansible documentation +in section +[Inventory basics: formats, hosts, and groups](https://docs.ansible.com/ansible/latest/inventory_guide/intro_inventory.html#inventory-basics-formats-hosts-and-groups) and allows +many flexibilities. -To use the sample playbooks for the IBM Z HMC Collection, you need to copy that -file to ``vault.yml`` and adjust the content of the copy as needed. +The following data structure in the inventory file is sufficient for purposes +of the sample playbooks: -## Creating an inventory file +``` +--- +default: # A group nickname -The sample playbooks are designed to run with a certain sample host group in -order to show how running against multiple HMCs can be achieved. That requires -using an inventory file that defines that host group. + hosts: + + myhmc13: # An HMC nickname (must match the nickname in the vault file) + ansible_host: 10.11.12.13 + + # ... more HMC entries for this group, as needed + +# ... more groups, as needed +``` + +The sample playbooks by default run against the HMCs defined in the group named +``default``. They can run against any other group or single HMC by setting the +``hmc`` variable to the nickname of the group or HMC. This can be done for +example by using the ``-e hmc=nickname`` option of the ``ansible-playbook`` +command. In order to ensure that the inventory file used by developers of this repository is not stored in the repository by mistake, the ``inventory.yml`` file is excluded @@ -41,24 +56,81 @@ the name: * ``inventory_example.yml`` To use the sample playbooks for the IBM Z HMC Collection, you need to copy that -file to ``inventory.yml`` and adjust the content of the copy as needed. +example inventory file to e.g. ``inventory.yml`` and and adjust its content to +your HMC environment. + +## Creating a vault file + +The sample playbooks of the IBM Z HMC Collection use a vault file named +``vault.yml`` that defines credentials for the HMCs you want to use the sample +playbooks with. + +From an Ansible perspective, the vault file is just a YAML file with arbitrary +content that is included into the playbooks with the ``vars_files`` directive. + +The sample playbooks assume the following data structure in the vault file: + +``` +--- +hmc_auth: + + myhmc13: # An HMC nickname (must match the nickname in the inventory file) + userid: myuserid + password: mypassword + verify: false # optional, only if you need to disable certificate validation + + # ... more HMC entries, as needed +``` + +The vault file can store multiple entries for HMCs that are identified with a +nickname. Each HMC entry specifies HMC userid and password to use. Optionally, +validation of the server certificate can be disabled using ``verify: false``. + +In order to ensure that the vault file used by developers of this repository +is not stored in the repository by mistake, the ``vault.yml`` file is excluded +from Git, and the playbook directory contains an example vault file: + +* ``vault_example.yml`` + +To use the sample playbooks for the IBM Z HMC Collection, you need to copy that +example vault file to ``vault.yml`` and adjust its content to your HMC +environment. + +You can encrypt the vault file using the ``ansible-vault`` command, and if you +do, you either need to specify the ``--ask-vault-password`` option when +running the playbooks using the ``ansible-playbook`` command, or use a vault +password file (see Ansible documentation). ## Running the playbooks -To run any of the sample playbooks, it is recommended to first look at them and -to adjust any parameters as documented in the playbook files. +To run any of the sample playbooks of the IBM Z HMC Collection, it is +recommended to first look at them and to adjust any parameters as documented in +the playbook files. You use the [ansible-playbook](https://docs.ansible.com/ansible/latest/cli/ansible-playbook.html) -command to run playbooks. - -Since the sample playbooks are designed to run with a certain sample host group, -the inventory file needs to be specified in the command, e.g.: +command to run playbooks: ``` $ ansible-playbook -i inventory.yml playbook.yml ``` +You can set variables or override variables defined in the playbook by using +the ``-e name=value`` option. For example, the following command sets the ``hmc`` +variable to an HMC nickname ``myhmc42`` defined in the inventory file (and vault +file) to run the playbook against that specific HMC: + +``` +$ ansible-playbook -i inventory.yml -e hmc=myhmc42 playbook.yml +``` + +If you have encrypted the vault file, you can have Ansible prompt for the +vault password by using the ``--ask-vault-password`` option: + +``` +$ ansible-playbook -i inventory.yml --ask-vault-password playbook.yml +``` + ## Sample playbooks The sample playbooks whose filename starts with ``module_`` are very simple @@ -77,109 +149,17 @@ Ansible must be configured to run the HMC related tasks of the playbook on the control node (= local host), from where the zhmc modules then connect to the HMC based on their input parameters. -There are multiple ways how this can be achieved in Ansible. The sample playbooks -are designed to use delegation to localhost in the zhmc tasks. The key elements -in that design are: - -* There is an inventory file that specifies a host group with the HMCs to target, - where each HMC has its IP addresses (or hostnames) defined and specifies that - the connection to that HMC is local, e.g.: - - File ``inventory.yml``: - - ``` - my_hmc_list: # name of the host group - hosts: - myhmc13: # Ansible name for the HMC - ansible_host: 10.11.12.13 # IP address or hostname of the HMC - ansible_connection: local # connection is local (for this host, on all playbook tasks) - ``` - -* There is a vault file that specifies the authentication data for each HMC, - using the same Ansible names for the HMCs as defined in the inventory file, - e.g.: - - File ``vault.yml``: - - ``` - hmc_auth: - myhmc13: # Ansible name for the HMC - userid: myuserid - password: mypassword - verify: false - ``` - -* The playbook references the host group defined in the inventory file, - loads the variables from the vault file, delegates each zhmc task to localhost, - and uses magic Ansible variables for obtaining the HMC IP address and - HMC authentication data, e.g.: - - File ``module_facts_cpc.yml``: - - ``` - - hosts: - - my_hmc_list # references the host group defined in the inventory file - vars_files: - - vault.yml # loads the variables from the vault file - vars: - cpc_name: CPCA - collections: - - ibm.ibm_zhmc - tasks: - - name: "Get facts for CPC {{ cpc_name }}" - delegate_to: localhost # delegates this task to run on localhost - zhmc_cpc: - hmc_host: "{{ ansible_host }}" # uses Ansible magic variable for HMC IP address - hmc_auth: "{{ hmc_auth[inventory_hostname] }}" # uses Ansible magic variable for HMC auth.data - name: "{{ cpc_name }}" - state: facts - ``` - -The examples above show how the sample playbooks are designed. There are -alternative ways to define the HMC hosts, the HMC authentication data, and -to ensure that the Ansible tasks run locally on the control node. - -One alternative approach is not to use an Ansible inventory and to define -only a single HMC to work with, and local connection for all tasks of the -playbook: - -* The vault file specifies the IP address / hostname of the HMC and the - authentication data for the HMC, e.g.: - - File ``alternative_vault.yml``: - - ``` - hmc_host: 10.11.12.13 - hmc_auth: - userid: myuserid - password: mypassword - verify: false - ``` - -* The playbook defines only localhost as a host, and defines the connection - to be local for the entire playbook. Non-zhmc tasks that need to run on - a specific other host can still do that by using the Ansible ``delegate_to`` - attribute, but the host will be a single host and not defined by an inventory. - - The playbook uses variables defined in the vault file for obtaining the HMC - IP address and HMC authentication data, e.g.: - - File ``alternative_module_facts_cpc.yml``: - - ``` - - hosts: localhost # runs all tasks on localhost - connection: local # connection is local for all tasks - vars_files: - - alternative_vault.yml # loads the variables from the vault file - vars: - cpc_name: CPCA - collections: - - ibm.ibm_zhmc - tasks: - - name: "Get facts for CPC {{ cpc_name }}" - zhmc_cpc: - hmc_host: "{{ hmc_host }}" # uses variable from vault file - hmc_auth: "{{ hmc_auth }}" # uses variable from vault file - name: "{{ cpc_name }}" - state: facts - ``` +The sample playbooks are designed to use delegation to localhost in the zhmc +tasks, for example: + +``` +- . . . + tasks: + - name: "Get facts for CPC {{ cpc }}" + delegate_to: localhost # <-- delegates this task to run on localhost + zhmc_cpc: + hmc_host: "{{ ansible_host }}" + hmc_auth: "{{ hmc_auth[inventory_hostname] }}" + name: "{{ cpc }}" + state: facts +``` diff --git a/z_systems_administration/zhmc/playbooks/README.md b/z_systems_administration/zhmc/playbooks/README.md index 1d84deb08..c577ce67b 100644 --- a/z_systems_administration/zhmc/playbooks/README.md +++ b/z_systems_administration/zhmc/playbooks/README.md @@ -8,3 +8,6 @@ and implement a particular use case. * [single module playbooks](../docs/module_playbooks.md) * [use case playbooks](../docs/usecase_playbooks.md) + +For more documentation, see +[Samples for the IBM Z HMC Collection](https://github.com/IBM/z_ansible_collections_samples/tree/main/z_systems_administration/zhmc). diff --git a/z_systems_administration/zhmc/playbooks/inventory_example.yml b/z_systems_administration/zhmc/playbooks/inventory_example.yml index cb249ffa6..52e462528 100644 --- a/z_systems_administration/zhmc/playbooks/inventory_example.yml +++ b/z_systems_administration/zhmc/playbooks/inventory_example.yml @@ -1,9 +1,13 @@ --- # inventory.yml file for the sample playbooks of the IBM Z HMC Collection -# The HMC inventory the sample playbooks will use: -my_hmc_list: +default: # A group nickname + hosts: - myhmc13: # must match the key name in the vault file + + myhmc13: # An HMC nickname (must match the nickname in the vault file) ansible_host: 10.11.12.13 - ansible_connection: local # defaults connection=local for this host on all playbook tasks + + # ... more HMC entries for this group, as needed + +# ... more groups, as needed diff --git a/z_systems_administration/zhmc/playbooks/module_adapter_facts.yml b/z_systems_administration/zhmc/playbooks/module_adapter_facts.yml new file mode 100644 index 000000000..8523260dd --- /dev/null +++ b/z_systems_administration/zhmc/playbooks/module_adapter_facts.yml @@ -0,0 +1,35 @@ +--- +# Sample playbook for the zhmc_adapter module of the ibm.ibm_zhmc collection: +# +# Get facts for an adapter +# +# Command to run this playbook: +# ansible-playbook -i inventory.yml -e hmc={myhmc} -e cpc={mycpc} -e adapter={myadapter} module_adapter_facts.yml + +- hosts: + - "{{ hmc | default('default') }}" # HMC nickname from inventory entry + gather_facts: no + vars_files: + - vault.yml + vars: + cpc: MYCPC # Adjust or override with -e option + adapter: sample-hs-1 # Adjust or override with -e option + log_file: zhmc.log + collections: + - ibm.ibm_zhmc + tasks: + + - name: "Get facts for adapter {{ adapter }} on CPC {{ cpc }}" + delegate_to: localhost + zhmc_adapter: + hmc_host: "{{ ansible_host }}" + hmc_auth: "{{ hmc_auth[inventory_hostname] }}" + cpc_name: "{{ hmc_auth[inventory_hostname] }}" + name: "{{ adapter }}" + state: facts + log_file: "{{ log_file | default(omit) }}" + register: result + + - name: Print the result + ansible.builtin.debug: + var: result diff --git a/z_systems_administration/zhmc/playbooks/module_adapter_rename.yml b/z_systems_administration/zhmc/playbooks/module_adapter_rename.yml new file mode 100644 index 000000000..3fbade1c3 --- /dev/null +++ b/z_systems_administration/zhmc/playbooks/module_adapter_rename.yml @@ -0,0 +1,38 @@ +--- +# Sample playbook for the zhmc_adapter module of the ibm.ibm_zhmc collection: +# +# Rename an adapter +# +# Command to run this playbook: +# ansible-playbook -i inventory.yml -e hmc={myhmc} -e cpc={mycpc} -e adapter_id={myid} -e new_adapter_name={mynewname} module_adapter_rename.yml + +- hosts: + - "{{ hmc | default('default') }}" # HMC nickname from inventory entry + gather_facts: no + vars_files: + - vault.yml + vars: + cpc: MYCPC # Adjust or override with -e option + adapter_id: '7c3' # Adjust or override with -e option + new_adapter_name: sample-hs-1 # Adjust or override with -e option + log_file: zhmc.log + collections: + - ibm.ibm_zhmc + tasks: + + - name: "Ensure adapter with PCHID {{ adapter_id }} has name {{ new_adapter_name }}" + delegate_to: localhost + zhmc_adapter: + hmc_host: "{{ ansible_host }}" + hmc_auth: "{{ hmc_auth[inventory_hostname] }}" + cpc_name: "{{ cpc }}" + name: "{{ new_adapter_name }}" + match: + adapter_id: "{{ adapter_id }}" + state: set + log_file: "{{ log_file | default(omit) }}" + register: result + + - name: Print the result + ansible.builtin.debug: + var: result diff --git a/z_systems_administration/zhmc/playbooks/module_adapter_set.yml b/z_systems_administration/zhmc/playbooks/module_adapter_set.yml new file mode 100644 index 000000000..79ab04a79 --- /dev/null +++ b/z_systems_administration/zhmc/playbooks/module_adapter_set.yml @@ -0,0 +1,38 @@ +--- +# Sample playbook for the zhmc_adapter module of the ibm.ibm_zhmc collection: +# +# Set a property (here: description) of an adapter +# +# Command to run this playbook: +# ansible-playbook -i inventory.yml -e hmc={myhmc} -e cpc={mycpc} -e adapter={myadapter} -e new_desc="{mydesc}" module_adapter_set.yml + +- hosts: + - "{{ hmc | default('default') }}" # HMC nickname from inventory entry + gather_facts: no + vars_files: + - vault.yml + vars: + cpc: MYCPC # Adjust or override with -e option + adapter: sample-hs-1 # Adjust or override with -e option + new_desc: "Changed description of adapter {{ adapter }}" # Adjust or override with -e option + log_file: zhmc.log + collections: + - ibm.ibm_zhmc + tasks: + + - name: "Ensure adapter {{ adapter }} has the desired description" + delegate_to: localhost + zhmc_adapter: + hmc_host: "{{ ansible_host }}" + hmc_auth: "{{ hmc_auth[inventory_hostname] }}" + cpc_name: "{{ cpc }}" + name: "{{ adapter }}" + state: set + properties: + description: "{{ new_desc }}" + log_file: "{{ log_file | default(omit) }}" + register: result + + - name: Print the result + ansible.builtin.debug: + var: result diff --git a/z_systems_administration/zhmc/playbooks/module_attach_crypto_any.yml b/z_systems_administration/zhmc/playbooks/module_attach_crypto_any.yml deleted file mode 100644 index 8b446eb8e..000000000 --- a/z_systems_administration/zhmc/playbooks/module_attach_crypto_any.yml +++ /dev/null @@ -1,30 +0,0 @@ ---- -# Sample module-level playbook of the IBM Z HMC Collection - -- hosts: - - my_hmc_list - vars_files: - - vault.yml - vars: - partition_name: sample-part-1 - collections: - - ibm.ibm_zhmc - tasks: - - - name: "Ensure domains 2..max on 2 arbitrary adapters are attached to partition {{ partition_name }}" - delegate_to: localhost - zhmc_crypto_attachment: - hmc_host: "{{ hmc_host }}" - hmc_auth: "{{ hmc_auth }}" - cpc_name: "{{ cpc_name }}" - partition_name: "{{ partition_name }}" - state: attached - crypto_type: ep11 - adapter_count: 2 - domain_range: 2,-1 - access_mode: usage - register: result - - - name: Print the result‚ - ansible.builtin.debug: - var: result diff --git a/z_systems_administration/zhmc/playbooks/module_attach_crypto_byname.yml b/z_systems_administration/zhmc/playbooks/module_attach_crypto_byname.yml deleted file mode 100644 index 4db892975..000000000 --- a/z_systems_administration/zhmc/playbooks/module_attach_crypto_byname.yml +++ /dev/null @@ -1,31 +0,0 @@ ---- -# Sample module-level playbook of the IBM Z HMC Collection - -- hosts: - - my_hmc_list - vars_files: - - vault.yml - vars: - partition_name: sample-part-1 - crypto_adapters: [CRYP00, CRYP01] - collections: - - ibm.ibm_zhmc - tasks: - - - name: "Ensure domains 2..max on crypto adapters {{ crypto_adapters }} are attached to partition {{ partition_name }}" - delegate_to: localhost - zhmc_crypto_attachment: - hmc_host: "{{ ansible_host }}" - hmc_auth: "{{ hmc_auth[inventory_hostname] }}" - cpc_name: "{{ cpc_name }}" - partition_name: "{{ partition_name }}" - state: attached - crypto_type: ep11 - adapter_names: "{{ crypto_adapters }}" - domain_range: 2,-1 - access_mode: usage - register: result - - - name: Print the result - ansible.builtin.debug: - var: result diff --git a/z_systems_administration/zhmc/playbooks/module_attach_storage_group.yml b/z_systems_administration/zhmc/playbooks/module_attach_storage_group.yml deleted file mode 100644 index b7b0eff45..000000000 --- a/z_systems_administration/zhmc/playbooks/module_attach_storage_group.yml +++ /dev/null @@ -1,28 +0,0 @@ ---- -# Sample module-level playbook of the IBM Z HMC Collection - -- hosts: - - my_hmc_list - vars_files: - - vault.yml - vars: - partition_name: sample-part-1 - stogroup_name: sample-sg-1 - collections: - - ibm.ibm_zhmc - tasks: - - - name: "Ensure storage group {{ stogroup_name }} is attached to partition {{ partition_name }}" - delegate_to: localhost - zhmc_storage_group_attachment: - hmc_host: "{{ ansible_host }}" - hmc_auth: "{{ hmc_auth[inventory_hostname] }}" - cpc_name: "{{ cpc_name }}" - storage_group_name: "{{ stogroup_name }}" - partition_name: "{{ partition_name }}" - state: attached - register: result - - - name: Print the result - ansible.builtin.debug: - var: result diff --git a/z_systems_administration/zhmc/playbooks/module_cpc_facts.yml b/z_systems_administration/zhmc/playbooks/module_cpc_facts.yml new file mode 100644 index 000000000..dc88fa1dd --- /dev/null +++ b/z_systems_administration/zhmc/playbooks/module_cpc_facts.yml @@ -0,0 +1,33 @@ +--- +# Sample playbook for the zhmc_cpc module of the ibm.ibm_zhmc collection: +# +# Get facts for a CPC +# +# Command to run this playbook: +# ansible-playbook -i inventory.yml -e hmc={myhmc} -e cpc={mycpc} module_cpc_facts.yml + +- hosts: + - "{{ hmc | default('default') }}" # HMC nickname from inventory entry + gather_facts: no + vars_files: + - vault.yml + vars: + cpc: MYCPC # Adjust or override with -e option + log_file: zhmc.log + collections: + - ibm.ibm_zhmc + tasks: + + - name: "Get facts for CPC {{ cpc }}" + delegate_to: localhost + zhmc_cpc: + hmc_host: "{{ ansible_host }}" + hmc_auth: "{{ hmc_auth[inventory_hostname] }}" + name: "{{ cpc }}" + state: facts + log_file: "{{ log_file | default(omit) }}" + register: result + + - name: Print the result + ansible.builtin.debug: + var: result diff --git a/z_systems_administration/zhmc/playbooks/module_cpc_set.yml b/z_systems_administration/zhmc/playbooks/module_cpc_set.yml new file mode 100644 index 000000000..06552adf8 --- /dev/null +++ b/z_systems_administration/zhmc/playbooks/module_cpc_set.yml @@ -0,0 +1,36 @@ +--- +# Sample playbook for the zhmc_cpc module of the ibm.ibm_zhmc collection: +# +# Set properties (here: description) of a CPC +# +# Command to run this playbook: +# ansible-playbook -i inventory.yml -e hmc={myhmc} -e cpc={mycpc} -e new_desc="{mydesc}" module_cpc_set.yml + +- hosts: + - "{{ hmc | default('default') }}" # HMC nickname from inventory entry + gather_facts: no + vars_files: + - vault.yml + vars: + cpc: MYCPC # Adjust or override with -e option + new_desc: "Changed description of CPC {{ cpc }}" # Adjust or override with -e option + log_file: zhmc.log + collections: + - ibm.ibm_zhmc + tasks: + + - name: "Ensure CPC {{ cpc }} has the desired description" + delegate_to: localhost + zhmc_cpc: + hmc_host: "{{ ansible_host }}" + hmc_auth: "{{ hmc_auth[inventory_hostname] }}" + name: "{{ cpc }}" + state: set + properties: + description: "{{ new_desc }}" + log_file: "{{ log_file | default(omit) }}" + register: result + + - name: Print the result + ansible.builtin.debug: + var: result diff --git a/z_systems_administration/zhmc/playbooks/module_create_hipersockets_adapter.yml b/z_systems_administration/zhmc/playbooks/module_create_hipersockets_adapter.yml deleted file mode 100644 index 8c1113305..000000000 --- a/z_systems_administration/zhmc/playbooks/module_create_hipersockets_adapter.yml +++ /dev/null @@ -1,29 +0,0 @@ ---- -# Sample module-level playbook of the IBM Z HMC Collection - -- hosts: - - my_hmc_list - vars_files: - - vault.yml - vars: - hs_adapter_name: sample-hs-1 - collections: - - ibm.ibm_zhmc - tasks: - - - name: "Ensure a Hipersockets adapter {{ hs_adapter_name }} exists and has the desired property values" - delegate_to: localhost - zhmc_adapter: - hmc_host: "{{ ansible_host }}" - hmc_auth: "{{ hmc_auth[inventory_hostname] }}" - cpc_name: "{{ cpc_name }}" - name: "{{ hs_adapter_name }}" - state: present - properties: - type: hipersockets - description: "This is Hipersockets adapter {{ hs_adapter_name }}" - register: result - - - name: Print the result - ansible.builtin.debug: - var: result diff --git a/z_systems_administration/zhmc/playbooks/module_create_partition.yml b/z_systems_administration/zhmc/playbooks/module_create_partition.yml deleted file mode 100644 index d327a6457..000000000 --- a/z_systems_administration/zhmc/playbooks/module_create_partition.yml +++ /dev/null @@ -1,34 +0,0 @@ ---- -# Sample module-level playbook of the IBM Z HMC Collection - -- hosts: - - my_hmc_list - vars_files: - - vault.yml - vars: - partition_name: sample-part-1 - collections: - - ibm.ibm_zhmc - tasks: - - - name: "Ensure partition {{ partition_name }} exists and is stopped" - delegate_to: localhost - zhmc_partition: - hmc_host: "{{ ansible_host }}" - hmc_auth: "{{ hmc_auth[inventory_hostname] }}" - cpc_name: "{{ cpc_name }}" - name: "{{ partition_name }}" - state: stopped - properties: - description: "This is partition {{ partition_name }}" - ifl_processors: 2 - initial_memory: 1024 - maximum_memory: 1024 - minimum_ifl_processing_weight: 50 - maximum_ifl_processing_weight: 800 - initial_ifl_processing_weight: 200 - register: result - - - name: Print the result - ansible.builtin.debug: - var: result diff --git a/z_systems_administration/zhmc/playbooks/module_create_storage_group.yml b/z_systems_administration/zhmc/playbooks/module_create_storage_group.yml deleted file mode 100644 index c38a96337..000000000 --- a/z_systems_administration/zhmc/playbooks/module_create_storage_group.yml +++ /dev/null @@ -1,33 +0,0 @@ ---- -# Sample module-level playbook of the IBM Z HMC Collection - -- hosts: - - my_hmc_list - vars_files: - - vault.yml - vars: - stogroup_name: sample-sg-1 - collections: - - ibm.ibm_zhmc - tasks: - - - name: "Ensure FCP storage group {{ stogroup_name }} exists" - delegate_to: localhost - zhmc_storage_group: - hmc_host: "{{ ansible_host }}" - hmc_auth: "{{ hmc_auth[inventory_hostname] }}" - cpc_name: "{{ cpc_name }}" - name: "{{ stogroup_name }}" - properties: - description: "This is storage group {{ stogroup_name }}" - type: fcp - shared: false - connectivity: 4 - max-partitions: 1 - state: present - expand: true - register: result - - - name: Print the result - ansible.builtin.debug: - var: result diff --git a/z_systems_administration/zhmc/playbooks/module_create_storage_volume.yml b/z_systems_administration/zhmc/playbooks/module_create_storage_volume.yml deleted file mode 100644 index 0d4f4d41f..000000000 --- a/z_systems_administration/zhmc/playbooks/module_create_storage_volume.yml +++ /dev/null @@ -1,31 +0,0 @@ ---- -# Sample module-level playbook of the IBM Z HMC Collection - -- hosts: - - my_hmc_list - vars_files: - - vault.yml - vars: - stogroup_name: sample-sg-1 - stovolume_name: sample-sv-1 - collections: - - ibm.ibm_zhmc - tasks: - - - name: "Ensure storage volume {{ stovolume_name }} exists in storage group {{ stogroup_name }}" - delegate_to: localhost - zhmc_storage_volume: - hmc_host: "{{ ansible_host }}" - hmc_auth: "{{ hmc_auth[inventory_hostname] }}" - cpc_name: "{{ cpc_name }}" - storage_group_name: "{{ stogroup_name }}" - name: "{{ stovolume_name }}" - properties: - description: "This is storage volume {{ stovolume_name }}" - size: 1 - state: present - register: result - - - name: Print the result - ansible.builtin.debug: - var: result diff --git a/z_systems_administration/zhmc/playbooks/module_crypto_attach_any.yml b/z_systems_administration/zhmc/playbooks/module_crypto_attach_any.yml new file mode 100644 index 000000000..8159c27fd --- /dev/null +++ b/z_systems_administration/zhmc/playbooks/module_crypto_attach_any.yml @@ -0,0 +1,39 @@ +--- +# Sample playbook for the zhmc_crypto_attachment module of the ibm.ibm_zhmc collection: +# +# Attach arbitrary crypto adapters to a partition +# +# Command to run this playbook: +# ansible-playbook -i inventory.yml -e hmc={myhmc} -e cpc={mycpc} -e partition={mypartition} module_crypto_attach_any.yml + +- hosts: + - "{{ hmc | default('default') }}" # HMC nickname from inventory entry + gather_facts: no + vars_files: + - vault.yml + vars: + cpc: MYCPC # Adjust or override with -e option + partition: sample-part-1 # Adjust or override with -e option + log_file: zhmc.log + collections: + - ibm.ibm_zhmc + tasks: + + - name: "Ensure domains 2..max on 2 arbitrary adapters are attached to partition {{ partition }}" + delegate_to: localhost + zhmc_crypto_attachment: + hmc_host: "{{ hmc_host }}" + hmc_auth: "{{ hmc_auth }}" + cpc_name: "{{ cpc }}" + partition_name: "{{ partition }}" + state: attached + crypto_type: ep11 + adapter_count: 2 + domain_range: 2,-1 + access_mode: usage + log_file: "{{ log_file | default(omit) }}" + register: result + + - name: Print the result + ansible.builtin.debug: + var: result diff --git a/z_systems_administration/zhmc/playbooks/module_crypto_attach_byname.yml b/z_systems_administration/zhmc/playbooks/module_crypto_attach_byname.yml new file mode 100644 index 000000000..e8393eeb3 --- /dev/null +++ b/z_systems_administration/zhmc/playbooks/module_crypto_attach_byname.yml @@ -0,0 +1,40 @@ +--- +# Sample playbook for the zhmc_crypto_attachment module of the ibm.ibm_zhmc collection: +# +# Attach named crypto adapters to a partition +# +# Command to run this playbook: +# ansible-playbook -i inventory.yml -e hmc={myhmc} -e cpc={mycpc} -e partition={mypartition} module_crypto_attach_byname.yml + +- hosts: + - "{{ hmc | default('default') }}" # HMC nickname from inventory entry + gather_facts: no + vars_files: + - vault.yml + vars: + cpc: MYCPC # Adjust or override with -e option + partition: sample-part-1 # Adjust or override with -e option + crypto_adapters: [CRYP00, CRYP01] # Adjust + log_file: zhmc.log + collections: + - ibm.ibm_zhmc + tasks: + + - name: "Ensure domains 2..max on crypto adapters {{ crypto_adapters }} are attached to partition {{ partition }}" + delegate_to: localhost + zhmc_crypto_attachment: + hmc_host: "{{ ansible_host }}" + hmc_auth: "{{ hmc_auth[inventory_hostname] }}" + cpc_name: "{{ cpc }}" + partition_name: "{{ partition }}" + state: attached + crypto_type: ep11 + adapter_names: "{{ crypto_adapters }}" + domain_range: 2,-1 + access_mode: usage + log_file: "{{ log_file | default(omit) }}" + register: result + + - name: Print the result + ansible.builtin.debug: + var: result diff --git a/z_systems_administration/zhmc/playbooks/module_crypto_attachment_facts.yml b/z_systems_administration/zhmc/playbooks/module_crypto_attachment_facts.yml new file mode 100644 index 000000000..2fe599e4b --- /dev/null +++ b/z_systems_administration/zhmc/playbooks/module_crypto_attachment_facts.yml @@ -0,0 +1,35 @@ +--- +# Sample playbook for the zhmc_crypto_attachment module of the ibm.ibm_zhmc collection: +# +# Get facts about the crypto config of a partition +# +# Command to run this playbook: +# ansible-playbook -i inventory.yml -e hmc={myhmc} -e cpc={mycpc} -e partition={mypartition} module_crypto_attachment_facts.yml + +- hosts: + - "{{ hmc | default('default') }}" # HMC nickname from inventory entry + gather_facts: no + vars_files: + - vault.yml + vars: + cpc: MYCPC # Adjust or override with -e option + partition: sample-part-1 # Adjust or override with -e option + log_file: zhmc.log + collections: + - ibm.ibm_zhmc + tasks: + + - name: "Get facts for crypto config of partition {{ partition }}" + delegate_to: localhost + zhmc_crypto_attachment: + hmc_host: "{{ ansible_host }}" + hmc_auth: "{{ hmc_auth[inventory_hostname] }}" + cpc_name: "{{ cpc }}" + partition_name: "{{ partition }}" + state: facts + log_file: "{{ log_file | default(omit) }}" + register: result + + - name: Print the result + ansible.builtin.debug: + var: result diff --git a/z_systems_administration/zhmc/playbooks/module_crypto_detach.yml b/z_systems_administration/zhmc/playbooks/module_crypto_detach.yml new file mode 100644 index 000000000..c259dca92 --- /dev/null +++ b/z_systems_administration/zhmc/playbooks/module_crypto_detach.yml @@ -0,0 +1,35 @@ +--- +# Sample playbook for the zhmc_crypto_attachment module of the ibm.ibm_zhmc collection: +# +# Detach all crypto adapters and domains from a partition +# +# Command to run this playbook: +# ansible-playbook -i inventory.yml -e hmc={myhmc} -e cpc={mycpc} -e partition={mypartition} module_crypto_detach.yml + +- hosts: + - "{{ hmc | default('default') }}" # HMC nickname from inventory entry + gather_facts: no + vars_files: + - vault.yml + vars: + cpc: MYCPC # Adjust or override with -e option + partition: sample-part-1 # Adjust or override with -e option + log_file: zhmc.log + collections: + - ibm.ibm_zhmc + tasks: + + - name: "Ensure no crypto domains and no crypto adapters are attached to partition {{ partition }}" + delegate_to: localhost + zhmc_crypto_attachment: + hmc_host: "{{ ansible_host }}" + hmc_auth: "{{ hmc_auth[inventory_hostname] }}" + cpc_name: "{{ cpc }}" + partition_name: "{{ partition }}" + state: detached + log_file: "{{ log_file | default(omit) }}" + register: result + + - name: Print the result + ansible.builtin.debug: + var: result diff --git a/z_systems_administration/zhmc/playbooks/module_delete_hipersockets_adapter.yml b/z_systems_administration/zhmc/playbooks/module_delete_hipersockets_adapter.yml deleted file mode 100644 index 09c4ded68..000000000 --- a/z_systems_administration/zhmc/playbooks/module_delete_hipersockets_adapter.yml +++ /dev/null @@ -1,26 +0,0 @@ ---- -# Sample module-level playbook of the IBM Z HMC Collection - -- hosts: - - my_hmc_list - vars_files: - - vault.yml - vars: - hs_adapter_name: sample-hs-1 - collections: - - ibm.ibm_zhmc - tasks: - - - name: "Ensure Hipersockets adapter {{ hs_adapter_name }} does not exist" - delegate_to: localhost - zhmc_adapter: - hmc_host: "{{ ansible_host }}" - hmc_auth: "{{ hmc_auth[inventory_hostname] }}" - cpc_name: "{{ cpc_name }}" - name: "{{ hs_adapter_name }}" - state: absent - register: result - - - name: Print the result - ansible.builtin.debug: - var: result diff --git a/z_systems_administration/zhmc/playbooks/module_delete_partition.yml b/z_systems_administration/zhmc/playbooks/module_delete_partition.yml deleted file mode 100644 index 8be1a0c2e..000000000 --- a/z_systems_administration/zhmc/playbooks/module_delete_partition.yml +++ /dev/null @@ -1,26 +0,0 @@ ---- -# Sample module-level playbook of the IBM Z HMC Collection - -- hosts: - - my_hmc_list - vars_files: - - vault.yml - vars: - partition_name: sample-part-1 - collections: - - ibm.ibm_zhmc - tasks: - - - name: "Ensure partition {{ partition_name }} does not exist" - delegate_to: localhost - zhmc_partition: - hmc_host: "{{ ansible_host }}" - hmc_auth: "{{ hmc_auth[inventory_hostname] }}" - cpc_name: "{{ cpc_name }}" - name: "{{ partition_name }}" - state: absent - register: result - - - name: Print the result - ansible.builtin.debug: - var: result diff --git a/z_systems_administration/zhmc/playbooks/module_delete_storage_group.yml b/z_systems_administration/zhmc/playbooks/module_delete_storage_group.yml deleted file mode 100644 index 26b80dfb0..000000000 --- a/z_systems_administration/zhmc/playbooks/module_delete_storage_group.yml +++ /dev/null @@ -1,26 +0,0 @@ ---- -# Sample module-level playbook of the IBM Z HMC Collection - -- hosts: - - my_hmc_list - vars_files: - - vault.yml - vars: - stogroup_name: sample-sg-1 - collections: - - ibm.ibm_zhmc - tasks: - - - name: "Ensure FCP storage group {{ stogroup_name }} does not exist" - delegate_to: localhost - zhmc_storage_group: - hmc_host: "{{ ansible_host }}" - hmc_auth: "{{ hmc_auth[inventory_hostname] }}" - cpc_name: "{{ cpc_name }}" - name: "{{ stogroup_name }}" - state: absent - register: result - - - name: Print the result - ansible.builtin.debug: - var: result diff --git a/z_systems_administration/zhmc/playbooks/module_delete_storage_volume.yml b/z_systems_administration/zhmc/playbooks/module_delete_storage_volume.yml deleted file mode 100644 index 1c8cae003..000000000 --- a/z_systems_administration/zhmc/playbooks/module_delete_storage_volume.yml +++ /dev/null @@ -1,28 +0,0 @@ ---- -# Sample module-level playbook of the IBM Z HMC Collection - -- hosts: - - my_hmc_list - vars_files: - - vault.yml - vars: - stogroup_name: sample-sg-1 - stovolume_name: sample-sv-1 - collections: - - ibm.ibm_zhmc - tasks: - - - name: "Ensure storage volume {{ stovolume_name }} does not exist in storage group {{ stogroup_name }}" - delegate_to: localhost - zhmc_storage_volume: - hmc_host: "{{ ansible_host }}" - hmc_auth: "{{ hmc_auth[inventory_hostname] }}" - cpc_name: "{{ cpc_name }}" - storage_group_name: "{{ stogroup_name }}" - name: "{{ stovolume_name }}" - state: absent - register: result - - - name: Print the result - ansible.builtin.debug: - var: result diff --git a/z_systems_administration/zhmc/playbooks/module_detach_crypto.yml b/z_systems_administration/zhmc/playbooks/module_detach_crypto.yml deleted file mode 100644 index face522f2..000000000 --- a/z_systems_administration/zhmc/playbooks/module_detach_crypto.yml +++ /dev/null @@ -1,26 +0,0 @@ ---- -# Sample module-level playbook of the IBM Z HMC Collection - -- hosts: - - my_hmc_list - vars_files: - - vault.yml - vars: - partition_name: sample-part-1 - collections: - - ibm.ibm_zhmc - tasks: - - - name: "Ensure no crypto domains and no crypto adapters are attached to partition {{ partition_name }}" - delegate_to: localhost - zhmc_crypto_attachment: - hmc_host: "{{ ansible_host }}" - hmc_auth: "{{ hmc_auth[inventory_hostname] }}" - cpc_name: "{{ cpc_name }}" - partition_name: "{{ partition_name }}" - state: detached - register: result - - - name: Print the result - ansible.builtin.debug: - var: result diff --git a/z_systems_administration/zhmc/playbooks/module_detach_storage_group.yml b/z_systems_administration/zhmc/playbooks/module_detach_storage_group.yml deleted file mode 100644 index 4ca4f7426..000000000 --- a/z_systems_administration/zhmc/playbooks/module_detach_storage_group.yml +++ /dev/null @@ -1,28 +0,0 @@ ---- -# Sample module-level playbook of the IBM Z HMC Collection - -- hosts: - - my_hmc_list - vars_files: - - vault.yml - vars: - partition_name: sample-part-1 - stogroup_name: sample-sg-1 - collections: - - ibm.ibm_zhmc - tasks: - - - name: "Ensure storage group {{ stogroup_name }} is detached from partition {{ partition_name }}" - delegate_to: localhost - zhmc_storage_group_attachment: - hmc_host: "{{ ansible_host }}" - hmc_auth: "{{ hmc_auth[inventory_hostname] }}" - cpc_name: "{{ cpc_name }}" - storage_group_name: "{{ stogroup_name }}" - partition_name: "{{ partition_name }}" - state: detached - register: result - - - name: Print the result - ansible.builtin.debug: - var: result diff --git a/z_systems_administration/zhmc/playbooks/module_facts_adapter.yml b/z_systems_administration/zhmc/playbooks/module_facts_adapter.yml deleted file mode 100644 index 7cec5541c..000000000 --- a/z_systems_administration/zhmc/playbooks/module_facts_adapter.yml +++ /dev/null @@ -1,26 +0,0 @@ ---- -# Sample module-level playbook of the IBM Z HMC Collection - -- hosts: - - my_hmc_list - vars_files: - - vault.yml - vars: - adapter_name: sample-hs-1 # Adjust to an existing adapter in your CPC - collections: - - ibm.ibm_zhmc - tasks: - - - name: "Get facts for adapter {{ adapter_name }}" - delegate_to: localhost - zhmc_adapter: - hmc_host: "{{ ansible_host }}" - hmc_auth: "{{ hmc_auth[inventory_hostname] }}" - cpc_name: "{{ cpc_name }}" - name: "{{ adapter_name }}" - state: facts - register: result - - - name: Print the result - ansible.builtin.debug: - var: result diff --git a/z_systems_administration/zhmc/playbooks/module_facts_cpc.yml b/z_systems_administration/zhmc/playbooks/module_facts_cpc.yml deleted file mode 100644 index 16daa5614..000000000 --- a/z_systems_administration/zhmc/playbooks/module_facts_cpc.yml +++ /dev/null @@ -1,23 +0,0 @@ ---- -# Sample module-level playbook of the IBM Z HMC Collection - -- hosts: - - my_hmc_list - vars_files: - - vault.yml - collections: - - ibm.ibm_zhmc - tasks: - - - name: "Get facts for CPC {{ cpc_name }}" - delegate_to: localhost - zhmc_cpc: - hmc_host: "{{ ansible_host }}" - hmc_auth: "{{ hmc_auth[inventory_hostname] }}" - name: "{{ cpc_name }}" - state: facts - register: result - - - name: Print the result - ansible.builtin.debug: - var: result diff --git a/z_systems_administration/zhmc/playbooks/module_facts_crypto_attachment.yml b/z_systems_administration/zhmc/playbooks/module_facts_crypto_attachment.yml deleted file mode 100644 index 7f196d9cd..000000000 --- a/z_systems_administration/zhmc/playbooks/module_facts_crypto_attachment.yml +++ /dev/null @@ -1,26 +0,0 @@ ---- -# Sample module-level playbook of the IBM Z HMC Collection - -- hosts: - - my_hmc_list - vars_files: - - vault.yml - vars: - partition_name: sample-part-1 - collections: - - ibm.ibm_zhmc - tasks: - - - name: "Get facts for crypto config of partition {{ partition_name }}" - delegate_to: localhost - zhmc_crypto_attachment: - hmc_host: "{{ ansible_host }}" - hmc_auth: "{{ hmc_auth[inventory_hostname] }}" - cpc_name: "{{ cpc_name }}" - partition_name: "{{ partition_name }}" - state: facts - register: result - - - name: Print the result - ansible.builtin.debug: - var: result diff --git a/z_systems_administration/zhmc/playbooks/module_facts_partition.yml b/z_systems_administration/zhmc/playbooks/module_facts_partition.yml deleted file mode 100644 index 18ead6a99..000000000 --- a/z_systems_administration/zhmc/playbooks/module_facts_partition.yml +++ /dev/null @@ -1,26 +0,0 @@ ---- -# Sample module-level playbook of the IBM Z HMC Collection - -- hosts: - - my_hmc_list - vars_files: - - vault.yml - vars: - partition_name: sample-part-1 - collections: - - ibm.ibm_zhmc - tasks: - - - name: "Get facts for partition {{ partition_name }}" - delegate_to: localhost - zhmc_partition: - hmc_host: "{{ ansible_host }}" - hmc_auth: "{{ hmc_auth[inventory_hostname] }}" - cpc_name: "{{ cpc_name }}" - name: "{{ partition_name }}" - state: facts - register: result - - - name: Print the result - ansible.builtin.debug: - var: result diff --git a/z_systems_administration/zhmc/playbooks/module_facts_storage_group.yml b/z_systems_administration/zhmc/playbooks/module_facts_storage_group.yml deleted file mode 100644 index 8e819d67d..000000000 --- a/z_systems_administration/zhmc/playbooks/module_facts_storage_group.yml +++ /dev/null @@ -1,28 +0,0 @@ ---- -# Sample module-level playbook of the IBM Z HMC Collection - -- hosts: - - my_hmc_list - vars_files: - - vault.yml - vars: - partition_name: sample-part-1 - stogroup_name: sample-sg-1 - collections: - - ibm.ibm_zhmc - tasks: - - - name: "Get facts for storage group {{ stogroup_name }}" - delegate_to: localhost - zhmc_storage_group: - hmc_host: "{{ ansible_host }}" - hmc_auth: "{{ hmc_auth[inventory_hostname] }}" - cpc_name: "{{ cpc_name }}" - name: "{{ stogroup_name }}" - state: facts - expand: true - register: result - - - name: Print the result - ansible.builtin.debug: - var: result diff --git a/z_systems_administration/zhmc/playbooks/module_facts_storage_group_attachment.yml b/z_systems_administration/zhmc/playbooks/module_facts_storage_group_attachment.yml deleted file mode 100644 index 9200e6483..000000000 --- a/z_systems_administration/zhmc/playbooks/module_facts_storage_group_attachment.yml +++ /dev/null @@ -1,28 +0,0 @@ ---- -# Sample module-level playbook of the IBM Z HMC Collection - -- hosts: - - my_hmc_list - vars_files: - - vault.yml - vars: - partition_name: sample-part-1 - stogroup_name: sample-sg-1 - collections: - - ibm.ibm_zhmc - tasks: - - - name: "Get facts for attachment of storage group {{ stogroup_name }} to partition {{ partition_name }}" - delegate_to: localhost - zhmc_storage_group_attachment: - hmc_host: "{{ ansible_host }}" - hmc_auth: "{{ hmc_auth[inventory_hostname] }}" - cpc_name: "{{ cpc_name }}" - storage_group_name: "{{ stogroup_name }}" - partition_name: "{{ partition_name }}" - state: facts - register: result - - - name: Print the result - ansible.builtin.debug: - var: result diff --git a/z_systems_administration/zhmc/playbooks/module_facts_storage_volume.yml b/z_systems_administration/zhmc/playbooks/module_facts_storage_volume.yml deleted file mode 100644 index 7e7f9e45d..000000000 --- a/z_systems_administration/zhmc/playbooks/module_facts_storage_volume.yml +++ /dev/null @@ -1,28 +0,0 @@ ---- -# Sample module-level playbook of the IBM Z HMC Collection - -- hosts: - - my_hmc_list - vars_files: - - vault.yml - vars: - stogroup_name: sample-sg-1 - stovolume_name: sample-sv-1 - collections: - - ibm.ibm_zhmc - tasks: - - - name: "Get facts for storage volume {{ stovolume_name }} of storage group {{ stogroup_name }}" - delegate_to: localhost - zhmc_storage_volume: - hmc_host: "{{ ansible_host }}" - hmc_auth: "{{ hmc_auth[inventory_hostname] }}" - cpc_name: "{{ cpc_name }}" - storage_group_name: "{{ stogroup_name }}" - name: "{{ stovolume_name }}" - state: facts - register: result - - - name: Print the result - ansible.builtin.debug: - var: result diff --git a/z_systems_administration/zhmc/playbooks/module_facts_user.yml b/z_systems_administration/zhmc/playbooks/module_facts_user.yml deleted file mode 100644 index 6c38bfdfe..000000000 --- a/z_systems_administration/zhmc/playbooks/module_facts_user.yml +++ /dev/null @@ -1,26 +0,0 @@ ---- -# Sample module-level playbook of the IBM Z HMC Collection - -- hosts: - - my_hmc_list - vars_files: - - vault.yml - vars: - user_name: "{{ hmc_auth.userid }}" # Adjust to any other user - collections: - - ibm.ibm_zhmc - tasks: - - - name: "Get facts for HMC user {{ user_name }}" - delegate_to: localhost - zhmc_user: - hmc_host: "{{ ansible_host }}" - hmc_auth: "{{ hmc_auth[inventory_hostname] }}" - name: "{{ user_name }}" - state: facts - expand: true - register: result - - - name: Print the result - ansible.builtin.debug: - var: result diff --git a/z_systems_administration/zhmc/playbooks/module_hipersockets_create.yml b/z_systems_administration/zhmc/playbooks/module_hipersockets_create.yml new file mode 100644 index 000000000..89ecb9f7a --- /dev/null +++ b/z_systems_administration/zhmc/playbooks/module_hipersockets_create.yml @@ -0,0 +1,38 @@ +--- +# Sample playbook for the zhmc_adapter module of the ibm.ibm_zhmc collection: +# +# Create a Hipersockets adapter +# +# Command to run this playbook: +# ansible-playbook -i inventory.yml -e hmc={myhmc} -e cpc={mycpc} -e hs={myhs} module_hipersockets_create.yml + +- hosts: + - "{{ hmc | default('default') }}" # HMC nickname from inventory entry + gather_facts: no + vars_files: + - vault.yml + vars: + cpc: MYCPC # Adjust or override with -e option + hs: sample-hs-1 # Adjust or override with -e option + log_file: zhmc.log + collections: + - ibm.ibm_zhmc + tasks: + + - name: "Ensure a Hipersockets adapter {{ hs }} exists and has the desired property values" + delegate_to: localhost + zhmc_adapter: + hmc_host: "{{ ansible_host }}" + hmc_auth: "{{ hmc_auth[inventory_hostname] }}" + cpc_name: "{{ cpc }}" + name: "{{ hs }}" + state: present + properties: + type: hipersockets + description: "This is Hipersockets adapter {{ hs }}" + log_file: "{{ log_file | default(omit) }}" + register: result + + - name: Print the result + ansible.builtin.debug: + var: result diff --git a/z_systems_administration/zhmc/playbooks/module_hipersockets_delete.yml b/z_systems_administration/zhmc/playbooks/module_hipersockets_delete.yml new file mode 100644 index 000000000..0b6ab02d6 --- /dev/null +++ b/z_systems_administration/zhmc/playbooks/module_hipersockets_delete.yml @@ -0,0 +1,35 @@ +--- +# Sample playbook for the zhmc_adapter module of the ibm.ibm_zhmc collection: +# +# Delete a Hipersockets adapter +# +# Command to run this playbook: +# ansible-playbook -i inventory.yml -e hmc={myhmc} -e cpc={mycpc} -e hs={myhs} module_hipersockets_delete.yml + +- hosts: + - "{{ hmc | default('default') }}" # HMC nickname from inventory entry + gather_facts: no + vars_files: + - vault.yml + vars: + cpc: MYCPC # Adjust or override with -e option + hs: sample-hs-1 # Adjust or override with -e option + log_file: zhmc.log + collections: + - ibm.ibm_zhmc + tasks: + + - name: "Ensure Hipersockets adapter {{ hs }} does not exist" + delegate_to: localhost + zhmc_adapter: + hmc_host: "{{ ansible_host }}" + hmc_auth: "{{ hmc_auth[inventory_hostname] }}" + cpc_name: "{{ cpc }}" + name: "{{ hs }}" + state: absent + log_file: "{{ log_file | default(omit) }}" + register: result + + - name: Print the result + ansible.builtin.debug: + var: result diff --git a/z_systems_administration/zhmc/playbooks/module_partition_create.yml b/z_systems_administration/zhmc/playbooks/module_partition_create.yml new file mode 100644 index 000000000..94f4042d4 --- /dev/null +++ b/z_systems_administration/zhmc/playbooks/module_partition_create.yml @@ -0,0 +1,43 @@ +--- +# Sample playbook for the zhmc_partition module of the ibm.ibm_zhmc collection: +# +# Create a partition +# +# Command to run this playbook: +# ansible-playbook -i inventory.yml -e hmc={myhmc} -e cpc={mycpc} -e partition={mypartition} module_partition_create.yml + +- hosts: + - "{{ hmc | default('default') }}" # HMC nickname from inventory entry + gather_facts: no + vars_files: + - vault.yml + vars: + cpc: MYCPC # Adjust or override with -e option + partition: sample-part-1 # Adjust or override with -e option + log_file: zhmc.log + collections: + - ibm.ibm_zhmc + tasks: + + - name: "Ensure partition {{ partition }} exists and is stopped" + delegate_to: localhost + zhmc_partition: + hmc_host: "{{ ansible_host }}" + hmc_auth: "{{ hmc_auth[inventory_hostname] }}" + cpc_name: "{{ cpc }}" + name: "{{ partition }}" + state: stopped + properties: + description: "This is partition {{ partition }}" + ifl_processors: 2 + initial_memory: 1024 + maximum_memory: 1024 + minimum_ifl_processing_weight: 50 + maximum_ifl_processing_weight: 800 + initial_ifl_processing_weight: 200 + log_file: "{{ log_file | default(omit) }}" + register: result + + - name: Print the result + ansible.builtin.debug: + var: result diff --git a/z_systems_administration/zhmc/playbooks/module_partition_delete.yml b/z_systems_administration/zhmc/playbooks/module_partition_delete.yml new file mode 100644 index 000000000..859a6bf85 --- /dev/null +++ b/z_systems_administration/zhmc/playbooks/module_partition_delete.yml @@ -0,0 +1,35 @@ +--- +# Sample playbook for the zhmc_partition module of the ibm.ibm_zhmc collection: +# +# Delete a partition +# +# Command to run this playbook: +# ansible-playbook -i inventory.yml -e hmc={myhmc} -e cpc={mycpc} -e partition={mypartition} module_partition_delete.yml + +- hosts: + - "{{ hmc | default('default') }}" # HMC nickname from inventory entry + gather_facts: no + vars_files: + - vault.yml + vars: + cpc: MYCPC # Adjust or override with -e option + partition: sample-part-1 # Adjust or override with -e option + log_file: zhmc.log + collections: + - ibm.ibm_zhmc + tasks: + + - name: "Ensure partition {{ partition }} does not exist" + delegate_to: localhost + zhmc_partition: + hmc_host: "{{ ansible_host }}" + hmc_auth: "{{ hmc_auth[inventory_hostname] }}" + cpc_name: "{{ cpc }}" + name: "{{ partition }}" + state: absent + log_file: "{{ log_file | default(omit) }}" + register: result + + - name: Print the result + ansible.builtin.debug: + var: result diff --git a/z_systems_administration/zhmc/playbooks/module_partition_facts.yml b/z_systems_administration/zhmc/playbooks/module_partition_facts.yml new file mode 100644 index 000000000..c820f8de5 --- /dev/null +++ b/z_systems_administration/zhmc/playbooks/module_partition_facts.yml @@ -0,0 +1,35 @@ +--- +# Sample playbook for the zhmc_partition module of the ibm.ibm_zhmc collection: +# +# Get the facts of a partition +# +# Command to run this playbook: +# ansible-playbook -i inventory.yml -e hmc={myhmc} -e cpc={mycpc} -e partition={mypartition} module_partition_facts.yml + +- hosts: + - "{{ hmc | default('default') }}" # HMC nickname from inventory entry + gather_facts: no + vars_files: + - vault.yml + vars: + cpc: MYCPC # Adjust or override with -e option + partition: sample-part-1 # Adjust or override with -e option + log_file: zhmc.log + collections: + - ibm.ibm_zhmc + tasks: + + - name: "Get facts for partition {{ partition }}" + delegate_to: localhost + zhmc_partition: + hmc_host: "{{ ansible_host }}" + hmc_auth: "{{ hmc_auth[inventory_hostname] }}" + cpc_name: "{{ cpc }}" + name: "{{ partition }}" + state: facts + log_file: "{{ log_file | default(omit) }}" + register: result + + - name: Print the result + ansible.builtin.debug: + var: result diff --git a/z_systems_administration/zhmc/playbooks/module_rename_adapter.yml b/z_systems_administration/zhmc/playbooks/module_rename_adapter.yml deleted file mode 100644 index 53fc09efd..000000000 --- a/z_systems_administration/zhmc/playbooks/module_rename_adapter.yml +++ /dev/null @@ -1,29 +0,0 @@ ---- -# Sample module-level playbook of the IBM Z HMC Collection - -- hosts: - - my_hmc_list - vars_files: - - vault.yml - vars: - adapter_id: '7c3' # Adjust to Hipersockets adapter created - new_adapter_name: sample-hs-1 - collections: - - ibm.ibm_zhmc - tasks: - - - name: "Ensure adapter with PCHID {{ adapter_id }} has name {{ new_adapter_name }}" - delegate_to: localhost - zhmc_adapter: - hmc_host: "{{ ansible_host }}" - hmc_auth: "{{ hmc_auth[inventory_hostname] }}" - cpc_name: "{{ cpc_name }}" - name: "{{ new_adapter_name }}" - match: - adapter_id: "{{ adapter_id }}" - state: set - register: result - - - name: Print the result - ansible.builtin.debug: - var: result diff --git a/z_systems_administration/zhmc/playbooks/module_set_adapter.yml b/z_systems_administration/zhmc/playbooks/module_set_adapter.yml deleted file mode 100644 index bc10c912e..000000000 --- a/z_systems_administration/zhmc/playbooks/module_set_adapter.yml +++ /dev/null @@ -1,28 +0,0 @@ ---- -# Sample module-level playbook of the IBM Z HMC Collection - -- hosts: - - my_hmc_list - vars_files: - - vault.yml - vars: - adapter_name: sample-hs-1 # Adjust to an existing adapter in your CPC - collections: - - ibm.ibm_zhmc - tasks: - - - name: "Ensure adapter {{ adapter_name }} has the desired description" - delegate_to: localhost - zhmc_adapter: - hmc_host: "{{ ansible_host }}" - hmc_auth: "{{ hmc_auth[inventory_hostname] }}" - cpc_name: "{{ cpc_name }}" - name: "{{ adapter_name }}" - state: set - properties: - description: "Changed description of adapter {{ adapter_name }}" - register: result - - - name: Print the result - ansible.builtin.debug: - var: result diff --git a/z_systems_administration/zhmc/playbooks/module_set_cpc.yml b/z_systems_administration/zhmc/playbooks/module_set_cpc.yml deleted file mode 100644 index 5cca1e1fe..000000000 --- a/z_systems_administration/zhmc/playbooks/module_set_cpc.yml +++ /dev/null @@ -1,25 +0,0 @@ ---- -# Sample module-level playbook of the IBM Z HMC Collection - -- hosts: - - my_hmc_list - vars_files: - - vault.yml - collections: - - ibm.ibm_zhmc - tasks: - - - name: "Ensure CPC {{ cpc_name }} has the desired description" - delegate_to: localhost - zhmc_cpc: - hmc_host: "{{ ansible_host }}" - hmc_auth: "{{ hmc_auth[inventory_hostname] }}" - name: "{{ cpc_name }}" - state: set - properties: - description: "Changed description of CPC {{ cpc_name }}" - register: result - - - name: Print the result - ansible.builtin.debug: - var: result diff --git a/z_systems_administration/zhmc/playbooks/module_storagegroup_attach.yml b/z_systems_administration/zhmc/playbooks/module_storagegroup_attach.yml new file mode 100644 index 000000000..4532218df --- /dev/null +++ b/z_systems_administration/zhmc/playbooks/module_storagegroup_attach.yml @@ -0,0 +1,37 @@ +--- +# Sample playbook for the zhmc_storage_group_attachment module of the ibm.ibm_zhmc collection: +# +# Attach a storage group to a partition +# +# Command to run this playbook: +# ansible-playbook -i inventory.yml -e hmc={myhmc} -e cpc={mycpc} -e partition={mypartition} -e stogroup={mystogroup} module_storagegroup_attach.yml + +- hosts: + - "{{ hmc | default('default') }}" # HMC nickname from inventory entry + gather_facts: no + vars_files: + - vault.yml + vars: + cpc: MYCPC # Adjust or override with -e option + partition: sample-part-1 # Adjust or override with -e option + stogroup: sample-sg-1 # Adjust or override with -e option + log_file: zhmc.log + collections: + - ibm.ibm_zhmc + tasks: + + - name: "Ensure storage group {{ stogroup }} is attached to partition {{ partition }}" + delegate_to: localhost + zhmc_storage_group_attachment: + hmc_host: "{{ ansible_host }}" + hmc_auth: "{{ hmc_auth[inventory_hostname] }}" + cpc_name: "{{ cpc }}" + storage_group_name: "{{ stogroup }}" + partition_name: "{{ partition }}" + state: attached + log_file: "{{ log_file | default(omit) }}" + register: result + + - name: Print the result + ansible.builtin.debug: + var: result diff --git a/z_systems_administration/zhmc/playbooks/module_storagegroup_attachment_facts.yml b/z_systems_administration/zhmc/playbooks/module_storagegroup_attachment_facts.yml new file mode 100644 index 000000000..cdfd8edb5 --- /dev/null +++ b/z_systems_administration/zhmc/playbooks/module_storagegroup_attachment_facts.yml @@ -0,0 +1,37 @@ +--- +# Sample playbook for the zhmc_storage_group_attachment module of the ibm.ibm_zhmc collection: +# +# Get facts about a storage group attached to a partition +# +# Command to run this playbook: +# ansible-playbook -i inventory.yml -e hmc={myhmc} -e cpc={mycpc} -e partition={mypartition} -e stogroup={mystogroup} module_storagegroup_attachment_facts.yml + +- hosts: + - "{{ hmc | default('default') }}" # HMC nickname from inventory entry + gather_facts: no + vars_files: + - vault.yml + vars: + cpc: MYCPC # Adjust or override with -e option + partition: sample-part-1 # Adjust or override with -e option + stogroup: sample-sg-1 # Adjust or override with -e option + log_file: zhmc.log + collections: + - ibm.ibm_zhmc + tasks: + + - name: "Get facts for attachment of storage group {{ stogroup }} to partition {{ partition }}" + delegate_to: localhost + zhmc_storage_group_attachment: + hmc_host: "{{ ansible_host }}" + hmc_auth: "{{ hmc_auth[inventory_hostname] }}" + cpc_name: "{{ cpc }}" + storage_group_name: "{{ stogroup }}" + partition_name: "{{ partition }}" + state: facts + log_file: "{{ log_file | default(omit) }}" + register: result + + - name: Print the result + ansible.builtin.debug: + var: result diff --git a/z_systems_administration/zhmc/playbooks/module_storagegroup_create.yml b/z_systems_administration/zhmc/playbooks/module_storagegroup_create.yml new file mode 100644 index 000000000..db956750e --- /dev/null +++ b/z_systems_administration/zhmc/playbooks/module_storagegroup_create.yml @@ -0,0 +1,42 @@ +--- +# Sample playbook for the zhmc_storage_group module of the ibm.ibm_zhmc collection: +# +# Create a storage group +# +# Command to run this playbook: +# ansible-playbook -i inventory.yml -e hmc={myhmc} -e cpc={mycpc} -e stogroup={mystogroup} module_storagegroup_create.yml + +- hosts: + - "{{ hmc | default('default') }}" # HMC nickname from inventory entry + gather_facts: no + vars_files: + - vault.yml + vars: + cpc: MYCPC # Adjust or override with -e option + stogroup: sample-sg-1 # Adjust or override with -e option + log_file: zhmc.log + collections: + - ibm.ibm_zhmc + tasks: + + - name: "Ensure FCP storage group {{ stogroup }} exists" + delegate_to: localhost + zhmc_storage_group: + hmc_host: "{{ ansible_host }}" + hmc_auth: "{{ hmc_auth[inventory_hostname] }}" + cpc_name: "{{ cpc }}" + name: "{{ stogroup }}" + properties: + description: "This is storage group {{ stogroup }}" + type: fcp + shared: false + connectivity: 4 + max-partitions: 1 + state: present + expand: true + log_file: "{{ log_file | default(omit) }}" + register: result + + - name: Print the result + ansible.builtin.debug: + var: result diff --git a/z_systems_administration/zhmc/playbooks/module_storagegroup_delete.yml b/z_systems_administration/zhmc/playbooks/module_storagegroup_delete.yml new file mode 100644 index 000000000..31e78ec5f --- /dev/null +++ b/z_systems_administration/zhmc/playbooks/module_storagegroup_delete.yml @@ -0,0 +1,35 @@ +--- +# Sample playbook for the zhmc_storage_group module of the ibm.ibm_zhmc collection: +# +# Delete a storage group +# +# Command to run this playbook: +# ansible-playbook -i inventory.yml -e hmc={myhmc} -e cpc={mycpc} -e stogroup={mystogroup} module_storagegroup_delete.yml + +- hosts: + - "{{ hmc | default('default') }}" # HMC nickname from inventory entry + gather_facts: no + vars_files: + - vault.yml + vars: + cpc: MYCPC # Adjust or override with -e option + stogroup: sample-sg-1 # Adjust or override with -e option + log_file: zhmc.log + collections: + - ibm.ibm_zhmc + tasks: + + - name: "Ensure FCP storage group {{ stogroup }} does not exist" + delegate_to: localhost + zhmc_storage_group: + hmc_host: "{{ ansible_host }}" + hmc_auth: "{{ hmc_auth[inventory_hostname] }}" + cpc_name: "{{ cpc }}" + name: "{{ stogroup }}" + state: absent + log_file: "{{ log_file | default(omit) }}" + register: result + + - name: Print the result + ansible.builtin.debug: + var: result diff --git a/z_systems_administration/zhmc/playbooks/module_storagegroup_detach.yml b/z_systems_administration/zhmc/playbooks/module_storagegroup_detach.yml new file mode 100644 index 000000000..981d0ab38 --- /dev/null +++ b/z_systems_administration/zhmc/playbooks/module_storagegroup_detach.yml @@ -0,0 +1,37 @@ +--- +# Sample playbook for the zhmc_storage_group_attachment module of the ibm.ibm_zhmc collection: +# +# Detach a storage group from a partition +# +# Command to run this playbook: +# ansible-playbook -i inventory.yml -e hmc={myhmc} -e cpc={mycpc} -e partition={mypartition} -e stogroup={mystogroup} module_storagegroup_detach.yml + +- hosts: + - "{{ hmc | default('default') }}" # HMC nickname from inventory entry + gather_facts: no + vars_files: + - vault.yml + vars: + cpc: MYCPC # Adjust or override with -e option + partition: sample-part-1 # Adjust or override with -e option + stogroup: sample-sg-1 # Adjust or override with -e option + log_file: zhmc.log + collections: + - ibm.ibm_zhmc + tasks: + + - name: "Ensure storage group {{ stogroup }} is detached from partition {{ partition }}" + delegate_to: localhost + zhmc_storage_group_attachment: + hmc_host: "{{ ansible_host }}" + hmc_auth: "{{ hmc_auth[inventory_hostname] }}" + cpc_name: "{{ cpc }}" + storage_group_name: "{{ stogroup }}" + partition_name: "{{ partition }}" + state: detached + log_file: "{{ log_file | default(omit) }}" + register: result + + - name: Print the result + ansible.builtin.debug: + var: result diff --git a/z_systems_administration/zhmc/playbooks/module_storagegroup_facts.yml b/z_systems_administration/zhmc/playbooks/module_storagegroup_facts.yml new file mode 100644 index 000000000..6b01745fc --- /dev/null +++ b/z_systems_administration/zhmc/playbooks/module_storagegroup_facts.yml @@ -0,0 +1,36 @@ +--- +# Sample playbook for the zhmc_storage_group module of the ibm.ibm_zhmc collection: +# +# Get facts about a storage group +# +# Command to run this playbook: +# ansible-playbook -i inventory.yml -e hmc={myhmc} -e cpc={mycpc} -e stogroup={mystogroup} module_storagegroup_facts.yml + +- hosts: + - "{{ hmc | default('default') }}" # HMC nickname from inventory entry + gather_facts: no + vars_files: + - vault.yml + vars: + cpc: MYCPC # Adjust or override with -e option + stogroup: sample-sg-1 # Adjust or override with -e option + log_file: zhmc.log + collections: + - ibm.ibm_zhmc + tasks: + + - name: "Get facts for storage group {{ stogroup }}" + delegate_to: localhost + zhmc_storage_group: + hmc_host: "{{ ansible_host }}" + hmc_auth: "{{ hmc_auth[inventory_hostname] }}" + cpc_name: "{{ cpc }}" + name: "{{ stogroup }}" + state: facts + expand: true + log_file: "{{ log_file | default(omit) }}" + register: result + + - name: Print the result + ansible.builtin.debug: + var: result diff --git a/z_systems_administration/zhmc/playbooks/module_storagevolume_create.yml b/z_systems_administration/zhmc/playbooks/module_storagevolume_create.yml new file mode 100644 index 000000000..2414d8292 --- /dev/null +++ b/z_systems_administration/zhmc/playbooks/module_storagevolume_create.yml @@ -0,0 +1,40 @@ +--- +# Sample playbook for the zhmc_storage_volume module of the ibm.ibm_zhmc collection: +# +# Create a storage volume +# +# Command to run this playbook: +# ansible-playbook -i inventory.yml -e hmc={myhmc} -e cpc={mycpc} -e stogroup={mystogroup} -e stovolume={mystovolume} module_storagevolume_create.yml + +- hosts: + - "{{ hmc | default('default') }}" # HMC nickname from inventory entry + gather_facts: no + vars_files: + - vault.yml + vars: + cpc: MYCPC # Adjust or override with -e option + stogroup: sample-sg-1 # Adjust or override with -e option + stovolume: sample-sv-1 # Adjust or override with -e option + log_file: zhmc.log + collections: + - ibm.ibm_zhmc + tasks: + + - name: "Ensure storage volume {{ stovolume }} exists in storage group {{ stogroup }}" + delegate_to: localhost + zhmc_storage_volume: + hmc_host: "{{ ansible_host }}" + hmc_auth: "{{ hmc_auth[inventory_hostname] }}" + cpc_name: "{{ cpc }}" + storage_group_name: "{{ stogroup }}" + name: "{{ stovolume }}" + properties: + description: "This is storage volume {{ stovolume }}" + size: 1 + state: present + log_file: "{{ log_file | default(omit) }}" + register: result + + - name: Print the result + ansible.builtin.debug: + var: result diff --git a/z_systems_administration/zhmc/playbooks/module_storagevolume_delete.yml b/z_systems_administration/zhmc/playbooks/module_storagevolume_delete.yml new file mode 100644 index 000000000..621876a52 --- /dev/null +++ b/z_systems_administration/zhmc/playbooks/module_storagevolume_delete.yml @@ -0,0 +1,37 @@ +--- +# Sample playbook for the zhmc_storage_volume module of the ibm.ibm_zhmc collection: +# +# Delete a storage volume +# +# Command to run this playbook: +# ansible-playbook -i inventory.yml -e hmc={myhmc} -e cpc={mycpc} -e stogroup={mystogroup} -e stovolume={mystovolume} module_storagevolume_delete.yml + +- hosts: + - "{{ hmc | default('default') }}" # HMC nickname from inventory entry + gather_facts: no + vars_files: + - vault.yml + vars: + cpc: MYCPC # Adjust or override with -e option + stogroup: sample-sg-1 # Adjust or override with -e option + stovolume: sample-sv-1 # Adjust or override with -e option + log_file: zhmc.log + collections: + - ibm.ibm_zhmc + tasks: + + - name: "Ensure storage volume {{ stovolume }} does not exist in storage group {{ stogroup }}" + delegate_to: localhost + zhmc_storage_volume: + hmc_host: "{{ ansible_host }}" + hmc_auth: "{{ hmc_auth[inventory_hostname] }}" + cpc_name: "{{ cpc }}" + storage_group_name: "{{ stogroup }}" + name: "{{ stovolume }}" + state: absent + log_file: "{{ log_file | default(omit) }}" + register: result + + - name: Print the result + ansible.builtin.debug: + var: result diff --git a/z_systems_administration/zhmc/playbooks/module_storagevolume_facts.yml b/z_systems_administration/zhmc/playbooks/module_storagevolume_facts.yml new file mode 100644 index 000000000..a651a4202 --- /dev/null +++ b/z_systems_administration/zhmc/playbooks/module_storagevolume_facts.yml @@ -0,0 +1,37 @@ +--- +# Sample playbook for the zhmc_storage_volume module of the ibm.ibm_zhmc collection: +# +# Get facts about a storage volume +# +# Command to run this playbook: +# ansible-playbook -i inventory.yml -e hmc={myhmc} -e cpc={mycpc} -e stogroup={mystogroup} -e stovolume={mystovolume} module_storagevolume_facts.yml + +- hosts: + - "{{ hmc | default('default') }}" # HMC nickname from inventory entry + gather_facts: no + vars_files: + - vault.yml + vars: + cpc: MYCPC # Adjust or override with -e option + stogroup: sample-sg-1 # Adjust or override with -e option + stovolume: sample-sv-1 # Adjust or override with -e option + log_file: zhmc.log + collections: + - ibm.ibm_zhmc + tasks: + + - name: "Get facts for storage volume {{ stovolume }} of storage group {{ stogroup }}" + delegate_to: localhost + zhmc_storage_volume: + hmc_host: "{{ ansible_host }}" + hmc_auth: "{{ hmc_auth[inventory_hostname] }}" + cpc_name: "{{ cpc }}" + storage_group_name: "{{ stogroup }}" + name: "{{ stovolume }}" + state: facts + log_file: "{{ log_file | default(omit) }}" + register: result + + - name: Print the result + ansible.builtin.debug: + var: result diff --git a/z_systems_administration/zhmc/playbooks/module_user_facts.yml b/z_systems_administration/zhmc/playbooks/module_user_facts.yml new file mode 100644 index 000000000..6a113f410 --- /dev/null +++ b/z_systems_administration/zhmc/playbooks/module_user_facts.yml @@ -0,0 +1,34 @@ +--- +# Sample playbook for the zhmc_user module of the ibm.ibm_zhmc collection: +# +# Get facts about an HMC user +# +# Command to run this playbook: +# ansible-playbook -i inventory.yml -e hmc={myhmc} -e user={myuser} module_user_facts.yml + +- hosts: + - "{{ hmc | default('default') }}" # HMC nickname from inventory entry + gather_facts: no + vars_files: + - vault.yml + vars: + user: "{{ hmc_auth[inventory_hostname].userid }}" # Adjust or override with -e option + log_file: zhmc.log + collections: + - ibm.ibm_zhmc + tasks: + + - name: "Get facts for HMC user {{ user }}" + delegate_to: localhost + zhmc_user: + hmc_host: "{{ ansible_host }}" + hmc_auth: "{{ hmc_auth[inventory_hostname] }}" + name: "{{ user }}" + state: facts + expand: true + log_file: "{{ log_file | default(omit) }}" + register: result + + - name: Print the result + ansible.builtin.debug: + var: result diff --git a/z_systems_administration/zhmc/playbooks/vault_example.yml b/z_systems_administration/zhmc/playbooks/vault_example.yml index 9de1c160b..dfbb38bc8 100644 --- a/z_systems_administration/zhmc/playbooks/vault_example.yml +++ b/z_systems_administration/zhmc/playbooks/vault_example.yml @@ -1,11 +1,11 @@ --- # vault.yml file for the sample playbooks of the IBM Z HMC Collection -# hmc_auth parameter for the zhmc tasks, for the HMCs in the inventory: hmc_auth: - myhmc13: # must match the key name in the inventory file + + myhmc13: # nickname of the HMC, must match the nickname in the inventory file userid: myuserid password: mypassword + verify: false # optional, only if you need to disable certificate validation -# The CPC the sample playbooks work with: -cpc_name: CPCA + # ... more HMC entries, as needed