From 467767b68924ee4817f6f7cea88c38bb7db41626 Mon Sep 17 00:00:00 2001 From: Mohammed Naser Date: Thu, 11 Apr 2019 16:16:22 -0400 Subject: [PATCH] initial commit --- README.md | 13 +++++++++++++ defaults/main.yaml | 2 ++ meta/main.yaml | 19 +++++++++++++++++++ tasks/install/centos.yaml | 7 +++++++ tasks/main.yaml | 20 ++++++++++++++++++++ templates/config.yml.j2 | 15 +++++++++++++++ vars/centos.yaml | 3 +++ 7 files changed, 79 insertions(+) create mode 100644 README.md create mode 100644 defaults/main.yaml create mode 100644 meta/main.yaml create mode 100644 tasks/install/centos.yaml create mode 100644 tasks/main.yaml create mode 100644 templates/config.yml.j2 create mode 100644 vars/centos.yaml diff --git a/README.md b/README.md new file mode 100644 index 0000000..7fed9a2 --- /dev/null +++ b/README.md @@ -0,0 +1,13 @@ +# ansible-role-docker-distribution + +## Examples + +### Pass-through cache +```yaml +- hosts: registry + roles: + - docker-distribution + vars: + docker_distribution_proxy: + remoteurl: https://registry-1.docker.io +``` \ No newline at end of file diff --git a/defaults/main.yaml b/defaults/main.yaml new file mode 100644 index 0000000..dad6b8f --- /dev/null +++ b/defaults/main.yaml @@ -0,0 +1,2 @@ +--- +docker_distribution_proxy: {} \ No newline at end of file diff --git a/meta/main.yaml b/meta/main.yaml new file mode 100644 index 0000000..edaff5a --- /dev/null +++ b/meta/main.yaml @@ -0,0 +1,19 @@ +--- +galaxy_info: + role_name: docker-registry + description: Install & configure Docker registry + license: Apache + + author: Mohammed Naser + company: VEXXHOST, Inc. + + platforms: + - name: Debian + versions: + - stretch + - name: Ubuntu + versions: + - bionic + - name: EL + versions: + - 7 \ No newline at end of file diff --git a/tasks/install/centos.yaml b/tasks/install/centos.yaml new file mode 100644 index 0000000..aea30a6 --- /dev/null +++ b/tasks/install/centos.yaml @@ -0,0 +1,7 @@ +--- +- name: Install packages (RedHat) + yum: + name: "{{ docker_distribution_packages }}" + enablerepo: extras + state: present + when: ansible_os_family == 'RedHat' diff --git a/tasks/main.yaml b/tasks/main.yaml new file mode 100644 index 0000000..2441190 --- /dev/null +++ b/tasks/main.yaml @@ -0,0 +1,20 @@ +--- +- name: Gather variables for each operating system + include_vars: "{{ item }}.yaml" + with_first_found: + - "{{ ansible_distribution | lower }}-{{ ansible_distribution_version | lower }}" + - "{{ ansible_distribution | lower }}-{{ ansible_distribution_major_version | lower }}" + - "{{ ansible_os_family | lower }}-{{ ansible_distribution_major_version | lower }}" + - "{{ ansible_distribution | lower }}" + - "{{ ansible_os_family | lower }}-{{ ansible_distribution_version.split('.')[0] }}" + - "{{ ansible_os_family | lower }}" + +- name: Install packages + import_tasks: "install/{{ item }}.yaml" + with_first_found: + - "{{ ansible_distribution | lower }}-{{ ansible_distribution_version | lower }}" + - "{{ ansible_distribution | lower }}-{{ ansible_distribution_major_version | lower }}" + - "{{ ansible_os_family | lower }}-{{ ansible_distribution_major_version | lower }}" + - "{{ ansible_distribution | lower }}" + - "{{ ansible_os_family | lower }}-{{ ansible_distribution_version.split('.')[0] }}" + - "{{ ansible_os_family | lower }}" \ No newline at end of file diff --git a/templates/config.yml.j2 b/templates/config.yml.j2 new file mode 100644 index 0000000..ae36211 --- /dev/null +++ b/templates/config.yml.j2 @@ -0,0 +1,15 @@ +--- +version: 0.1 +log: + fields: + service: registry +storage: + cache: + layerinfo: inmemory + filesystem: + rootdirectory: /var/lib/registry +{% if docker_distribution_proxy %} +proxy: {{ docker_distribution_proxy | to_nice_yaml }} +{% endif %} +http: + addr: :5000 \ No newline at end of file diff --git a/vars/centos.yaml b/vars/centos.yaml new file mode 100644 index 0000000..0a7184d --- /dev/null +++ b/vars/centos.yaml @@ -0,0 +1,3 @@ +--- +docker_distribution_packages: + - docker-distribution \ No newline at end of file