Zack Williams | 65edc22 | 2018-01-30 18:52:30 -0700 | [diff] [blame] | 1 | --- |
| 2 | # Copyright 2017-present Open Networking Foundation |
| 3 | # |
| 4 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | # you may not use this file except in compliance with the License. |
| 6 | # You may obtain a copy of the License at |
| 7 | # |
| 8 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | # |
| 10 | # Unless required by applicable law or agreed to in writing, software |
| 11 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | # See the License for the specific language governing permissions and |
| 14 | # limitations under the License. |
| 15 | |
| 16 | # docker-registry/tasks/main.yml |
| 17 | # Install a SSL secured (server and client cert) docker registry |
| 18 | |
| 19 | - name: Create docker registry directories |
| 20 | file: |
| 21 | path: "{{ item }}" |
| 22 | state: directory |
| 23 | owner: root |
| 24 | group: docker |
| 25 | mode: 0750 |
| 26 | with_items: |
| 27 | - "{{ docker_registry_dir }}" |
| 28 | - "{{ docker_registry_dir }}/certs" |
| 29 | - "{{ docker_registry_dir }}/data" |
| 30 | |
| 31 | - name: Copy over SSL keys for the registry |
| 32 | copy: |
| 33 | src: "{{ item.src }}" |
| 34 | dest: "{{ docker_registry_dir }}/certs/{{ item.dest }}" |
| 35 | mode: "{{ item.mode }}" |
| 36 | owner: root |
| 37 | group: docker |
| 38 | with_items: |
| 39 | - src: "{{ pki_dir }}/root_ca/certs/ca_cert.pem" |
| 40 | dest: "ca_cert.pem" |
| 41 | mode: "0444" |
| 42 | - src: "{{ pki_dir }}/{{ site_name }}_im_ca/certs/docker-registry.{{ site_suffix }}_cert_chain.pem" |
| 43 | dest: "docker_registry.pem" |
| 44 | mode: "0444" |
| 45 | - src: "{{ pki_dir }}/{{ site_name }}_im_ca/private/docker-registry.{{ site_suffix }}_key.pem" |
| 46 | dest: "docker_registry_key.pem" |
| 47 | mode: "0440" |
| 48 | |
| 49 | - name: Pull the docker registry image |
| 50 | docker_image: |
| 51 | pull: True |
| 52 | name: "{{ docker_registry_image }}" |
| 53 | |
| 54 | - name: Create docker-compose file for running the registry |
| 55 | template: |
| 56 | src: docker-compose.yml.j2 |
| 57 | dest: "{{ docker_registry_dir }}/docker-compose.yml" |
| 58 | owner: root |
| 59 | group: docker |
| 60 | mode: 0640 |
| 61 | |
| 62 | - name: Start the docker registry |
| 63 | docker_service: |
| 64 | project_name: "cordreg" |
| 65 | project_src: "{{ docker_registry_dir }}/" |
| 66 | |