Add the possibility to update packages from local rpms using yum.
This is needed if we want to only update installed packages and not hit depenency issues encountered when updating packages with rpm_install.sh Change-Id: I5095d7b04cb10fde1bd82afd1bc406445b7595fd Closes-bug: #1858837
This commit is contained in:
parent
c2a428db12
commit
22374eb422
21
README.rst
21
README.rst
|
@ -45,6 +45,10 @@ Role Variables
|
|||
* - `target_image`
|
||||
- `''`
|
||||
- See modify image variables
|
||||
* - `rpms_path`
|
||||
- `''`
|
||||
- If set, packages present in rpms_path will be updated but dependencies must also be included if required as yum
|
||||
is called with localupdate.
|
||||
* - `update_repo`
|
||||
- `''`
|
||||
- If set, packages from this repo will be updated. Other repos will only be used for dependencies of these updates.
|
||||
|
@ -195,6 +199,21 @@ In this playbook the tasks\_from is set as a variable instead of an
|
|||
modified_append_tag: updated
|
||||
container_build_tool: buildah # or docker
|
||||
yum_cache: /tmp/containers-updater/yum_cache
|
||||
rpms_path: /home/stack/rpms
|
||||
|
||||
.. code-block::
|
||||
|
||||
- hosts: localhost
|
||||
tasks:
|
||||
- name: include ansible-role-tripleo-modify-image
|
||||
import_role:
|
||||
name: ansible-role-tripleo-modify-image
|
||||
vars:
|
||||
tasks_from: yum_update.yml
|
||||
source_image: docker.io/tripleomaster/centos-binary-nova-api:latest
|
||||
modified_append_tag: updated
|
||||
container_build_tool: docker # or buildah
|
||||
rpms_path: /home/stack/rpms/
|
||||
|
||||
Note, if you have a locally installed gating repo, you can add
|
||||
``update_repo: gating-repo``. This may be the case for the consequent in-place
|
||||
|
@ -242,7 +261,7 @@ network connectivity.
|
|||
vars:
|
||||
tasks_from: rpm_install.yml
|
||||
source_image: docker.io/tripleomaster/centos-binary-nova-api:latest
|
||||
rpms_path: /foo/bar
|
||||
rpms_path: /home/stack/rpms
|
||||
modified_append_tag: -hotfix
|
||||
|
||||
Dev install
|
||||
|
|
|
@ -0,0 +1,20 @@
|
|||
---
|
||||
- name: List RPMs
|
||||
find:
|
||||
paths: "{{ rpms_path }}"
|
||||
patterns: "^.*?\\.rpm$"
|
||||
use_regex: true
|
||||
when: rpms_path is defined
|
||||
register: context_rpms
|
||||
|
||||
- name: Set rpms_list
|
||||
set_fact:
|
||||
rpms_list: "{{ context_rpms.files|json_query('[*].path') }}"
|
||||
when: rpms_path is defined
|
||||
|
||||
- name: Copy RPMs to context dir
|
||||
copy:
|
||||
src: "{{ item }}"
|
||||
dest: "{{ modify_dir_path }}"
|
||||
with_list: "{{ rpms_list }}"
|
||||
when: rpms_path is defined
|
|
@ -15,23 +15,7 @@
|
|||
set_fact:
|
||||
modify_dir_path: "{{ context_dir.path }}"
|
||||
|
||||
- name: List RPMs
|
||||
find:
|
||||
paths: "{{ rpms_path }}"
|
||||
patterns: "^.*?\\.rpm$"
|
||||
use_regex: true
|
||||
when: rpms_path is defined
|
||||
register: context_rpms
|
||||
|
||||
- name: Set rpms_list
|
||||
set_fact:
|
||||
rpms_list: "{{ context_rpms.files|json_query('[*].path') }}"
|
||||
|
||||
- name: Copy RPMs to context dir
|
||||
copy:
|
||||
src: "{{ item }}"
|
||||
dest: "{{ modify_dir_path }}"
|
||||
with_list: "{{ rpms_list }}"
|
||||
- import_tasks: copy_rpms.yml
|
||||
|
||||
- name: Write Dockerfile to {{ modify_dir_path }}
|
||||
template:
|
||||
|
|
|
@ -34,6 +34,8 @@
|
|||
set_fact:
|
||||
cache_path: /var/cache/{{ pkg_mgr.split('/')[-1] }}
|
||||
|
||||
- import_tasks: copy_rpms.yml
|
||||
|
||||
- name: Prepare yum_update.sh script
|
||||
template:
|
||||
src: yum_update.sh.j2
|
||||
|
@ -45,6 +47,7 @@
|
|||
args:
|
||||
chdir: "{{ yum_repos_dir_path }}"
|
||||
register: file_repos
|
||||
when: rpms_path is undefined
|
||||
|
||||
- name: Define bind-mount modes for yum cache to be populated or used
|
||||
when: yum_cache is defined and yum_cache
|
||||
|
|
|
@ -15,6 +15,8 @@
|
|||
set_fact:
|
||||
modify_dir_path: "{{ context_dir.path }}"
|
||||
|
||||
- import_tasks: copy_rpms.yml
|
||||
|
||||
- name: Copy local file repos to context directory
|
||||
shell: |
|
||||
#!/bin/sh
|
||||
|
@ -36,7 +38,7 @@
|
|||
done
|
||||
args:
|
||||
chdir: "{{ modify_dir_path }}"
|
||||
when: yum_repos_dir_path is defined
|
||||
when: yum_repos_dir_path is defined and rpms_path is undefined
|
||||
|
||||
- name: Write Dockerfile to {{ modify_dir_path }}
|
||||
template:
|
||||
|
|
|
@ -5,6 +5,10 @@ set -eou pipefail
|
|||
PKG={{ pkg_mgr }}
|
||||
PKG_MGR="$(echo ${PKG:(-3)})"
|
||||
|
||||
{% if rpms_path is defined %}
|
||||
$PKG -y localupdate /tmp/*.rpm
|
||||
rm -f /tmp/*.rpm
|
||||
{% else %}
|
||||
if [ $PKG_MGR == "dnf" ]; then
|
||||
REPOQUERY_CMD="$PKG repoquery"
|
||||
else
|
||||
|
@ -18,7 +22,6 @@ if [ -n "$1" ] && [[ -n $REPOQUERY_CMD ]]; then
|
|||
available_versions=$($REPOQUERY_CMD --quiet --provides --disablerepo='*' --enablerepo=$1 -a | sort || true)
|
||||
uptodate_versions=$(comm -12 <(printf "%s\n" "$installed_versions") <(printf "%s\n" "$available_versions"))
|
||||
|
||||
|
||||
installed=$(printf "%s\n" "$installed_versions" | cut -d= -f1 | sort)
|
||||
available=$(printf "%s\n" "$available_versions" | cut -d= -f1 | sort)
|
||||
uptodate=$(printf "%s\n" "$uptodate_versions" | cut -d= -f1 | sort)
|
||||
|
@ -32,7 +35,6 @@ if [ -z "$packages_for_update" ]; then
|
|||
exit
|
||||
fi
|
||||
|
||||
|
||||
if [ $PKG_MGR == "dnf" ]; then
|
||||
plugin=dnf-plugins-core
|
||||
else
|
||||
|
@ -46,8 +48,14 @@ fi
|
|||
YUM_OPTS="{% if yum_cache is defined and yum_cache %}--setopt=keepcache=1{% endif %}"
|
||||
|
||||
$PKG -y update $YUM_OPTS $packages_for_update
|
||||
{% endif %}
|
||||
|
||||
{% if yum_cache is defined and yum_cache %}
|
||||
sync
|
||||
{% else %}
|
||||
rm -rf /var/cache/$PKG_MGR
|
||||
{% endif %}
|
||||
|
||||
{% if container_build_tool is defined and container_build_tool == 'docker' %}
|
||||
rm -f /tmp/yum_install.sh
|
||||
{% endif %}
|
||||
|
|
Loading…
Reference in New Issue