From 499eb6fe2167fcf4c5c1687e828c39c896b2c618 Mon Sep 17 00:00:00 2001 From: Major Hayden Date: Tue, 12 Dec 2017 11:06:36 -0600 Subject: [PATCH] Create and use a local LXC RPM repo CentOS deployments require a special COPR repository for modern LXC packages. The COPR repository isn't mirrored at this time and this causes failed gate tests and production deployments. The role now syncs the LXC packages down from COPR to each host and builds a local LXC package repository in `/opt/thm-lxc2.0`. This greatly reduces the amount of times that packages must be downloaded from the COPR server during deployments, which will reduce failures until the packages can be hosted with a more reliable source. In addition, this should speed up playbook runs since ``yum`` can check a locally-hosted repository instead of a remote repository with availability and performance challenges. Partial-Bug: 1730380 Change-Id: I8726b46f4058bb67709246785c7a61278eb64fab --- ...l-lxc-package-mirror-843e1ceac2469547.yaml | 16 ++++++++++ tasks/lxc_install_yum.yml | 29 +++++++++++++++++-- vars/redhat-7.yml | 2 +- 3 files changed, 44 insertions(+), 3 deletions(-) create mode 100644 releasenotes/notes/centos-local-lxc-package-mirror-843e1ceac2469547.yaml diff --git a/releasenotes/notes/centos-local-lxc-package-mirror-843e1ceac2469547.yaml b/releasenotes/notes/centos-local-lxc-package-mirror-843e1ceac2469547.yaml new file mode 100644 index 00000000..233d11c9 --- /dev/null +++ b/releasenotes/notes/centos-local-lxc-package-mirror-843e1ceac2469547.yaml @@ -0,0 +1,16 @@ +--- +other: + - | + CentOS deployments require a special COPR repository for modern LXC + packages. The COPR repository is not mirrored at this time and this causes + failed gate tests and production deployments. + + The role now syncs the LXC packages down from COPR to each host and builds + a local LXC package repository in `/opt/thm-lxc2.0`. This greatly reduces + the amount of times that packages must be downloaded from the COPR server + during deployments, which will reduce failures until the packages can be + hosted with a more reliable source. + + In addition, this should speed up playbook runs since ``yum`` can check a + locally-hosted repository instead of a remote repository with availability + and performance challenges. diff --git a/tasks/lxc_install_yum.yml b/tasks/lxc_install_yum.yml index 027e8bfa..f214614d 100644 --- a/tasks/lxc_install_yum.yml +++ b/tasks/lxc_install_yum.yml @@ -13,12 +13,29 @@ # See the License for the specific language governing permissions and # limitations under the License. -- name: Deploy COPR yum repo for LXC 2.0 +- name: Ensure createrepo package is installed + yum: + name: createrepo + state: latest + +- name: Deploy upstream COPR yum repo for LXC 2.0 yum_repository: name: thm-lxc2.0 description: "COPR repository for LXC 2.0 packages on CentOS 7" baseurl: "{{ lxc_centos_package_baseurl }}" - enabled: yes + enabled: no + gpgcheck: yes + gpgkey: "{{ lxc_centos_package_key }}" + repo_gpgcheck: no + priority: 50 + state: present + +- name: Deploy local COPR yum repo for LXC 2.0 + yum_repository: + name: thm-lxc2.0-local + description: "Local repository for LXC 2.0 packages on CentOS 7" + baseurl: "file:///opt/thm-lxc2.0" + enabled: no gpgcheck: yes gpgkey: "{{ lxc_centos_package_key }}" repo_gpgcheck: no @@ -50,6 +67,14 @@ retries: 5 delay: 2 +- name: Create and enable local LXC package repository + command: "{{ item }}" + with_items: + - "reposync --repoid=thm-lxc2.0 --download_path=/tmp/" + - "createrepo /tmp/thm-lxc2.0" + - "rsync -a --delete /tmp/thm-lxc2.0/ /opt/thm-lxc2.0/" + - "yum-config-manager --enable thm-lxc2.0-local" + - name: Install distro packages package: pkg: "{{ lxc_hosts_distro_packages }}" diff --git a/vars/redhat-7.yml b/vars/redhat-7.yml index 3b681137..f4a66c82 100644 --- a/vars/redhat-7.yml +++ b/vars/redhat-7.yml @@ -60,7 +60,7 @@ lxc_cache_map: {% endfor %} rpm --import /etc/pki/rpm-gpg/* # The containers do not need the LXC repository (only hosts need it). - rm -f /etc/yum.repos.d/thm-lxc2.0.repo + rm -f /etc/yum.repos.d/thm-lxc2.0* # Prefer dnf over yum for CentOS. which dnf &>/dev/null && RHT_PKG_MGR='dnf' || RHT_PKG_MGR='yum' # Create yum/dnf transaction file and run it all at once