adding a docker registry to the head node

Change-Id: I9509b32c00c097259b83a802ab35f8c529a95947
diff --git a/roles/maas/templates/automation-compose.yml.j2 b/roles/maas/templates/automation-compose.yml.j2
index 4d2400b..b3ade60 100644
--- a/roles/maas/templates/automation-compose.yml.j2
+++ b/roles/maas/templates/automation-compose.yml.j2
@@ -71,3 +71,4 @@
     - "/etc/maas/virtualbox:/etc/maas/virtualbox"
 {% endif %}
   command: [ "-apiVersion", "1.0", "-apikey", "{{ apikey.stdout }}", "-maas", "http://{{ mgmt_ip_address.stdout }}/MAAS", "-period", "30s", "-mappings", "@/mappings/mappings.json", "-always-rename" ]
+
diff --git a/roles/registry/files/mirror-config.yml b/roles/registry/files/mirror-config.yml
new file mode 100644
index 0000000..65ff62c
--- /dev/null
+++ b/roles/registry/files/mirror-config.yml
@@ -0,0 +1,23 @@
+version: 0.1
+log:
+  fields:
+    service: registry
+storage:
+  cache:
+    blobdescriptor: inmemory
+  filesystem:
+    rootdirectory: /var/lib/registry
+  delete:
+    enabled: true
+http:
+    addr: :5000
+    headers:
+        X-Content-Type-Options: [nosniff]
+health:
+  storagedriver:
+    enabled: true
+    interval: 10s
+    threshold: 3
+
+proxy:
+  remoteurl: https://registry-1.docker.io
diff --git a/roles/registry/meta/main.yml b/roles/registry/meta/main.yml
new file mode 100644
index 0000000..1bdb78b
--- /dev/null
+++ b/roles/registry/meta/main.yml
@@ -0,0 +1,15 @@
+---
+galaxy_info:
+  author: ON.Lab
+  description: Services required to bare metal boot CORD POD
+  company: Open Networking Laboratory
+  license: Apache 2.0
+  min_ansible_version: 2.0
+  platforms:
+    - name: Ubuntu
+      versions:
+        - trusty
+  galaxy_tags:
+    - cord
+dependencies:
+  - { role : docker }
diff --git a/roles/registry/tasks/main.yml b/roles/registry/tasks/main.yml
new file mode 100644
index 0000000..c67924d
--- /dev/null
+++ b/roles/registry/tasks/main.yml
@@ -0,0 +1,33 @@
+- name: Directories are present
+  file:
+    path: "{{ item }}"
+    state: directory
+    recurse: yes
+  with_items:
+    - /data/registry-mirror/conf
+  tags: [registry]
+
+- name: Configuration is copied
+  copy:
+    src: mirror-config.yml
+    dest: /data/registry-mirror/conf/config.yml
+  tags: [registry]
+
+- name: Local Docker Registry
+  become: yes
+  template:
+    src: templates/{{ item }}.j2
+    dest: /etc/maas/{{ item }}
+    owner: maas
+    group: maas
+    mode: 0644
+  with_items:
+    - registry-compose.yml
+  tags: [registry]
+
+- name: Ensure Local Registry Running
+  become: yes
+  command: docker-compose -f /etc/maas/{{ item }} up -d
+  with_items:
+    - registry-compose.yml
+  tags: [registry]
diff --git a/roles/registry/templates/registry-compose.yml.j2 b/roles/registry/templates/registry-compose.yml.j2
new file mode 100644
index 0000000..f4702c5
--- /dev/null
+++ b/roles/registry/templates/registry-compose.yml.j2
@@ -0,0 +1,18 @@
+registry:
+  image: registry:2.4.0
+  container_name: registry
+  volumes:
+   - /docker-registry/registry:/var/lib/registry/docker/registry
+   - /docker-registry/conf:/conf
+  ports:
+    - "5000:5000"
+
+registry-mirror:
+  image: registry:2.4.0
+  container_name: registry-mirror
+  volumes:
+   - /docker-registry-mirror/registry:/var/lib/registry/docker/registry
+   - /docker-registry-mirror/conf:/conf
+  command: serve /conf/config.yml
+  ports:
+    - "5001:5000"