Re-Use role To Complete multi-stage Upgrade

Somewhat new to Ansible Roles and I can’t sort it out in my head how to do this.

I have a situation where I need to upgrade 2 target devices from software code v1 → v2 and once that is completed on both devices, then upgrade the devices from from software code v2 → v3

The role I have is structured like this

  • { role: “init”, when: (upgrade_success == true | bool) }
  • { role: “pre-upgrade”, when: (upgrade_success == true | bool) }
  • { role: “upgrade”, when: (upgrade_success == true | bool) }
  • { role: “post-upgrade”, when: (upgrade_success == true | bool) }

I have a variable defined ‘ISO_IMAGE_1’ that installs the v2 software and this role completes normally for the upgrade from v1 → v2

What I would like to do is re-use this same role roles above for upgrading from v2 → v3 and when this role is run a 2nd time, I’d like to pass the variable ‘ISO_IMAGE_2’.

2 questions