111 lines
5.9 KiB
YAML
111 lines
5.9 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: "Tear-down containers that need to be re-created (new-config detected)"
|
|
when:
|
|
- tripleo_container_manage_systemd_teardown | bool
|
|
include_role:
|
|
name: tripleo_container_rm
|
|
vars:
|
|
tripleo_container_cli: "{{ tripleo_container_manage_cli }}"
|
|
tripleo_containers_to_rm: >-
|
|
{{ podman_containers.containers | needs_delete(config=batched_container_data|
|
|
haskey(attribute='action', reverse=True)|singledict,
|
|
config_id=tripleo_container_manage_config_id) }}
|
|
|
|
- name: "Async container create/run"
|
|
async: "{{ (not ansible_check_mode | bool) | ternary('600', omit) }}"
|
|
poll: "{{ (not ansible_check_mode | bool) | ternary('0', omit) }}"
|
|
register: create_async_results
|
|
loop: "{{ batched_container_data | haskey(attribute='action', reverse=True) }}"
|
|
loop_control:
|
|
label: "{{ lookup('dict', container_data).key }}"
|
|
loop_var: container_data
|
|
podman_container:
|
|
annotation: "{{ lookup('dict', container_data).value.annotation | default(omit) }}"
|
|
cap_add: "{{ lookup('dict', container_data).value.cap_add | default(omit) }}"
|
|
cap_drop: "{{ lookup('dict', container_data).value.cap_drop | default(omit) }}"
|
|
command: "{{ lookup('dict', container_data).value.command | default(omit) }}"
|
|
conmon_pidfile: "/var/run/{{ lookup('dict', container_data).key }}.pid"
|
|
cpu_shares: "{{ lookup('dict', container_data).value.cpu_shares | default(omit) }}"
|
|
debug: true
|
|
detach: "{{ lookup('dict', container_data).value.detach | default(true) }}"
|
|
device: "{{ lookup('dict', container_data).value.device | default(omit) }}"
|
|
entrypoint: "{{ lookup('dict', container_data).value.entrypoint | default(omit) }}"
|
|
env: "{{ lookup('dict', container_data).value.environment | default(omit) }}"
|
|
env_file: "{{ lookup('dict', container_data).value.env_file | default(omit) }}"
|
|
etc_hosts: "{{ lookup('dict', container_data).value.extra_hosts | default({}) }}"
|
|
group_add: "{{ lookup('dict', container_data).value.group_add | default(omit) }}"
|
|
healthcheck: >-
|
|
{{ (not tripleo_container_manage_healthcheck_disabled | bool) |
|
|
ternary((lookup('dict', container_data).value.healthcheck.test|default(omit)), omit) }}
|
|
healthcheck_interval: >-
|
|
{{ lookup('dict', container_data).value.check_interval|default('60s')
|
|
if lookup('dict', container_data).value.healthcheck is defined else omit }}
|
|
hostname: "{{ lookup('dict', container_data).value.hostname | default(omit) }}"
|
|
image: "{{ lookup('dict', container_data).value.image }}"
|
|
interactive: "{{ lookup('dict', container_data).value.interactive | default(false) }}"
|
|
ipc: "{{ lookup('dict', container_data).value.ipc | default(omit) }}"
|
|
label:
|
|
config_id: "{{ tripleo_container_manage_config_id }}"
|
|
container_name: "{{ lookup('dict', container_data).key }}"
|
|
managed_by: tripleo_ansible
|
|
config_data: "{{ lookup('dict', container_data).value }}"
|
|
log_driver: 'k8s-file'
|
|
log_level: "{{ tripleo_container_manage_debug | ternary('debug', 'error') }}"
|
|
log_opt: "path={{ tripleo_container_manage_log_path }}/{{ lookup('dict', container_data).key }}.log"
|
|
memory: "{{ lookup('dict', container_data).value.mem_limit | default(omit) }}"
|
|
memory_swap: "{{ lookup('dict', container_data).value.mem_swappiness | default(omit) }}"
|
|
name: "{{ lookup('dict', container_data).key }}"
|
|
net: "{{ lookup('dict', container_data).value.net | default('none') }}"
|
|
pid: "{{ lookup('dict', container_data).value.pid | default(omit) }}"
|
|
pids_limit: "{{ lookup('dict', container_data).value.pids_limit | default(omit) }}"
|
|
privileged: "{{ lookup('dict', container_data).value.privileged | default(false) }}"
|
|
rm: "{{ lookup('dict', container_data).value.remove | default(false) }}"
|
|
security_opt: "{{ lookup('dict', container_data).value.security_opt | default(omit) }}"
|
|
state: present
|
|
stop_signal: "{{ lookup('dict', container_data).value.stop_signal | default(omit) }}"
|
|
stop_timeout: "{{ lookup('dict', container_data).value.stop_grace_period | default(omit) }}"
|
|
sysctl: "{{ lookup('dict', container_data).value.sysctl | default(omit) }}"
|
|
tty: "{{ lookup('dict', container_data).value.tty | default(false) }}"
|
|
ulimit: "{{ lookup('dict', container_data).value.ulimit | default(omit) }}"
|
|
user: "{{ lookup('dict', container_data).value.user | default(omit) }}"
|
|
uts: "{{ lookup('dict', container_data).value.uts | default(omit) }}"
|
|
volume: "{{ lookup('dict', container_data).value.volumes | default(omit) }}"
|
|
volumes_from: "{{ lookup('dict', container_data).value.volumes_from | default([]) }}"
|
|
|
|
- name: "Check podman create status"
|
|
async_status:
|
|
jid: "{{ create_async_result_item.ansible_job_id }}"
|
|
loop: "{{ create_async_results.results }}"
|
|
loop_control:
|
|
label: "{{ lookup('dict', create_async_result_item.container_data).key }}"
|
|
loop_var: "create_async_result_item"
|
|
register: create_async_poll_results
|
|
until: create_async_poll_results.finished
|
|
retries: "{{ tripleo_container_manage_create_retries }}"
|
|
# We fail later if a container has failed to start
|
|
failed_when: false
|
|
when:
|
|
- not ansible_check_mode|bool
|
|
|
|
- name: Check containers status
|
|
container_status:
|
|
container_async_results: "{{ create_async_poll_results.results }}"
|
|
container_data: "{{ batched_container_data }}"
|
|
valid_exit_codes: "{{ tripleo_container_manage_valid_exit_code }}"
|
|
debug: "{{ tripleo_container_manage_debug | bool }}"
|