Add container image prepare role

Adds tripleo_container_image_prepare role to execute the tripleo
container image prepare process.

Change-Id: Iec1c2a3afa9c6e2ef0011036749f294a1d9b9508
This commit is contained in:
Alex Schultz
2020-01-15 15:00:16 -07:00
parent a45f018244
commit bf90885e13
6 changed files with 137 additions and 0 deletions

View File

@@ -0,0 +1,52 @@
tripleo_container_image_prepare
===============================
A role to perform the container image prepare action.
Requirements
------------
None.
Role Variables
--------------
* `tripleo_container_image_prepare_become`: (Boolean) Run the command as root. This needs to be true when uploading to the local undercloud registry. Default: true
* `tripleo_container_image_prepare_cleanup`: (String) Cleanup behavior for local images left after upload. Can be one of full, partial, or none. Default is not set.
* `tripleo_container_image_prepare_debug`: (Boolean) Flag to print out the prepare command. Default: False
* `tripleo_container_image_prepare_dry_run`: (Boolean) Perform a dry run upload which will not perform any push, pull or modify operations. The environment file will still be populaged. Default: false
* `tripleo_container_image_prepare_environment_files`: (List) List of environment files. Default: []
* `tripleo_container_image_prepare_environment_directory`: (List) Directories containing environment files. Should not be used if `tripleo_container_image_prepare_environment_files` is defined. Default: []
* `tripleo_container_image_prepare_output_env_file`: (String) File to write heat environment file which specifies all image parameters. Default is not set.
* `tripleo_container_image_prepare_output_roles_file`: (String) Roles file path on the remote system. Default is not set.
* `tripleo_container_image_prepare_timeout`: (Number) Amount of time to wait for the command to conplete. Default: 1800
Output Variables
----------------
* `tripleo_container_image_prepare_result`: Ansible shell execution results
Dependencies
------------
None.
Example Playbook
----------------
Example container prepare execution playbook
- hosts: undercloud
gather_facts: true
tasks:
- name: Run container prepare
import_role:
name: tripleo_container_image_prepare
vars:
tripleo_container_image_prepare_files:
- /home/stack/container-image-prepare.yaml
License
-------
Apache-2.0

View File

@@ -0,0 +1,11 @@
---
# defaults file for tripleo_container_image_prepare
tripleo_container_image_prepare_become: true
tripleo_container_image_prepare_cleanup:
tripleo_container_image_prepare_debug: false
tripleo_container_image_prepare_dry_run: false
tripleo_container_image_prepare_environemnt_files: []
tripleo_container_image_prepare_environment_directory: []
tripleo_container_image_prepare_output_env_file:
tripleo_container_image_prepare_roles_file:
tripleo_container_image_prepare_timeout: 1800

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_prepare
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,25 @@
---
# tasks file for tripleo_container_image_prepare
- name: Setup container image prepare facts
set_fact:
_prepare_cmd: >-
openstack tripleo container image prepare
{{ tripleo.operator.shell_arg_list(tripleo_container_image_prepare_environment_files, '--environment-file') }}
{{ tripleo.operator.shell_arg_list(tripleo_container_image_prepare_environment_directory, '--environment-directory') }}
{{ tripleo_container_image_prepare_roles_file | ternary('--roles-file ' ~ tripleo_container_image_prepare_roles_file, '') }}
{{ tripleo_container_image_prepare_output_env_file | ternary('--output-env-file ' ~ tripleo_container_image_prepare_output_env_file, '') }}
{{ tripleo_container_image_prepare_dry_run | ternary('--dry-run', '') }}
{{ tripleo_container_image_prepare_cleanup | ternary('--cleanup ' ~ tripleo_container_image_prepare_cleanup, '') }}
- name: Show the container image prepare command
debug:
var: _prepare_cmd
when: tripleo_container_image_prepare_debug|bool
- name: Container image prepare
shell: "{{ _prepare_cmd }}" # noqa 305
async: "{{ tripleo_container_image_prepare_timeout }}"
poll: 1
become: "{{ tripleo_container_image_prepare_become }}"
register: tripleo_container_image_prepare_result
changed_when: true

View File

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

View File

@@ -0,0 +1,5 @@
---
- hosts: localhost
remote_user: root
roles:
- tripleo_container_image_prepare