From 821fcbf6c9df7a3a822348e6d1b751baf4074aed Mon Sep 17 00:00:00 2001 From: Steve Baker Date: Wed, 5 Sep 2018 16:34:33 +1200 Subject: [PATCH] Don't use copy module for /etc/yum.repos.d Ansible copy is slow for multiple files. Using cp instead saves about 5 seconds in this case, which adds up over many images. Change-Id: I74eedd89657bc4daddb2d45d692e1270c567705a --- tasks/yum_update.yml | 9 ++------- templates/Dockerfile-yum.j2 | 2 +- 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/tasks/yum_update.yml b/tasks/yum_update.yml index fc142ec..cf7e428 100644 --- a/tasks/yum_update.yml +++ b/tasks/yum_update.yml @@ -14,18 +14,13 @@ set_fact: modify_dir_path: "{{ context_dir.path }}" - -- name: Copy directory used for /etc/yum.repos.d - copy: - src: "{{ yum_repos_dir_path }}" - dest: "{{ modify_dir_path }}/yum.repos.d" - when: yum_repos_dir_path is defined - - name: Copy local file repos to context directory shell: | #!/bin/sh set -ex + cp -a {{ yum_repos_dir_path }} {{ modify_dir_path }}/yum.repos.d + # discover repos with local packages repos=$(sed -n 's/baseurl=file:\/\///p' {{ yum_repos_dir_path }}/*.repo) diff --git a/templates/Dockerfile-yum.j2 b/templates/Dockerfile-yum.j2 index e236212..ca61564 100644 --- a/templates/Dockerfile-yum.j2 +++ b/templates/Dockerfile-yum.j2 @@ -8,7 +8,7 @@ COPY compare-package-json.py /tmp/ {% if yum_repos_dir_path is defined %} RUN rm -rf /etc/yum.repos.d/ -COPY yum.repos.d /etc/ +COPY yum.repos.d /etc/yum.repos.d COPY repos / {% endif %}