From d439564a7ed6e2dba9aa57042bcdd6a3664da045 Mon Sep 17 00:00:00 2001
From: Christopher Randles <randles.chris@gmail.com>
Date: Mon, 30 Mar 2020 04:13:53 -0400
Subject: [PATCH] disable gpgcheck if gpgkey is empty (#5621)

Signed-off-by: Chris Randles <randles.chris@gmail.com>
---
 roles/container-engine/containerd/tasks/containerd_repo.yml     | 2 +-
 .../container-engine/containerd/templates/rh_containerd.repo.j2 | 2 +-
 roles/container-engine/docker/tasks/main.yml                    | 2 +-
 roles/container-engine/docker/templates/fedora_docker.repo.j2   | 2 +-
 roles/container-engine/docker/templates/rh_docker.repo.j2       | 2 +-
 5 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/roles/container-engine/containerd/tasks/containerd_repo.yml b/roles/container-engine/containerd/tasks/containerd_repo.yml
index 6fbacb5d3..c141bfc4a 100644
--- a/roles/container-engine/containerd/tasks/containerd_repo.yml
+++ b/roles/container-engine/containerd/tasks/containerd_repo.yml
@@ -58,7 +58,7 @@
     state: present
     baseurl: "{{ extras_rh_repo_base_url }}"
     file: "extras"
-    gpgcheck: yes
+    gpgcheck: "{{ 'yes' if extras_rh_repo_gpgkey else 'no' }}"
     gpgkey: "{{ extras_rh_repo_gpgkey }}"
     keepcache: "{{ containerd_rpm_keepcache | default('1') }}"
     proxy: " {{ http_proxy | default('_none_') }}"
diff --git a/roles/container-engine/containerd/templates/rh_containerd.repo.j2 b/roles/container-engine/containerd/templates/rh_containerd.repo.j2
index 9161f921e..81f9c37d5 100644
--- a/roles/container-engine/containerd/templates/rh_containerd.repo.j2
+++ b/roles/container-engine/containerd/templates/rh_containerd.repo.j2
@@ -2,7 +2,7 @@
 name=Docker-CE Repository
 baseurl={{ docker_rh_repo_base_url }}
 enabled=1
-gpgcheck=1
+gpgcheck={{ '1' if docker_rh_repo_gpgkey else '0' }}
 keepcache={{ docker_rpm_keepcache | default('1') }}
 gpgkey={{ docker_rh_repo_gpgkey }}
 {% if http_proxy is defined %}proxy={{ http_proxy }}{% endif %}
diff --git a/roles/container-engine/docker/tasks/main.yml b/roles/container-engine/docker/tasks/main.yml
index b942fea67..85d50e576 100644
--- a/roles/container-engine/docker/tasks/main.yml
+++ b/roles/container-engine/docker/tasks/main.yml
@@ -120,7 +120,7 @@
     state: present
     baseurl: "{{ extras_rh_repo_base_url }}"
     file: "extras"
-    gpgcheck: yes
+    gpgcheck: "{{ 'yes' if extras_rh_repo_gpgkey else 'no' }}"
     gpgkey: "{{ extras_rh_repo_gpgkey }}"
     keepcache: "{{ docker_rpm_keepcache | default('1') }}"
     proxy: " {{ http_proxy | default('_none_') }}"
diff --git a/roles/container-engine/docker/templates/fedora_docker.repo.j2 b/roles/container-engine/docker/templates/fedora_docker.repo.j2
index 6525f1133..3958ff020 100644
--- a/roles/container-engine/docker/templates/fedora_docker.repo.j2
+++ b/roles/container-engine/docker/templates/fedora_docker.repo.j2
@@ -2,6 +2,6 @@
 name=Docker-CE Repository
 baseurl={{ docker_fedora_repo_base_url }}
 enabled=1
-gpgcheck=1
+gpgcheck={{ '1' if docker_fedora_repo_gpgkey else '0' }}
 gpgkey={{ docker_fedora_repo_gpgkey }}
 {% if http_proxy is defined %}proxy={{ http_proxy }}{% endif %}
diff --git a/roles/container-engine/docker/templates/rh_docker.repo.j2 b/roles/container-engine/docker/templates/rh_docker.repo.j2
index 9161f921e..81f9c37d5 100644
--- a/roles/container-engine/docker/templates/rh_docker.repo.j2
+++ b/roles/container-engine/docker/templates/rh_docker.repo.j2
@@ -2,7 +2,7 @@
 name=Docker-CE Repository
 baseurl={{ docker_rh_repo_base_url }}
 enabled=1
-gpgcheck=1
+gpgcheck={{ '1' if docker_rh_repo_gpgkey else '0' }}
 keepcache={{ docker_rpm_keepcache | default('1') }}
 gpgkey={{ docker_rh_repo_gpgkey }}
 {% if http_proxy is defined %}proxy={{ http_proxy }}{% endif %}
-- 
GitLab