Skip to content

Conversation

@surendrababuravella
Copy link
Collaborator

SUMMARY

A role that automatically scans the playbooks in the directory and advises of migration actions

ISSUE TYPE
  • Role Pull Request
COMPONENT NAME
ADDITIONAL INFORMATION

@surendrababuravella surendrababuravella marked this pull request as ready for review November 10, 2025 08:30
@surendrababuravella
Copy link
Collaborator Author

surendrababuravella commented Nov 10, 2025

SPS pipeline results:

Screenshot 2025-11-12 at 3 43 42 PM Screenshot 2025-11-12 at 3 44 55 PM

richp405
richp405 previously approved these changes Nov 10, 2025
Copy link
Collaborator

@rexemin rexemin left a 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"
Copy link
Collaborator

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"

Copy link
Collaborator Author

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
Copy link
Collaborator

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

Copy link
Collaborator Author

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.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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.

Copy link
Collaborator Author

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.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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.

Copy link
Collaborator Author

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.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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.

Copy link
Collaborator Author

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
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- name: print debug data
- name: Print migration validation results

Copy link
Collaborator Author

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.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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.

Copy link
Collaborator Author

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:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
The only variable required is:
The following variables are required:

Copy link
Collaborator Author

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.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- `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.

Copy link
Collaborator Author

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.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- `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.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@fernandofloresg
Copy link
Collaborator

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

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 library given the project tree:

roles/
    common/               # this hierarchy represents a "role"
        tasks/            #
            main.yml      #  <-- tasks file can include smaller files if warranted
        handlers/         #
            main.yml      #  <-- handlers file
        templates/        #  <-- files for use with the template resource
            ntp.conf.j2   #  <------- templates end in .j2
        files/            #
            bar.txt       #  <-- files for use with the copy resource
            foo.sh        #  <-- script files for use with the script resource
        vars/             #
            main.yml      #  <-- variables associated with this role
        defaults/         #
            main.yml      #  <-- default lower priority variables for this role
        meta/             #
            main.yml      #  <-- role dependencies
        library/          # roles can also include custom modules
        module_utils/     # roles can also include custom module_utils
        lookup_plugins/   # or other types of plugins, like lookup in this case

    webtier/              # same kind of structure as "common" was above, done for the webtier role
    monitoring/           # ""
    fooapp/               # ""

Copy link
Collaborator

@fernandofloresg fernandofloresg left a 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.
Copy link
Collaborator

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.

Copy link
Collaborator Author

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.
Copy link
Collaborator

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?

Copy link
Collaborator Author

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
Copy link
Collaborator

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?

Copy link
Collaborator

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
Copy link
Collaborator

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?

Copy link
Collaborator

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?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested with multiple combinations

Copy link
Collaborator Author

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"
    ]
  }

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot!

Copy link
Collaborator

@fernandofloresg fernandofloresg left a 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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants