mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-05-14 21:19:12 -07:00
Improve ansible-galaxy handling of role versions (#12904)
* Improve ansible-galaxy handling of role versions Ensure that role versions are considered when deciding whether or not to (re-)install a role. Issue a warning when the version of a dependency conflicts with the version of an already installed role Display what version of a role is being installed Show the versions when upgrading/downgrading a role. Implements #11266 * Improve force logic for galaxy version changes Ensure that force is required to change role versions
This commit is contained in:
parent
64432c8f7c
commit
5ee5593cbf
2 changed files with 30 additions and 7 deletions
|
@ -369,9 +369,19 @@ class GalaxyCLI(CLI):
|
|||
display.vvv('Installing role %s ' % role.name)
|
||||
# query the galaxy API for the role data
|
||||
|
||||
if role.install_info is not None and not force:
|
||||
display.display('- %s is already installed, skipping.' % role.name)
|
||||
continue
|
||||
if role.install_info is not None:
|
||||
if role.install_info['version'] != role.version:
|
||||
if force:
|
||||
display.display('- changing role %s from %s to %s' %
|
||||
(role.name, role.install_info['version'], role.version or "unspecified"))
|
||||
role.remove()
|
||||
else:
|
||||
display.warning('- %s (%s) is already installed - use --force to change version to %s' %
|
||||
(role.name, role.install_info['version'], role.version or "unspecified"))
|
||||
continue
|
||||
else:
|
||||
display.display('- %s is already installed, skipping.' % str(role))
|
||||
continue
|
||||
|
||||
try:
|
||||
installed = role.install()
|
||||
|
@ -392,14 +402,18 @@ class GalaxyCLI(CLI):
|
|||
# we know we can skip this, as it's not going to
|
||||
# be found on galaxy.ansible.com
|
||||
continue
|
||||
if dep_role.install_info is None or force:
|
||||
if dep_role.install_info is None:
|
||||
if dep_role not in roles_left:
|
||||
display.display('- adding dependency: %s' % dep_role.name)
|
||||
display.display('- adding dependency: %s' % str(dep_role))
|
||||
roles_left.append(dep_role)
|
||||
else:
|
||||
display.display('- dependency %s already pending installation.' % dep_role.name)
|
||||
else:
|
||||
display.display('- dependency %s is already installed, skipping.' % dep_role.name)
|
||||
if dep_role.install_info['version'] != dep_role.version:
|
||||
display.warning('- dependency %s from role %s differs from already installed version (%s), skipping' %
|
||||
(str(dep_role), role.name, dep_role.install_info['version']))
|
||||
else:
|
||||
display.display('- dependency %s is already installed, skipping.' % dep_role.name)
|
||||
|
||||
if not installed:
|
||||
display.warning("- %s was NOT installed successfully." % role.name)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue