summaryrefslogtreecommitdiff
path: root/playbooks/docker_registry.yaml
blob: 3666deb8f9170151764c4c92eba105706e46487f (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
56
57
58
59
60
61
62
63
64
65
---
- name: "Install docker-registry"
  hosts: target
  tasks:
    - name: "Create docker-registry directories"
      file:
        path: "{{ item.path }}"
        state: directory
        mode: "{{ item.mode }}"
      with_items:
        - { path: /root/docker-registry/nginx, mode: "0755" }
        - { path: /root/docker-registry/data, mode: "0755" }

    - name: "Create docker-registry files"
      template:
        src: "../templates/{{ item.src }}"
        dest: "{{ item.dest }}"
        mode: "{{ item.mode }}"
        owner: root
        group: root
      with_items:
        - { src: registry.conf, dest: /root/docker-registry/nginx/registry.conf, mode: "0644" }

    - name: "Create docker-registry files"
      copy:
        src: "../files/{{ item.src }}"
        dest: "{{ item.dest }}"
        mode: "{{ item.mode }}"
        owner: root
        group: root
      with_items:
        - { src: docker-compose.yaml, dest: /root/docker-registry/docker-compose.yaml, mode: "0644" }

    - name: "Copy SSL certs into nginx directory"
      shell: |
        cp "/etc/ssl/certs/{{ inventory_hostname }}.crt" /root/docker-registry/nginx/
        cp "/etc/ssl/certs/{{ inventory_hostname }}.ca" /root/docker-registry/nginx/
        cp "/etc/ssl/private/{{ inventory_hostname }}.key" /root/docker-registry/nginx/
      when: ansible_distribution == "Ubuntu" or ansible_distribution == "Gentoo"

    - name: "Create password file"
      shell: htpasswd -c -b -s /root/docker-registry/nginx/registry.password '{{ username }}' '{{ password }}'

    - name: "Install init script"
      copy:
        src: ../files/docker-registry.ubuntu
        dest: /etc/init.d/docker-registry
        mode: "0755"
      when: ansible_distribution == "Ubuntu"

    - name: "Install init script"
      copy:
        src: ../files/docker-registry.gentoo
        dest: /etc/init.d/docker-registry
        mode: "0755"
      when: ansible_distribution == "Gentoo"

    - name: "Enable docker-registry"
      service:
        name: "{{ item.name }}"
        enabled: yes
        state: started
        runlevel: "{{ item.runlevel }}"
      with_items:
        - { name: docker-registry, runlevel: default }