tripleo-ansible/tripleo_ansible/roles/tripleo-container-manage/tasks/main.yml

86 lines
3.4 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.
# "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_facts['distribution'] | lower }}-{{ ansible_facts['distribution_version'] | lower }}.yml"
- "{{ ansible_facts['distribution'] | lower }}-{{ ansible_facts['distribution_major_version'] | lower }}.yml"
- "{{ ansible_facts['os_family'] | lower }}-{{ ansible_facts['distribution_major_version'] | lower }}.yml"
- "{{ ansible_facts['distribution'] | lower }}.yml"
- "{{ ansible_facts['os_family'] | lower }}-{{ ansible_facts['distribution_version'].split('.')[0] }}.yml"
- "{{ ansible_facts['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: "{{ not tripleo_container_manage_debug }}"
block:
- name: "Find all matching configs configs for in {{ tripleo_container_manage_config }}"
container_config_data:
config_path: "{{ tripleo_container_manage_config }}"
config_pattern: "{{ tripleo_container_manage_config_patterns }}"
config_overrides: "{{ tripleo_container_manage_config_overrides }}"
debug: "{{ tripleo_container_manage_debug }}"
register: container_config_data
- name: Finalise hashes for all containers
set_fact:
all_containers_hash: "{{ container_config_data.configs }}"
- name: "Manage systemd shutdown files"
include_tasks: shutdown.yml
when:
- tripleo_container_manage_systemd_order|bool
- name: "Manage containers from {{ tripleo_container_manage_config }}"
when:
- (all_containers_hash|length) > 0
- tripleo_container_manage_cli == 'podman'
become: true
block:
- name: "Update container configs with new config hashes"
include_tasks: puppet_config.yml
when:
- tripleo_container_manage_check_puppet_config|bool
- name: "Delete orphan containers from {{ tripleo_container_manage_config }}"
include_tasks: delete_orphan.yml
when:
- tripleo_container_manage_clean_orphans|bool
- name: "Create containers from {{ tripleo_container_manage_config }}"
include_tasks: create.yml