Implement tripleo-docker-rm role
tripleo-docker-rm ================= An Ansible role to remove Docker containers when Podman is enabled. Requirements ------------ It requires python-docker on the host. Role variables -------------- - container_cli: -- Name of the Container CLI tool (default to docker). - containers_to_rm: -- List of containers to remove. Example Playbook ---------------- Sample playbook to call the role: - name: Remove Nova API docker containers hosts: all roles: - tripleo-docker-rm vars: containers_to_rm: - nova_api - nova_api_cron container_cli: podman This role will be consummed by THT in post_upgrade_tasks. Change-Id: I03ad922c61ddd0b4a34935e1e17c0b37cd71ee03
This commit is contained in:
parent
b031901a0e
commit
978088904d
@ -0,0 +1,5 @@
|
||||
---
|
||||
features:
|
||||
- |
|
||||
The new tripleo-docker-rm will be useful to remove the containers that
|
||||
were managed by Docker and that are now managed by Podman.
|
40
roles/tripleo-docker-rm/README.md
Normal file
40
roles/tripleo-docker-rm/README.md
Normal file
@ -0,0 +1,40 @@
|
||||
tripleo-docker-rm
|
||||
=================
|
||||
|
||||
An Ansible role to remove Docker containers when Podman is enabled.
|
||||
|
||||
Requirements
|
||||
------------
|
||||
|
||||
It requires python-docker on the host.
|
||||
|
||||
Role variables
|
||||
--------------
|
||||
|
||||
- container_cli: -- Name of the Container CLI tool (default to docker).
|
||||
- containers_to_rm: -- List of containers to remove.
|
||||
|
||||
Example Playbook
|
||||
----------------
|
||||
|
||||
Sample playbook to call the role:
|
||||
|
||||
- name: Remove Nova API docker containers
|
||||
hosts: all
|
||||
roles:
|
||||
- tripleo-docker-rm
|
||||
vars:
|
||||
containers_to_rm:
|
||||
- nova_api
|
||||
- nova_api_cron
|
||||
container_cli: podman
|
||||
|
||||
License
|
||||
-------
|
||||
|
||||
Free software: Apache License (2.0)
|
||||
|
||||
Author Information
|
||||
------------------
|
||||
|
||||
OpenStack TripleO team
|
2
roles/tripleo-docker-rm/defaults/main.yaml
Normal file
2
roles/tripleo-docker-rm/defaults/main.yaml
Normal file
@ -0,0 +1,2 @@
|
||||
---
|
||||
container_cli: docker
|
17
roles/tripleo-docker-rm/tasks/main.yaml
Normal file
17
roles/tripleo-docker-rm/tasks/main.yaml
Normal file
@ -0,0 +1,17 @@
|
||||
---
|
||||
- name: Check if docker is installed
|
||||
stat:
|
||||
path: /usr/bin/docker
|
||||
register: docker_path_stat
|
||||
|
||||
- set_fact:
|
||||
docker_installed: "{{ docker_path_stat.results | map(attribute='stat') | map(attribute='exists') is any }}"
|
||||
|
||||
- name: remove "{{ containers_to_rm|join(', ') }}" containers
|
||||
docker_container:
|
||||
name: "{{ item }}"
|
||||
state: absent
|
||||
when:
|
||||
- container_cli == 'podman'
|
||||
- docker_installed
|
||||
with_items: "{{ containers_to_rm }}"
|
Loading…
Reference in New Issue
Block a user