-
Notifications
You must be signed in to change notification settings - Fork 45
[Role][2167] A role that automatically scans the playbooks in the directory and advises of migration actions #2399
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: dev
Are you sure you want to change the base?
Conversation
rexemin
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should say "2.0.0"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
| #!/usr/bin/python | ||
| # -*- coding: utf-8 -*- | ||
|
|
||
| # Copyright (c) IBM Corporation 2023, 2025 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If it's a new file, the copyright should just say 2025, I think
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
| 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| 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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
| 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| 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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
| 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| 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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
| register: result | ||
| delegate_to: localhost | ||
|
|
||
| - name: print debug data |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| - name: print debug data | |
| - name: Print migration validation results |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
| @@ -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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| 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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
|
|
||
| ## Role Variables | ||
|
|
||
| The only variable required is: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| The only variable required is: | |
| The following variables are required: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
|
|
||
| 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| - `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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
| 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| - `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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
| type: str | ||
| playbook_path: | ||
| description: | ||
| - The path to the directory containing one or more Ansible playbooks. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Question, will it analyze the playbooks recursively?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes.
| def load_playbook(path): | ||
| """Load playbook YAML and preserve line numbers.""" | ||
| try: | ||
| from ruamel.yaml import YAML |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you also uninstall it only if it was installed by this role?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested with multiple combinations
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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"
]
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks a lot!
fernandofloresg
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me thanks!


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