Skip to main content

ansible-tripleo-modify-image - Ansible role to allow modification to container images built for the TripleO project.

Project description

A role to allow modification to container images built for the TripleO project.

Role Variables

Variables used for modify image

Name

Default Value

Description

source_image

[undefined]

Mandatory fully qualified reference to the source image to be modified. The supplied Dockerfile will be copied and modified to make the FROM directive match this variable.

modify_dir_path

[undefined]

Mandatory path to the directory containing the Dockerfile to modify the image

modified_append_tag

date +-modified-%Y%m%d%H%M%S

String to be appended after the tag to indicate this is a modified version of the source image.

target_image

[undefined]

If set, the modified image will be tagged with target_image + modified_append_tag. If target_image is not set, the modified image will be tagged with source_image + modified_append_tag. If the purpose of the image is not changing, it may be enough to rely on the source_image + modified_append_tag tag to identify that this is a modified version of the source image.

container_build_tool

docker

Tool used to build containers, can be ‘docker’ or ‘buildah’

Variables used for yum update

Name

Default Value

Description

source_image

[undefined]

See modify image variables

modified_append_tag

date +-modified-%Y%m%d%H%M%S

See modify image 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.

yum_repos_dir_path

None

Optional path of directory to be used as /etc/yum.repos.d during the update

container_build_tool

docker

See modify image variables

yum_cache

None

Optional path to the host directory for yum cache during the update. Requires an overlay-enabled FS that also supports SE context relabling. Works only with container_build_tool=buildah.

force_purge_yum_cache

False

Optional argument that tells buildah to forcefully re-populate the yum cache with new contents.

Variables used for yum install

Name

Default Value

Description

source_image

[undefined]

See modify image variables

modified_append_tag

date +-modified-%Y%m%d%H%M%S

See modify image variables

target_image

‘’

See modify image variables

yum_packages

[]

Provide a list of packages to install via yum

yum_repos_dir_path

None

Optional path of directory to be used as /etc/yum.repos.d during the update

container_build_tool

docker

See modify image variables

Variables used for dev install

Name

Default Value

Description

source_image

[undefined]

See modify image variables

modified_append_tag

date +-modified-%Y%m%d%H%M%S

See modify image variables

target_image

‘’

See modify image variables

container_build_tool

docker

See modify image variables

refspecs

[]

An array of project/refspec pairs that will be installed into the generated container. Currently only supports python source projects.

python_dir

[]

Directory which contains a Python project ready to be installed with pip.

Requirements

  • ansible >= 2.4

  • python >= 2.6

  • docker-py >= 1.7.0

  • Docker API >= 1.20

Dependencies

None

Example Playbooks

Modify Image

The following playbook will produce a modified image with the tag :latest-modified-<timestamp> based on the Dockerfile in the custom directory /path/to/example_modify_dir.

- hosts: localhost
  tasks:
  - name: include ansible-role-tripleo-modify-image
    import_role:
      name: ansible-role-tripleo-modify-image
      tasks_from: modify_image.yml
    vars:
      source_image: docker.io/tripleomaster/centos-binary-nova-api:latest
      modify_dir_path: /path/to/example_modify_dir
      container_build_tool: docker # or buildah

The directory example_modify_dir contains the Dockerfile which will perform the modification, for example:

# This will be replaced in the file Dockerfile.modified
FROM centos-binary-nova-api

# switch to root to install packages
USER root

# install packages
RUN curl "https://bootstrap.pypa.io/get-pip.py" -o "/tmp/get-pip.py"
RUN python /tmp/get-pip.py

# switch the container back to the default user
USER nova

Yum update

