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
This commit is contained in:
Sagi Shnaidman 2017-03-30 17:31:26 +03:00
parent 2016fe7ac1
commit 1792332d0c
4 changed files with 21 additions and 2 deletions

View File

@ -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"

View File

@ -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
------------

View File

@ -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:
# ib_repo_host:

View File

@ -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 %}