refactor ansible code in to ansible-2.0 folder, and created space for ansible-2.10
This commit is contained in:
40
ansible-2.0/roles/docker_registry/tasks/main.yml
Normal file
40
ansible-2.0/roles/docker_registry/tasks/main.yml
Normal file
@@ -0,0 +1,40 @@
|
||||
---
|
||||
# Main task for creating a docker registry
|
||||
|
||||
- name: clean up old config
|
||||
command: "{{ item }}"
|
||||
with_items:
|
||||
- "rm -rf /opt/dkrepository"
|
||||
- "rm -rf /opt/shared/dkrepository/auth"
|
||||
|
||||
# create folders for certs, data,
|
||||
- name: create data folders (/opt/dkregistry)
|
||||
file:
|
||||
path: "{{ item }}"
|
||||
state: directory
|
||||
owner: root
|
||||
group: docker
|
||||
mode: 0770
|
||||
with_items:
|
||||
- /opt/shared/dkregistry/data
|
||||
- /opt/shared/dkregistry/auth
|
||||
|
||||
# make auth files using docker container
|
||||
- name: create auth file
|
||||
shell: echo '' > /opt/shared/dkregistry/auth/htpasswd
|
||||
|
||||
- name: add user to auth file
|
||||
shell: "docker run --entrypoint htpasswd registry:2 -Bbn {{ item.name }} {{ item.pass }} >> /opt/shared/dkregistry/auth/htpasswd"
|
||||
with_items:
|
||||
- { "name" : "richard", "pass" : "richard" }
|
||||
- { "name" : "testuser", "pass" : "testpassword" }
|
||||
|
||||
- name: copy composer file
|
||||
copy:
|
||||
src: docker-compose.yml
|
||||
dest: /opt/dkregistry/docker-compose.yml
|
||||
|
||||
- name: run docker up
|
||||
shell: "docker-compose down && docker-compose create && docker-compose start"
|
||||
args:
|
||||
chdir: /opt/dkregistry
|
||||
Reference in New Issue
Block a user