[Role][2167] A role that automatically scans the playbooks in the directory and advises of migration actions#2399
[Role][2167] A role that automatically scans the playbooks in the directory and advises of migration actions#2399surendrababuravella wants to merge 12 commits intodevfrom
Conversation
rexemin
left a comment
There was a problem hiding this comment.
It looks pretty good, this will be really useful for users migrating to v2.0.0, but I have another question: does this really need to be a new module? Everything will always run locally and you are breaking the naming convention for modules by not starting the module name with zos_, this looks more like a different type of plugin or a module utility
| DOCUMENTATION = r''' | ||
| --- | ||
| module: playbook_upgrade_validator | ||
| version_added: "1.0.0" |
| #!/usr/bin/python | ||
| # -*- coding: utf-8 -*- | ||
|
|
||
| # Copyright (c) IBM Corporation 2023, 2025 |
There was a problem hiding this comment.
If it's a new file, the copyright should just say 2025, I think
| version_added: "1.0.0" | ||
| author: | ||
| - "Ravella Surendra Babu (@surendrababuravella)" | ||
| short_description: Validates playbooks against ibm_zos_core 2.0 and provides migration actions. |
There was a problem hiding this comment.
| short_description: Validates playbooks against ibm_zos_core 2.0 and provides migration actions. | |
| short_description: Validates playbooks against ibm_zos_core 2.0.0 and provides migration actions. |
| short_description: Validates playbooks against ibm_zos_core 2.0 and provides migration actions. | ||
| description: | ||
| - Scans one or more Ansible playbooks to identify deprecated or renamed parameters | ||
| based on migration rules for IBM z/OS core collection version 2.0. |
There was a problem hiding this comment.
| based on migration rules for IBM z/OS core collection version 2.0. | |
| based on migration rules for IBM z/OS Core collection version 2.0.0. |
| migration_map: | ||
| description: | ||
| - A structured set of migration rules that specifies deprecated, renamed, and modified parameters | ||
| to help upgrade playbooks from ibm_zos_core 1.x to 2.0. |
There was a problem hiding this comment.
| to help upgrade playbooks from ibm_zos_core 1.x to 2.0. | |
| to help upgrade playbooks from ibm_zos_core 1.x.x to 2.0.0. |
| register: result | ||
| delegate_to: localhost | ||
|
|
||
| - name: print debug data |
There was a problem hiding this comment.
| - name: print debug data | |
| - name: Print migration validation results |
| @@ -0,0 +1,11 @@ | |||
| # ibm.ibm_zos_core.playbook_upgrade_validator | |||
|
|
|||
| This role validates playbooks against ibm_zos_core 2.0 and provides migration actions. | |||
There was a problem hiding this comment.
| This role validates playbooks against ibm_zos_core 2.0 and provides migration actions. | |
| This role validates playbooks against ibm_zos_core 2.0.0 and provides migration actions. |
|
|
||
| ## Role Variables | ||
|
|
||
| The only variable required is: |
There was a problem hiding this comment.
| The only variable required is: | |
| The following variables are required: |
|
|
||
| The only variable required is: | ||
|
|
||
| - `playbook_path`: The path to the directory containing one or more Ansible playbooks. |
There was a problem hiding this comment.
| - `playbook_path`: The path to the directory containing one or more Ansible playbooks. | |
| - `playbook_path`: The path to a directory containing one or more Ansible playbooks. |
| The only variable required is: | ||
|
|
||
| - `playbook_path`: The path to the directory containing one or more Ansible playbooks. | ||
| - `output_path`: File path where validation results should be written in JSON format. |
There was a problem hiding this comment.
| - `output_path`: File path where validation results should be written in JSON format. | |
| - `output_path`: File path where validation results should be written to in JSON format. |
Agree with Alex on this one, this doc mentions how to add custom modules to be used in a role https://docs.ansible.com/projects/ansible/latest/playbook_guide/playbooks_reuse_roles.html#embedding-modules-and-plugins-in-roles Basically, you can add them under |
fernandofloresg
left a comment
There was a problem hiding this comment.
Asked few questions and requested a couple of tests
| @@ -0,0 +1,3 @@ | |||
| minor_changes: | |||
| - playbook_upgrade_validator - Adding a role that automatically scans the playbooks in the directory and advises of migration actions. | |||
There was a problem hiding this comment.
Would recommend to add this
- playbook_upgrade_validator - Adding a role that automatically scans the playbooks in the directory and advises of migration actions from v1.x.x to v2.0.0.
| type: str | ||
| playbook_path: | ||
| description: | ||
| - The path to the directory containing one or more Ansible playbooks. |
There was a problem hiding this comment.
Question, will it analyze the playbooks recursively?
| def load_playbook(path): | ||
| """Load playbook YAML and preserve line numbers.""" | ||
| try: | ||
| from ruamel.yaml import YAML |
There was a problem hiding this comment.
Question, is this package included in the Red Hat Universal Base Image for Execution Environments? How complex would be for the user to install it in a EE given that this could be executed in a AAP instance?
There was a problem hiding this comment.
Just saw in the role playbook that you make sure that it is installed locally, thanks
| @@ -0,0 +1,30 @@ | |||
| --- | |||
| - name: Ensure ruamel.yaml is installed | |||
There was a problem hiding this comment.
Could you also uninstall it only if it was installed by this role?
There was a problem hiding this comment.
Could you also test with a playbook that does not include any zos_core collection tasks ? another one that calls the modules like ibm.ibm_zos_core.zos_archive too?
There was a problem hiding this comment.
Tested with multiple combinations
There was a problem hiding this comment.
tested a playbook containing below task:
- name: Archive data set into a terse, specify pack algorithm and use adrdssu
zos_archive:
src: "USER.ARCHIVE.TEST"
dest: "USER.ARCHIVE.RESULT.TRS"
format:
name: terse
format_options:
terse_pack: "spack"
use_adrdssu: true
Results:
{
"playbook": "/Users/surendra/Documents/GitHub/ansible/test/dataset.yml",
"play_name": "executing zos_script module",
"task_name": "Archive data set into a terse, specify pack algorithm and use adrdssu",
"module": "zos_archive",
"line": 40,
"migration_actions": [
"[MUST_FIX] Param 'format.format_options' is renamed to 'format.options' in zos_archive",
"[MUST_FIX] Param 'format.format_options.terse_pack' is renamed to 'format.options.spack' in zos_archive",
"[MUST_FIX] Param 'format.format_options.use_adrdssu' is renamed to 'format.options.adrdssu' in zos_archive",
"[MUST_FIX] Param 'format.format_options.terse_pack' type changed from 'string' to 'boolean' in zos_archive"
]
}
fernandofloresg
left a comment
There was a problem hiding this comment.
Looks good to me thanks!
0fb61d4


SUMMARY
A role that automatically scans the playbooks in the directory and advises of migration actions
ISSUE TYPE
COMPONENT NAME
ADDITIONAL INFORMATION