-
Notifications
You must be signed in to change notification settings - Fork 46
[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?
Changes from 4 commits
965ea6e
ab87f16
ebd1e8c
6d8f492
b4b21a8
36cecdf
d56aa14
0fb61d4
64d56ca
4481b9d
f5d553d
dcdaf2f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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. | ||
| (https://github.com/ansible-collections/ibm_zos_core/pull/2399) | ||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,285 @@ | ||||||
| #!/usr/bin/python | ||||||
| # -*- coding: utf-8 -*- | ||||||
|
|
||||||
| # Copyright (c) IBM Corporation 2023, 2025 | ||||||
|
||||||
| # Licensed under the Apache License, Version 2.0 (the "License"); | ||||||
| # you may not use this file except in compliance with the License. | ||||||
| # You may obtain a copy of the License at | ||||||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||||||
| # Unless required by applicable law or agreed to in writing, software | ||||||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||||||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||||||
| # See the License for the specific language governing permissions and | ||||||
| # limitations under the License. | ||||||
| from __future__ import absolute_import, division, print_function | ||||||
| __metaclass__ = type | ||||||
|
|
||||||
| DOCUMENTATION = r''' | ||||||
| --- | ||||||
| module: playbook_upgrade_validator | ||||||
| version_added: "1.0.0" | ||||||
|
||||||
| author: | ||||||
| - "Ravella Surendra Babu (@surendrababuravella)" | ||||||
| short_description: Validates playbooks against ibm_zos_core 2.0 and provides migration actions. | ||||||
|
||||||
| 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
Outdated
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
Outdated
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
Outdated
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.
| - File path where validation results should be written in JSON format. | |
| - 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.
Updated line
Outdated
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.
Outdated
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.
| - Designed to assist migration of playbooks from older IBM z/OS core collection versions to 2.0. | |
| - Designed to assist migration of playbooks from older IBM z/OS core collection versions 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
Outdated
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.
| - Always false as there is no state changes happen in this process. | |
| - Always false as there are no state changes happening in this process. |
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
Outdated
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.
| description: File path where validation results should be written in JSON format. | |
| description: File path where validation results were 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
Outdated
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.
I would instead write something like
Path that was scanned for 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.
updated description
Outdated
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.
| module.fail_json(msg=f"Failed to write output into file: {str(e)}") | |
| module.fail_json(msg=f"Failed to write output to file: {str(e)}") |
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
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -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. | ||||||
|
||||||
| 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
Outdated
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
Outdated
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
Outdated
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,93 @@ | ||
| # Copyright (c) IBM Corporation 2023, 2025 | ||
| # Licensed under the Apache License, Version 2.0 (the "License"); | ||
| # you may not use this file except in compliance with the License. | ||
| # You may obtain a copy of the License at | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
|
|
||
| DOCUMENTATION = r''' | ||
| --- | ||
| module: playbook_upgrade_validator | ||
| version_added: "1.0.0" | ||
| author: | ||
| - "Ravella Surendra Babu (@surendrababuravella)" | ||
| 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. | ||
| - Provides line numbers, affected modules, and suggested corrective actions. | ||
| options: | ||
| ignore_response_params: | ||
| description: | ||
| - Indicates whether information about response parameter changes should be included. | ||
| default: false | ||
| type: bool | ||
| 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. | ||
| required: true | ||
| type: dict | ||
| output_path: | ||
| description: | ||
| - File path where validation results should be written in JSON format. | ||
| required: true | ||
| type: str | ||
| playbook_path: | ||
| description: | ||
| - The path to the directory containing one or more Ansible playbooks. | ||
| required: true | ||
| type: str | ||
| notes: | ||
| - Designed to assist migration of playbooks from older IBM z/OS core collection versions to 2.0. | ||
| - Supports reading tasks, blocks, and nested includes. | ||
| ''' | ||
|
|
||
| EXAMPLES = r''' | ||
| - name: execute playbook_upgrade_validator role | ||
| include_role: | ||
| name: ibm.ibm_zos_core.playbook_upgrade_validator | ||
| vars: | ||
| playbook_path: "/path/to/playbooks/*.yml" | ||
| output_path: "/path/to/reports/validation_report.json" | ||
| ignore_response_params: false | ||
| ''' | ||
|
|
||
| RETURN = r''' | ||
| changed: | ||
| description: | ||
| - Always false as there is no state changes happen in this process. | ||
| returned: always | ||
| type: bool | ||
| output_path: | ||
| description: File path where validation results should be written in JSON format. | ||
| returned: always | ||
| type: str | ||
| playbook_path: | ||
| description: The path to the directory containing one or more Ansible playbooks. | ||
| returned: always | ||
| type: str | ||
| results: | ||
| description: List of issues identified in all scanned playbooks, along with detailed information. | ||
| returned: always | ||
| type: list | ||
| sample: | ||
| [ | ||
| { | ||
| "line": 9, | ||
| "migration_actions": [ | ||
| "[MUST_FIX] Param 'force_lock' is renamed to 'force' in zos_copy", | ||
| "[MUST_FIX] Param 'is_binary' is renamed to 'binary' in zos_copy", | ||
| "[MUST_FIX] Param 'force' is renamed to 'replace' in zos_copy" | ||
| ], | ||
| "module": "zos_copy", | ||
| "play_name": "Execute z/OS modules", | ||
| "playbook": "/path/to/playbook/copy_file.yml", | ||
| "task_name": "copy file to z/os" | ||
| } | ||
| ] | ||
| ''' |
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
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