Blob Blame History Raw
From e4fae653daa2fc66f5aee63ab4b523f79809fb19 Mon Sep 17 00:00:00 2001
From: Michael Scherer <mscherer@users.noreply.github.com>
Date: Fri, 21 Apr 2017 13:40:47 +0200
Subject: [PATCH] Fix --force for unversionned requirements (#23391)

In current stable (2.2), ansible galaxy install --force do erase
a role, even if the version is not set. This commit should restore
that specific behavior, in accordance to people reports:
  https://github.com/ansible/ansible/issues/11266#issuecomment-273801480

It was also the behavior planned in the initial discussion:
"if you're not fixing versions in your roles file, then it's fine
to expect that the role will be reinstalled each time you run
ansible-galaxy install.", cf https://github.com/ansible/ansible/pull/12904
(cherry picked from commit 78836ec0b9719a62fa0f8619707a9f411ed4a4f0)
---
 lib/ansible/cli/galaxy.py | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/lib/ansible/cli/galaxy.py b/lib/ansible/cli/galaxy.py
index 143fd80..da371e4 100644
--- a/lib/ansible/cli/galaxy.py
+++ b/lib/ansible/cli/galaxy.py
@@ -379,8 +379,9 @@ class GalaxyCLI(CLI):
                                         (role.name, role.install_info['version'], role.version or "unspecified"))
                         continue
                 else:
-                    display.display('- %s is already installed, skipping.' % str(role))
-                    continue
+                    if not force:
+                        display.display('- %s is already installed, skipping.' % str(role))
+                        continue
 
             try:
                 installed = role.install()
-- 
2.9.4