summaryrefslogtreecommitdiff
path: root/roles/docker-registry/main.yml
blob: 9143d7a2afdaa605dc864d82b03ab3a8ee5b5f62 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
---
- name: Container Setup

  vars:
    lxc_base: ansible-alpine3.11
    lxc_name: docker-registry

  import_playbook: ../common/tasks/lxc.yml

- name: Installing Docker Registry on Alpine LXC Container
  hosts: docker_registry

  vars_files:
    - ../variables.yml

  tasks:

    - name: Including docker bootstrap for alpine
      include: ../common/tasks/docker/alpine.yml

    - name: Creating docker registry folder
      file:
        path: /opt/docker/registry
        state: directory

    - name: Working around docker registry not restarting after reboot
      blockinfile:
        path: /etc/local.d/2-docker-registry.start
        block: |
          while true;
          do
            [ -e /run/docker.sock ] && break;
            sleep 3;
          done
          docker stop $(docker ps -aq);
          docker container prune --force;
          docker run -d \
          --publish=5000:5000 \
          --volume=/opt:/var/lib/registry \
          --env=REGISTRY_HTTP_SECRET={{ secret_key }} \
          --restart=always \
          --name=registry \
          registry:{{ docker_registry_version }} \
        create: yes

    - name: Setting rc.local executable
      file:
        path: /etc/local.d/2-docker-registry.start
        mode: '0755'

    - name: Starting docker registry
      service:
        name: local
        state: restarted
        enabled: yes