Add configuration to deploy a Docker registry on a controller

By default the registry listens on port 4000 to avoid clashing with keystone.
It is configured via the following commands:

kayobe overcloud service <deploy|pull|reconfigure|upgrade>
This commit is contained in:
Mark Goddard 2017-06-27 18:49:08 +01:00
parent 4c9a6da3f1
commit 56ee18d0fd
11 changed files with 138 additions and 0 deletions

View File

@ -0,0 +1,12 @@
---
# Deploy/pull/reconfigure/upgrade Docker registry.
#
# Follows kolla-ansible service deployment patterns.
#
# Variables:
# action: One of deploy, pull, reconfigure, upgrade
- name: Ensure a local Docker registry is deployed
hosts: controllers[0]
roles:
- role: docker-registry

View File

@ -0,0 +1,11 @@
---
###############################################################################
# Docker registry configuration.
# Whether a docker registry is enabled.
docker_registry_enabled: true
# The port on which the docker registry server should listen.
# NOTE: This is set to 4000 rather than the default of 5000 to avoid clashing
# with keystone.
docker_registry_port: 4000

View File

@ -7,4 +7,5 @@
# Variables:
# action: One of deploy, pull, reconfigure, upgrade
- include: docker-registry.yml
- include: opensm.yml

View File

@ -0,0 +1,47 @@
Docker Registry
===============
This role can be used to configure a Docker registry running in a Docker
container.
Requirements
------------
The host executing the role has the following requirements:
* Docker engine
* ``docker-py >= 1.7.0``
Role Variables
--------------
``docker_registry_enabled``: Whether the Docker registry is enabled. Defaults
to ``true``.
``docker_registry_namespace``: Docker image namespace. Defaults to
``library``.
``docker_registry_image``: Docker image name.
``docker_registry_tag``: Docker image tag. Defaults to ``latest``.
``docker_registry_image_full``: Full docker image specification.
``docker_registry_restart_policy``: Docker restart policy for
``docker_registry`` container. Defaults to ``unless-stopped``.
``docker_registry_restart_retries``: Number of Docker restarts. Defaults to 10.
Dependencies
------------
None
Example Playbook
----------------
The following playbook configures a Docker registry.
---
- hosts: docker-registry
roles:
- role: stackhpc.docker-registry
Author Information
------------------
- Mark Goddard (<mark@stackhpc.com>)

View File

@ -0,0 +1,31 @@
---
# Roughly follows kolla-ansible's service deployment patterns.
# Whether a docker registry is enabled.
docker_registry_enabled: true
# Service deployment definition.
docker_registry_services:
docker_registry:
container_name: docker_registry
enabled: "{{ docker_registry_enabled }}"
image: "{{ docker_registry_image_full }}"
ports:
- "{{ docker_registry_port }}:5000"
volumes:
- "/etc/localtime:/etc/localtime:ro"
- "docker_registry:/var/lib/registry"
# The port on which the docker registry server should listen.
docker_registry_port: 5000
####################
# Docker
####################
docker_registry_namespace: "library"
docker_registry_image: "{{ docker_registry ~ '/' if docker_registry | default else '' }}{{ docker_registry_namespace }}/registry"
docker_registry_tag: "latest"
docker_registry_image_full: "{{ docker_registry_image }}:{{ docker_registry_tag }}"
docker_registry_restart_policy: "unless-stopped"
docker_registry_restart_retries: 10

View File

@ -0,0 +1,14 @@
---
- name: Ensure Docker registry container is running
docker_container:
image: "{{ item.value.image }}"
name: "{{ item.value.container_name }}"
ports: "{{ item.value.ports | default(omit) }}"
privileged: "{{ item.value.privileged | default(omit) }}"
pull: "{{ action == 'upgrade' }}"
read_only: "{{ item.value.read_only | default(omit) }}"
restart_policy: "{{ docker_registry_restart_policy }}"
restart_retries: "{{ docker_registry_restart_retries }}"
state: "{{ 'started' if item.value.enabled | bool else 'absent' }}"
volumes: "{{ item.value.volumes }}"
with_dict: "{{ docker_registry_services }}"

View File

@ -0,0 +1,2 @@
---
- include: "{{ action }}.yml"

View File

@ -0,0 +1,5 @@
---
- name: Pulling Docker registry container image
docker_image:
name: "{{ docker_registry_image_full }}"
state: present

View File

@ -0,0 +1 @@
deploy.yml

View File

@ -0,0 +1 @@
deploy.yml

View File

@ -0,0 +1,13 @@
---
###############################################################################
# Docker registry configuration.
# Whether a docker registry is enabled.
#docker_registry_enabled:
# The port on which the docker registry server should listen.
#docker_registry_port:
###############################################################################
# Dummy variable to allow Ansible to accept this file.
workaround_ansible_issue_8743: yes