--- # 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. # "tripleo-container-manage" will search for and load any operating system variable file # found within the "vars/" path. If no OS files are found the task will skip. - name: Gather variables for each operating system include_vars: "{{ item }}" with_first_found: - skip: true files: - "{{ ansible_distribution | lower }}-{{ ansible_distribution_version | lower }}.yml" - "{{ ansible_distribution | lower }}-{{ ansible_distribution_major_version | lower }}.yml" - "{{ ansible_os_family | lower }}-{{ ansible_distribution_major_version | lower }}.yml" - "{{ ansible_distribution | lower }}.yml" - "{{ ansible_os_family | lower }}-{{ ansible_distribution_version.split('.')[0] }}.yml" - "{{ ansible_os_family | lower }}.yml" tags: - always - name: Create container logs path file: path: "{{ tripleo_container_manage_log_path }}" state: directory owner: root group: root become: true - name: Create ansible-managed dropin file copy: dest: "{{ tripleo_container_manage_config | dirname }}/.ansible-managed" content: | Containers are managed by the tripleo-container-manage role in tripleo-ansible project. This file is used by paunch to show a warning if paunch is used against a deployment done with tripleo-container-manage. - name: Generate containers configs data no_log: "{{ false if tripleo_container_manage_debug else true }}" block: - name: "Find all matching configs configs for in {{ tripleo_container_manage_config }}" find: paths: "{{ tripleo_container_manage_config }}" patterns: "{{ tripleo_container_manage_config_patterns }}" recurse: true register: matched_files - name: "Read config for each container in {{ tripleo_container_manage_config }}" slurp: src: "{{ item.path }}" register: containers_data loop: "{{ matched_files.files }}" - name: Prepare container hashes from config set_fact: container_hash: "{'{{ item.source|basename|regex_replace('^hashed-','')|regex_replace('.json$','') }}': {{ item.content|b64decode|from_json }} }" register: container_hashes loop: "{{ containers_data['results'] }}" - name: Compile container hashes from results set_fact: container_hash: "{{ item.ansible_facts.container_hash | combine(item.ansible_facts.container_hash) }}" register: container_hashes loop: "{{ container_hashes.results }}" - name: Finalise hashes for all containers set_fact: all_containers_hash: >- {{ container_hashes.results | map(attribute='ansible_facts.container_hash') | list | singledict(merge_with=tripleo_container_manage_config_overrides) }} - name: "Manage systemd shutdown files" become: true when: - tripleo_container_manage_systemd_order block: - name: Check if /usr/lib/systemd/system-preset/91-tripleo-container-shutdown.preset exists stat: path: /usr/lib/systemd/system-preset/91-tripleo-container-shutdown.preset register: tripleo_container_shutdown - name: Include tasks for systemd shutdown service include_tasks: shutdown.yml when: - not tripleo_container_shutdown.stat.exists - name: "Manage containers from {{ tripleo_container_manage_config }}" when: - tripleo_container_manage_cli == 'podman' become: true block: - name: "Delete containers from {{ tripleo_container_manage_config }}" include_tasks: delete.yml - name: "Create containers from {{ tripleo_container_manage_config }}" include_tasks: create.yml - name: "Show all container commands for {{ tripleo_container_manage_config }}" debug: msg: "{{ all_containers_commands }}" when: - ansible_check_mode|bool