Ansible role for built packages install

Take the repository comressed file, which was built by
build-test-packages role and install packages from it on live
host or inject them into the image with modify-image role.

Change-Id: I0305cfb917500a5890d74cadf9299d6538262282
This commit is contained in:
Sagi Shnaidman 2017-01-30 19:54:52 +02:00
parent 4114cc6849
commit d7757ec171
7 changed files with 130 additions and 0 deletions

View File

@ -0,0 +1,60 @@
install-built-repo
==================
Install built packages on host and/or within the image.
This Ansible role allows installation of packages which were built by DLRN
on a live host or within an image.
Requirements
------------
No requirements.
Role Variables
--------------
* `ib_repo_install_script` - path to repositories install script template
* `ib_repo_install_log` - path to repositories install script log
* `ib_repo_run_live`: false/true - where to run repo install script on host (live host that playbook runs on it) (default: true)
* `ib_gating_repo_enabled`: true/false - whether to enable built repo or not (default: true)
* `ib_repo_file_path`: path to compressed repo built by `build-test-packages` role
* `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
Dependencies
------------
* `modify-image` role in TripleO Quickstart extras repository
Example Playbook
----------------
Including an example of how to use this role
---
- name: Run repo install
hosts: undercloud
gather_facts: no
roles:
- install-built-repo
- name: Run repo install
hosts: undercloud
gather_facts: no
vars:
ib_repo_image_inject: true
ib_repo_image_path: "{{ working_dir }}/overcloud-full.qcow2"
roles:
- install-built-repo
License
-------
Apache 2.0
Author Information
------------------
OpenStack

View File

@ -0,0 +1,12 @@
---
ib_repo_workdir: '{{ working_dir }}'
ib_repo_install_script: install-built-repo.sh.j2
ib_repo_install_log: "{{ ib_repo_workdir }}/install_built_repo.log"
ib_repo_run_live: true
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
# Configure host where gate_repo files exists, if it's not the host
# where this role is executed
# ib_repo_host:

View File

@ -0,0 +1,2 @@
dependencies:
- extras-common

View File

@ -0,0 +1,9 @@
- name: Inject into image and install packages
include_role:
name: modify-image
vars:
image_to_modify: "{{ ib_repo_image_path }}"
modify_script: "{{ ib_repo_workdir }}/install-built-repo.sh"
modify_image_upload_files:
- src: "/tmp/gating_repo.tar.gz"
dest: "/tmp/gating_repo.tar.gz"

View File

@ -0,0 +1,5 @@
- name: Setup repos on live host
shell: >
{{ ib_repo_workdir }}/install-built-repo.sh >
{{ ib_repo_install_log }} 2>&1
become: true

View File

@ -0,0 +1,24 @@
- name: Create repo setup script
template:
src: "{{ ib_repo_install_script }}"
dest: "{{ ib_repo_workdir }}/install-built-repo.sh"
mode: 0755
- when: ib_repo_host is defined
block:
- name: Fetch repo to localhost
fetch: "src={{ ib_repo_file_path }} dest={{ local_working_dir }}/gating_repo.tar.gz flat=yes"
delegate_to: "{{ ib_repo_host }}"
- name: Upload repo to host for install
copy: "src={{ local_working_dir }}/gating_repo.tar.gz dest=/tmp/gating_repo.tar.gz"
- name: Copy compressed repo to /tmp
shell: cp -f {{ ib_repo_file_path }} /tmp/gating_repo.tar.gz
when: ib_repo_host is not defined
- include: install_built_repo.yml
when: ib_repo_run_live|bool
- include: inject_repo.yml
when: ib_repo_image_inject|bool

View File

@ -0,0 +1,18 @@
#!/bin/bash
mkdir -p /opt
pushd /opt
tar xzf /tmp/gating_repo.tar.gz
cat > /etc/yum.repos.d/gating.repo << EOF
[gating-repo]
name=Gating repository
baseurl=file:///opt/gating_repo
enabled={{ ib_gating_repo_enabled | bool | ternary('1', '0') }}
gpgcheck=0
priority=1
EOF
{% if ib_gating_repo_enabled|bool %}
yum --disablerepo="*" --enablerepo="gating-repo" update -y
{% endif %}