tripleo-ansible/tripleo_ansible/playbooks/cli-container-image-prepare.yaml
Rabi Mishra afe6f82185 Add filter for absolute path of file/dir
This adds a custom filter that can be used in playbooks
to convert relative file/dir paths wrt home dir and
tht_root to absolute paths.

Also changes relevant playbooks to use it.

Closes-Bug: #1895194
Change-Id: I260fa3ec2f85a095d1d3ae4c22e2488d6000257a
2020-09-14 08:41:54 +05:30

74 lines
2.7 KiB
YAML

---
# 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.
- name: Container Image Prepare
connection: "{{ (tripleo_target_host is defined) | ternary('ssh', 'local') }}"
hosts: "{{ tripleo_target_host | default('localhost') }}"
remote_user: "{{ tripleo_target_user | default(lookup('env', 'USER')) }}"
gather_facts: "{{ (tripleo_target_host is defined) | ternary(true, false) }}"
any_errors_fatal: true
vars:
roles_file: /usr/share/openstack-tripleo-heat-templates/roles_data.yaml
environment_files: []
environment_directories: []
cleanup: full
dry_run: false
debug: false
log_file: container_image_prepare.log
tasks:
- name: Fetch roles_data
slurp:
src: "{{ roles_file | tht_abspath }}"
register: roles_data
- name: Set fact for log file
set_fact:
cip_log_file: "{{ lookup('env', 'HOME') ~ '/' ~ log_file }}"
- name: Get all files in directories
find:
paths: "{{ environment_directories | tht_abspath(ignore_error=true) }}"
patterns: '*.yaml'
when: environment_directories
register: out_env_files
- name: Build environment_files
set_fact:
env_files: "{{ out_env_files.files | map(
attribute='path') | list + (environment_files | tht_abspath) }}"
- name: Build heat stack environment
tripleo_build_heat_environment:
env_files: "{{ env_files }}"
register: env_result
- name: Prepare container images, check logs in {{ cip_log_file }}
become: true
tripleo_container_image_prepare:
roles_data: "{{ roles_data['content'] | b64decode | from_yaml}}"
environment: "{{ env_result.environment }}"
cleanup: "{{ cleanup }}"
dry_run: "{{ dry_run }}"
log_file: "{{ cip_log_file }}"
debug: "{{ debug }}"
register: prepare_result
- name: Write output to file to {{ output_env_file }}
copy:
content: "{{ prepare_result.params | to_nice_yaml }}"
backup: true
dest: "{{ output_env_file }}"
when: output_env_file is defined
- name: Write output to console
debug:
msg: "{{ prepare_result.params | to_nice_yaml }}"
when: output_env_file is not defined