0

Problem: You have 2 (or more) playbooks, both of which use the ansible role xyz.very-useful-role. However, Playbook A uses version 2.x of the role, while (for whatever reason), Playbook B is stuck on version 1.x.

Ansible, however, does not distinguish between versions in the .ansible directory; which means that if Playbook A is run after Playbook B or vice versa, there is a risk that the playbook will be run on an incorrect version of the dependent role, leading to all kinds of subtle and not-so-subtle errors.

Is there a "best practice" for dealing with this problem?

Michael A.
  • 4,163
  • 3
  • 28
  • 47
  • hope so this help...https://github.com/ansible/ansible/issues/4357 – error404 Nov 07 '19 at 06:51
  • 1
    Thanks, but this looks like it is only for ansible itself, though. The problem I'm worried about is in the context of role dependencies. – Michael A. Nov 07 '19 at 08:10
  • 1
    Separate the playbooks and manage deps on each side in a well crafted `roles/requirements.yml`. Or modify either playbooks so they all use the same version of the role and keep them together. See [this answer](https://stackoverflow.com/questions/55773505/where-to-place-requirements-yml-for-ansible-and-use-it-to-resolve-dependencies/55774721#55774721) for a proposition on how to organise the project structure to manage that. – Zeitounator Nov 07 '19 at 08:15
  • That was an interesting link, thanks. – Michael A. Nov 07 '19 at 08:43
  • Migrate to using collections :) – webknjaz -- Слава Україні Nov 07 '19 at 10:50

1 Answers1

0

You are far better off avoiding the need to use different role versions.

Even if possible, your codebase would not be maintainable and you will spend more time wondering around than doing other stuff.

sorin
  • 161,544
  • 178
  • 535
  • 806