Vendor Galaxy Roles and Collections
This commit is contained in:
parent
c1e1897cda
commit
2aed20393f
3553 changed files with 387444 additions and 2 deletions
|
|
@ -0,0 +1,55 @@
|
|||
#!{{ ansible_python['executable'] }}
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Copyright (C) 2019 Maciej Delmanowski <drybjed@gmail.com>
|
||||
# Copyright (C) 2019 DebOps <https://debops.org/>
|
||||
# SPDX-License-Identifier: GPL-3.0-only
|
||||
|
||||
# {{ ansible_managed }}
|
||||
|
||||
from __future__ import print_function
|
||||
from json import loads, dumps
|
||||
from yaml import load
|
||||
from sys import exit
|
||||
import subprocess
|
||||
import os
|
||||
|
||||
|
||||
def cmd_exists(cmd):
|
||||
return any(
|
||||
os.access(os.path.join(path, cmd), os.X_OK)
|
||||
for path in os.environ["PATH"].split(os.pathsep)
|
||||
)
|
||||
|
||||
|
||||
config_file = loads('''{{ docker_registry__config_file | to_nice_json }}''')
|
||||
|
||||
output = loads('''{{ {"host_fqdn": docker_registry__fqdn,
|
||||
"host_port": 443} | to_nice_json }}''')
|
||||
|
||||
output['installed'] = cmd_exists('docker-registry')
|
||||
|
||||
try:
|
||||
output['version'] = subprocess.check_output(
|
||||
['docker-registry', '-v']).strip('\n') \
|
||||
.split()[2] \
|
||||
.split('+')[0] \
|
||||
.lstrip('v')
|
||||
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
try:
|
||||
with open(config_file, 'r') as f:
|
||||
config = load(f)
|
||||
output['api_url'] = ('http://' + config.get('http').get('addr') + '/')
|
||||
if config.get('storage').get('filesystem'):
|
||||
output['storage_type'] = 'filesystem'
|
||||
output['storage_path'] = config.get('storage') \
|
||||
.get('filesystem') \
|
||||
.get('rootdirectory')
|
||||
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
print(dumps(output, sort_keys=True, indent=4))
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
{# Copyright (C) 2019 Maciej Delmanowski <drybjed@gmail.com>
|
||||
# Copyright (C) 2019 DebOps <https://debops.org/>
|
||||
# SPDX-License-Identifier: GPL-3.0-only
|
||||
#}
|
||||
# {{ ansible_managed }}
|
||||
|
||||
{% set docker_registry__tpl_config = {} %}
|
||||
{% for element in docker_registry__combined_config | debops.debops.parse_kv_config %}
|
||||
{% if element.name | d() and element.state | d('present') not in [ 'absent', 'init', 'ignore' ] and element.config | d() %}
|
||||
{% set combined_config = docker_registry__tpl_config | combine(element.config, recursive=True) %}
|
||||
{% set _ = docker_registry__tpl_config.update(combined_config) %}
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
{{ docker_registry__tpl_config | to_nice_yaml }}
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
{# Copyright (C) 2019 Maciej Delmanowski <drybjed@gmail.com>
|
||||
# Copyright (C) 2019 DebOps <https://debops.org/>
|
||||
# SPDX-License-Identifier: GPL-3.0-only
|
||||
#}
|
||||
# {{ ansible_managed }}
|
||||
|
||||
# Allow the '{{ docker_registry__user }}' UNIX account to stop and start the
|
||||
# Docker Registry service. This is required to correctly perform the garbage
|
||||
# collection using a cron script.
|
||||
|
||||
Cmnd_Alias DOCKER_REGISTRY_STOP = /bin/systemctl stop docker-registry.service
|
||||
Cmnd_Alias DOCKER_REGISTRY_START = /bin/systemctl start docker-registry.service
|
||||
Cmnd_Alias DOCKER_REGISTRY_RESTART = /bin/systemctl restart docker-registry.service
|
||||
Cmnd_Alias DOCKER_REGISTRY_RELOAD = /bin/systemctl reload docker-registry.service
|
||||
Cmnd_Alias DOCKER_REGISTRY_STATUS = /bin/systemctl status docker-registry.service
|
||||
|
||||
{{ docker_registry__user }} ALL = (root) NOPASSWD: DOCKER_REGISTRY_STOP
|
||||
{{ docker_registry__user }} ALL = (root) NOPASSWD: DOCKER_REGISTRY_START
|
||||
{{ docker_registry__user }} ALL = (root) NOPASSWD: DOCKER_REGISTRY_RESTART
|
||||
{{ docker_registry__user }} ALL = (root) NOPASSWD: DOCKER_REGISTRY_RELOAD
|
||||
{{ docker_registry__user }} ALL = (root) NOPASSWD: DOCKER_REGISTRY_STATUS
|
||||
|
|
@ -0,0 +1,26 @@
|
|||
{# Copyright (C) 2019 Maciej Delmanowski <drybjed@gmail.com>
|
||||
# Copyright (C) 2019 DebOps <https://debops.org/>
|
||||
# SPDX-License-Identifier: GPL-3.0-only
|
||||
#}
|
||||
# {{ ansible_managed }}
|
||||
|
||||
[Unit]
|
||||
Description=Docker Registry service
|
||||
ConditionPathExists=/var/lib/docker-registry
|
||||
After=network.target network-online.target
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
User={{ docker_registry__user }}
|
||||
Group={{ docker_registry__group }}
|
||||
WorkingDirectory={{ docker_registry__home }}
|
||||
ExecStart={{ docker_registry__binary }} serve {{ docker_registry__config_file }}
|
||||
Restart=on-failure
|
||||
RestartSec=10
|
||||
|
||||
StandardOutput=syslog
|
||||
StandardError=syslog
|
||||
SyslogIdentifier=docker-registry
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
|
|
@ -0,0 +1,38 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
# Copyright (C) 2019 Maciej Delmanowski <drybjed@gmail.com>
|
||||
# Copyright (C) 2019 DebOps <https://debops.org/>
|
||||
# SPDX-License-Identifier: GPL-3.0-only
|
||||
|
||||
# {{ ansible_managed }}
|
||||
|
||||
# Perform garbage collection in the Docker Registry
|
||||
|
||||
|
||||
set -o nounset -o pipefail -o errexit
|
||||
|
||||
readonly CONFIG_FILE="{{ docker_registry__config_file }}"
|
||||
readonly REGISTRY_BIN="{{ docker_registry__binary }}"
|
||||
readonly DELETE_UNTAGGED="{{ '--delete-untagged' if (docker_registry__version is version('2.7.1', '>=')) else '' }}"
|
||||
|
||||
# Redis support
|
||||
readonly REDIS_ENABLED="{{ docker_registry__redis_enabled | bool | lower }}"
|
||||
readonly REDIS_DATABASE="{{ docker_registry__redis_db }}"
|
||||
|
||||
if "${REGISTRY_BIN}" garbage-collect "${CONFIG_FILE}" --dry-run 2>/dev/null \
|
||||
| grep --extended-regexp "^blob eligible for deletion" > /dev/null ; then
|
||||
sudo systemctl stop docker-registry.service
|
||||
"${REGISTRY_BIN}" garbage-collect "${CONFIG_FILE}" "${DELETE_UNTAGGED}" > /dev/null 2>&1
|
||||
|
||||
# Flush Redis cache entries related to Docker Registry. Currently it
|
||||
# flushes all cache data, but could be improved later to remove only
|
||||
# specific keys.
|
||||
if [ "${REDIS_ENABLED}" == "true" ] ; then
|
||||
redis-cli -a "$(redis-password)" -n "${REDIS_DATABASE}" --raw keys "blobs::sha256:*" 2>/dev/null \
|
||||
| xargs redis-cli -a "$(redis-password)" -n "${REDIS_DATABASE}" del 1>/dev/null 2>&1
|
||||
redis-cli -a "$(redis-password)" -n "${REDIS_DATABASE}" --raw keys "repository::*::blobs::sha256:*" 2>/dev/null \
|
||||
| xargs redis-cli -a "$(redis-password)" -n "${REDIS_DATABASE}" del 1>/dev/null 2>&1
|
||||
fi
|
||||
|
||||
sudo systemctl start docker-registry.service
|
||||
fi
|
||||
Loading…
Reference in a new issue