osism.services.kolla_docker (0.20240327.0) — module

Module for controlling Docker

Authors: Sam Yaple

Install collection

Install with ansible-galaxy collection install osism.services:==0.20240327.0


Add to requirements.yml

  collections:
    - name: osism.services
      version: 0.20240327.0

Description

A module targeting at controlling Docker as used by Kolla.

Usage examples

  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- hosts: kolla_docker
  tasks:
    - name: Start container
      kolla_docker:
        image: ubuntu
        name: test_container
        action: start_container
    - name: Remove container
      kolla_docker:
        name: test_container
        action: remove_container
    - name: Pull image without starting container
      kolla_docker:
        action: pull_image
        image: private-registry.example.com:5000/ubuntu
    - name: Create named volume
      kolla_docker:
        action: create_volume
        name: name_of_volume
    - name: Remove named volume
      kolla_docker:
        action: remove_volume
        name: name_of_volume
    - name: Remove image
      kolla_docker:
        action: remove_image
        image: name_of_image

Inputs

    
tty:
    default: false
    description:
    - Allocate TTY to container
    required: false
    type: bool

name:
    description:
    - Name of the container or volume to manage
    required: false
    type: str

image:
    description:
    - Name of the docker image
    required: false
    type: str

state:
    choices:
    - running
    - exited
    - paused
    description:
    - Check container status
    required: false
    type: str

tmpfs:
    description:
    - List of paths to mount as tmpfs.
    required: false
    type: list

action:
    choices:
    - compare_container
    - compare_image
    - create_volume
    - ensure_image
    - get_container_env
    - get_container_state
    - pull_image
    - remove_container
    - remove_image
    - remove_volume
    - recreate_or_restart_container
    - restart_container
    - start_container
    - stop_container
    - stop_container_and_remove_container
    description:
    - The action the module should take
    required: true
    type: str

detach:
    default: true
    description:
    - Detach from the container after it is created
    required: false
    type: bool

labels:
    default: dict()
    description:
    - List of labels to apply to container
    required: false
    type: dict

cap_add:
    default: list()
    description:
    - Add capabilities to docker container
    required: false
    type: list

command:
    description:
    - The command to execute in the container
    required: false
    type: str

volumes:
    description:
    - Set volumes for docker to use
    required: false
    type: list

ipc_mode:
    choices:
    - host
    default: None
    description:
    - Set docker ipc namespace
    required: false
    type: str

pid_mode:
    choices:
    - host
    default: None
    description:
    - Set docker pid namespace
    required: false
    type: str

auth_email:
    description:
    - The email address used to authenticate
    required: false
    type: str

privileged:
    default: false
    description:
    - Set the container to privileged
    required: false
    type: bool

api_version:
    default: auto
    description:
    - The version of the api for docker-py to use when contacting docker
    required: false
    type: str

environment:
    description:
    - The environment to set for the container
    required: false
    type: dict

healthcheck:
    default: dict()
    description:
    - Container healthcheck configuration
    required: false
    type: dict

security_opt:
    default: list()
    description:
    - Set container security profile
    required: false
    type: list

volumes_from:
    description:
    - Name or id of container(s) to use volumes from
    required: true
    type: list

auth_password:
    description:
    - The password used to authenticate
    required: false
    type: str

auth_registry:
    description:
    - The registry to authenticate
    required: false
    type: str

auth_username:
    description:
    - The username used to authenticate
    required: false
    type: str

cgroupns_mode:
    choices:
    - private
    - host
    default: None
    description:
    - Set docker cgroups namespace (default depends on Docker config)
    - Supported only with Docker 20.10 (Docker API 1.41) and later
    required: false
    type: str

client_timeout:
    default: 120
    description:
    - Docker client timeout in seconds
    required: false
    type: int

common_options:
    default: dict()
    description:
    - A dict containing common params such as login info
    required: false
    type: dict

remove_on_exit:
    default: true
    description:
    - When not detaching from container, remove on successful exit
    required: false
    type: bool

restart_policy:
    choices:
    - false
    - on-failure
    - always
    - unless-stopped
    description:
    - When docker restarts the container (does not affect checks)
    required: false
    type: str

restart_retries:
    default: 10
    description:
    - How many times to attempt a restart if 'on-failure' policy is set
    type: int