From 1792332d0cd80037545cdbebe0ca7d1928781727 Mon Sep 17 00:00:00 2001 From: Sagi Shnaidman Date: Thu, 30 Mar 2017 17:31:26 +0300 Subject: [PATCH] Use web repo with installed packages for image build When building images we need to supply repo with built packages to DIB so it will use when installing packages on the image. Because DIB is in a chrooted environment we have to use repo in network. This patch runs a webserver on the directory of the repository to make it accessible over HTTP on port 8766. Change-Id: I7b21d3ff1ec7cecab322e599cb929259f5a7256e --- roles/build-images/defaults/main.yml | 2 +- roles/install-built-repo/README.md | 1 + roles/install-built-repo/defaults/main.yml | 3 ++- .../templates/install-built-repo.sh.j2 | 17 +++++++++++++++++ 4 files changed, 21 insertions(+), 2 deletions(-) diff --git a/roles/build-images/defaults/main.yml b/roles/build-images/defaults/main.yml index b56cb6842..07150101f 100644 --- a/roles/build-images/defaults/main.yml +++ b/roles/build-images/defaults/main.yml @@ -16,7 +16,7 @@ package_images: true overcloud_repo_paths: - "$(ls /etc/yum.repos.d/delorean*)" - "$(ls /etc/yum.repos.d/CentOS-Ceph-*)" - - "$(ls /etc/yum.repos.d/gating.repo)" + - "$(ls {{working_dir}}/web-gating.repo)" image_build_yaml_paths: - "/usr/share/tripleo-common/image-yaml/overcloud-images-centos7.yaml" - "/usr/share/tripleo-common/image-yaml/overcloud-images.yaml" diff --git a/roles/install-built-repo/README.md b/roles/install-built-repo/README.md index 3cb706a26..164636d10 100644 --- a/roles/install-built-repo/README.md +++ b/roles/install-built-repo/README.md @@ -21,6 +21,7 @@ Role Variables * `ib_repo_image_inject`: false/true - where to inject and run repo install script on specified image (default: false) * `ib_repo_image_path`: path to image, in case of injecting repositories into the image * `ib_repo_host`: host where built repo exists, if it's not the same host where this roles runs +* `ib_create_web_repo`: false/true - Create web accessible repository in directory with built packages (default: false) Dependencies ------------ diff --git a/roles/install-built-repo/defaults/main.yml b/roles/install-built-repo/defaults/main.yml index 945093488..63314cfcf 100644 --- a/roles/install-built-repo/defaults/main.yml +++ b/roles/install-built-repo/defaults/main.yml @@ -7,6 +7,7 @@ ib_repo_file_path: "{{ ib_repo_workdir}}/gating_repo.tar.gz" ib_repo_image_inject: false ib_repo_image_path: "{{ ib_repo_workdir }}/overcloud-full.qcow2" ib_gating_repo_enabled: true +ib_create_web_repo: false # Configure host where gate_repo files exists, if it's not the host # where this role is executed -# ib_repo_host: \ No newline at end of file +# ib_repo_host: diff --git a/roles/install-built-repo/templates/install-built-repo.sh.j2 b/roles/install-built-repo/templates/install-built-repo.sh.j2 index affd82138..2a28dee72 100644 --- a/roles/install-built-repo/templates/install-built-repo.sh.j2 +++ b/roles/install-built-repo/templates/install-built-repo.sh.j2 @@ -1,4 +1,5 @@ #!/bin/bash +set -x mkdir -p /opt pushd /opt @@ -13,6 +14,22 @@ gpgcheck=0 priority=1 EOF +{% if ib_create_web_repo|bool %} +ps -ef | grep -i python | grep SimpleHTTPServer | awk '{print $2}' | xargs --no-run-if-empty kill -9 || true +pushd /opt/gating_repo +iptables -I INPUT -p tcp --dport 8766 -j ACCEPT +nohup python -m SimpleHTTPServer 8766 1>{{ working_dir }}/yum_mirror.log 2>{{ working_dir }}/yum_mirror_error.log & +popd +cat > {{ working_dir }}//web-gating.repo << EOF +[gating-repo] +name=Gating repository +baseurl=http://localhost:8766/ +enabled={{ ib_gating_repo_enabled | bool | ternary('1', '0') }} +gpgcheck=0 +priority=1 +EOF +{% endif %} + {% if ib_gating_repo_enabled|bool %} yum --enablerepo="gating-repo" update -y {% endif %}