Merge "Add container image push role"

This commit is contained in:
Zuul
2020-01-15 09:09:59 +00:00
committed by Gerrit Code Review
6 changed files with 150 additions and 0 deletions

View File

@@ -0,0 +1,58 @@
tripleo-container-image-push
============================
A role to perform the container image push against a registry.
Requirements
------------
None.
Role Variables
--------------
* `tripleo_container_image_push_append_tag`: (String) Tag to append to the existing tag when pushing the container.
* `tripleo_container_image_push_become`: (Boolean) Run the command as root. This needs to be true when uploading to the local undercloud registry. Default: true
* `tripleo_container_image_push_cleanup`: (Boolean) Remove local copy of the image after uploading. Default: false
* `tripleo_container_image_push_debug`: (Boolean) Flag to print out the push command. Default: False
* `tripleo_container_image_push_dry_run`: (Boolean) Perform a dry run upload which will exercise the authentication process but not upload the container. Default: false
* `tripleo_container_image_push_image`: (String) REQUIRED. Container image to upload. Should be in the form of <registry>/<namespace>/<name>:tag. If the tag is not provided, 'latest' is used.
* `tripleo_container_image_push_local`: (Boolean) Use this flag if teh container image is already on the current system and does not need to be pulled from a remote registry. Default: false
* `tripleo_container_image_push_multi_arch`: (Boolean) Enable multi arch support for the upload. Default: false
* `tripleo_container_image_push_password`: (String) Password for the registry
* `tripleo_container_image_push_registry_url`: (String) URL of the destiantionr egistry in the form <fqdn>:<port>.
* `tripleo_container_image_push_timeout`: (Number) Amount of time to wait for the command to conplete. Default: 360
* `tripleo_container_image_push_username`: (String) Username for the registry
Output Variables
----------------
* `tripleo_container_image_push_result`: Ansible execution results
Dependencies
------------
None.
Example Playbook
----------------
Example container push execution playbook
- hosts: undercloud
gather_facts: true
tasks:
- name: Push a container
import_role:
name: tripleo-container-image-push
vars:
tripleo_container_image_push_image: docker.io/library/centos:7
- name: Print output
debug:
var: tripleo_container_image_push_output
License
-------
Apache-2.0

View File

@@ -0,0 +1,13 @@
---
# defaults file for tripleo-container-image-push
tripleo_container_image_push_append_tag:
tripleo_container_image_push_become: true
tripleo_container_image_push_cleanup: false
tripleo_container_image_push_debug: false
tripleo_container_image_push_dry_run: false
tripleo_container_image_push_local: false
tripleo_container_image_push_multi_arch: false
tripleo_container_image_push_password:
tripleo_container_image_push_registry_url:
tripleo_container_image_push_timeout: 360
tripleo_container_image_push_username:

View File

@@ -0,0 +1,42 @@
---
# Copyright 2019 Red Hat, Inc.
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
galaxy_info:
author: OpenStack
description: TripleO Operator Role -- tripleo-container-image-push
company: Red Hat
license: Apache-2.0
min_ansible_version: 2.8
#
# Provide a list of supported platforms, and for each platform a list of versions.
# If you don't wish to enumerate all versions for a particular platform, use 'all'.
# To view available platforms and versions (or releases), visit:
# https://galaxy.ansible.com/api/v1/platforms/
#
platforms:
- name: CentOS
versions:
- 7
- 8
galaxy_tags:
- tripleo
# List your role dependencies here, one per line. Be sure to remove the '[]' above,
# if you add dependencies to this list.
dependencies: []

View File

@@ -0,0 +1,28 @@
---
# tasks file for tripleo-container-image-push
- name: Setup container image push facts
set_fact:
_push_cmd: >-
openstack tripleo container image push
{{ tripleo_container_image_push_local | ternary('--local', '') }}
{{ tripleo_container_image_push_registry_url | ternary('--registry-url ' ~ tripleo_container_image_push_registry_url, '') }}
{{ tripleo_container_image_push_append_tag | ternary('--append-tag ' ~ tripleo_container_image_push_append_tag, '') }}
{{ tripleo_container_image_push_username | ternary('--username ' ~ tripleo_container_image_push_username, '') }}
{{ tripleo_container_image_push_password | ternary('--password ' ~ tripleo_container_image_push_password, '') }}
{{ tripleo_container_image_push_dry_run | ternary('--dry-run', '') }}
{{ tripleo_container_image_push_multi_arch | ternary('--multi-arch', '') }}
{{ tripleo_container_image_push_cleanup | ternary('--cleanup', '') }}
{{ tripleo_container_image_push_image }}
- name: Show the container image push command
debug:
var: _push_cmd
when: tripleo_container_image_push_debug|bool
- name: Container image push
shell: "{{ _push_cmd }}" # noqa 305
async: "{{ tripleo_container_image_push_timeout }}"
poll: 1
become: "{{ tripleo_container_image_push_become }}"
register: tripleo_container_image_push_result
changed_when: true

View File

@@ -0,0 +1,2 @@
localhost

View File

@@ -0,0 +1,7 @@
---
- hosts: localhost
remote_user: root
roles:
- tripleo-container-image-push
vars:
tripleo_container_image_push_image: docker.io/library/centos:7