--- - 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/{{ cn }}.crt" /root/docker-registry/nginx/ cp "/etc/ssl/certs/{{ cn }}.ca" /root/docker-registry/nginx/ cp "/etc/ssl/private/{{ cn }}.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 }