Make git2u swap idempotent 82/15982/4
authorAndrew Grimberg <agrimberg@linuxfoundation.org>
Tue, 25 Jun 2019 00:51:18 +0000 (10:51 +1000)
committerAndrew Grimberg <agrimberg@linuxfoundation.org>
Wed, 26 Jun 2019 16:02:28 +0000 (09:02 -0700)
Issue: RELENG-2143
Change-Id: Icba128bf8d775edd2b750f05c7662162fcdf9371
Signed-off-by: Andrew Grimberg <agrimberg@linuxfoundation.org>
Signed-off-by: Anil Belur <abelur@linuxfoundation.org>
provision/install-base-pkgs-RedHat.yaml

index 29cdc3b..5d6f49d 100644 (file)
@@ -8,17 +8,19 @@
       - https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
       - https://centos7.iuscommunity.org/ius-release.rpm
     state: latest
-  become: yes
+  become: true
 
-# yum-plugin-replace comes from ius and therefore must be a separate step
-- name: Install yum-plugin-replace
-  yum:
-    name: yum-plugin-replace
-    state: latest
-    update_cache: yes
-  become: yes
-
-# calling yum replace is not possible via standard ansible
-- name: Switch to git2u
-  shell: yum -y replace git --replace-with git2u
-  become: yes
+- name: Swap to git2u
+  block:
+    - name: Install yum-plugin-replace
+      yum:
+        name: yum-plugin-replace
+        state: present
+        update_cache: true
+    - name: Gather rpm package facts
+      package_facts:
+        manager: auto
+    - name: Replace git with git2u
+      command: yum replace -y git --replace-with git2u
+      when: ansible_facts.packages['git'] is defined
+  become: true