The following playbook will produce a modified image with the tag :latest-updated which will do a yum update using the host’s /etc/yum.repos.d. Only file repositories will be used (with baseurl=file://…). In this playbook the tasks_from is set as a variable instead of an import_role parameter.

- 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
      yum_repos_dir_path: /etc/yum.repos.d
      modified_append_tag: updated
      container_build_tool: buildah # or docker
      yum_cache: /tmp/containers-updater/yum_cache
      rpms_path: /home/stack/rpms
- 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 deployments, like those performed with the CI reproducer script.

Yum install

The following playbook will produce a modified image with the tag :latest-updated which will do a yum install of the requested packages using the host’s /etc/yum.repos.d. In this playbook the tasks_from is set as a variable instead of an import_role parameter.

- hosts: localhost
  tasks:
  - name: include ansible-role-tripleo-modify-image
    import_role:
      name: ansible-role-tripleo-modify-image
    vars:
      tasks_from: yum_install.yml
      source_image: docker.io/tripleomaster/centos-binary-nova-api:latest
      yum_repos_dir_path: /etc/yum.repos.d
      yum_packages: ['foobar-nova-plugin', 'fizzbuzz-nova-plugin']
      container_build_tool: docker # or buildah

RPM install

The following playbook will produce a modified image with RPMs from the specified rpms_path on the local filesystem installed as a new layer for the container. The new container tag is appened with the ‘-hotfix’ suffix. Useful for creating adhoc hotfix containers with local RPMs with no network connectivity.

- hosts: localhost
  tasks:
  - name: include ansible-role-tripleo-modify-image
    import_role:
      name: ansible-role-tripleo-modify-image
    vars:
      tasks_from: rpm_install.yml
      source_image: docker.io/tripleomaster/centos-binary-nova-api:latest
      rpms_path: /home/stack/rpms
      modified_append_tag: -hotfix

Dev install

The following playbook will produce a modified image with Python source code installed via pip. To minimize dependencies within the container we generate the sdist locally and then copy it into the resulting container image as an sdist tarball to run pip install locally.

It can be used to pull a review from OpenDev Gerrit:

- hosts: localhost
  connection: local
  tasks:
  - name: dev install heat-api
    import_role:
      name: ansible-role-tripleo-modify-image
    vars:
      tasks_from: dev_install.yml
      source_image: docker.io/tripleomaster/centos-binary-heat-api:current-tripleo
      refspecs:
        -
          project: heat
          refspec: refs/changes/12/1234/3
      modified_append_tag: -devel

or it can be used to build an image from a local Python directory:

- hosts: localhost
  connection: local
  tasks:
  - name: dev install heat-api
    import_role:
      name: ansible-role-tripleo-modify-image
    vars:
      tasks_from: dev_install.yml
      source_image: docker.io/tripleomaster/centos-binary-heat-api:current-tripleo
      modified_append_tag: -devel
      python_dir:
        - /home/joe/git/openstack/heat

License

Apache 2.0

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

Built Distribution

ansible_role_tripleo_modify_image-1.2.1-py2.py3-none-any.whl (24.9 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file ansible-role-tripleo-modify-image-1.2.1.tar.gz.

File metadata

  • Download URL: ansible-role-tripleo-modify-image-1.2.1.tar.gz
  • Upload date:
  • Size: 18.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.24.0 setuptools/50.3.0 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.7.8

File hashes

Hashes for ansible-role-tripleo-modify-image-1.2.1.tar.gz
Algorithm Hash digest
SHA256 c55f48e35b6984c16ec80b336a213e408f1516bc7d5eb6e7dd036d343e40b270
MD5 a99ec176f7d8f22fa748427ed96c1392
BLAKE2b-256 49d6e8ea22552d97c738bbf53486d8a986ef153804e14d62fee884c7f10bca69

See more details on using hashes here.

Provenance

File details

Details for the file ansible_role_tripleo_modify_image-1.2.1-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for ansible_role_tripleo_modify_image-1.2.1-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 ec37da546907966f7ed25f300a9651e610714b954b7cf0bdea1d01cfb0c5546c
MD5 f476e9588c1745791b288dbd47e0579c
BLAKE2b-256 d1991afeb7d92731eb998d5ff064709ebea9f1e7ce51059454d1e74ffb2954f9

See more details on using hashes here.

Provenance

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page