From 76891b357cd6ef3485f70b4f6907bccd7946469f Mon Sep 17 00:00:00 2001 From: usrbinkat Date: Sun, 18 Oct 2020 04:00:04 +0000 Subject: [PATCH] img infra artifacts isolation wip --- collector/bundle.yml | 6 ++-- collector/tools.yml | 62 +++++++++++++++++++++++++++++++++++++++ collector/tree.yml | 1 + collector/vars/global.yml | 1 + 4 files changed, 67 insertions(+), 3 deletions(-) create mode 100755 collector/tools.yml diff --git a/collector/bundle.yml b/collector/bundle.yml index bc4cb45..40487ab 100755 --- a/collector/bundle.yml +++ b/collector/bundle.yml @@ -23,7 +23,7 @@ - name: '{{ ansible_name_module }} | stat:sha256 | SHA ArtifactsBundle.tar.xz' command: 'sha256sum koffer-bundle.ocp-{{ version_openshift }}.tar.xz' args: - chdir: '/tmp/' + chdir: '{{ dir_bundle }}' warn: false register: bundle_sha @@ -31,5 +31,5 @@ - name: '{{ ansible_name_module }} | copy:content.bundle_sha | Place SHA256 SUM File | {{ bundle_sha.stdout }}' copy: content: '{{ bundle_sha.stdout }}' - dest: /tmp/koffer-bundle.ocp-{{ version_openshift }}.tar.xz.sha256 - mode: 0600 + dest: "{{ dir_bundle }}/koffer-bundle.ocp-{{ version_openshift }}.tar.xz.sha256" + mode: 0775 diff --git a/collector/tools.yml b/collector/tools.yml new file mode 100755 index 0000000..275ad9f --- /dev/null +++ b/collector/tools.yml @@ -0,0 +1,62 @@ +#!/usr/local/bin/ansible-playbook --inventory=inventory.yaml +- name: '{{ name_vendor }} | Koffer | images.yml' + hosts: koffer + vars_files: + - 'vars/global.yml' + + vars: + module: "images" + ansible_name_module: "{{ ansible_name }} | {{ module }}" + + tasks: + + ####### Place OpenShift Version Manifest + - name: '{{ ansible_name_module }} | get_url:url | Place OpenShift release.txt | {{ version_openshift }}' + get_url: + url: 'https://mirror.openshift.com/pub/openshift-v4/clients/ocp/{{ version_openshift }}/openshift-install-linux.tar.gz' + dest: '{{ dir_platform }}/nginx/openshift/latest/release.txt' + mode: 0775 + + ###### Evaluate lock file presence + - name: '{{ ansible_name_module }} | stat | check for mirror v2.sha256 Lock file' + stat: + path: '{{ dir_platform }}/mirror/ocp-release.{{ version_openshift }}.lock' + register: mirror_lock_check + + ###### Download OpenShift Docker Images from Quay.io to File: /root/platform/mirror/v2 + - name: '{{ ansible_name_module }} | block | Download OpenShift images' + block: + + ######### Purge & Prepare + - name: '{{ ansible_name_module }} | file:directory | Create mirror artifact directories' + file: + path: "{{ dir_platform }}/mirror" + state: directory + + ######### Mirror Images to directory + - name: '{{ ansible_name_module }} | shell:oc.adm.release.mirror | Sync content from quay.io' + shell: | + oc adm release mirror --insecure=true \ + --to=localhost:5000/openshift-release-dev \ + --registry-config=/root/.docker/config.json \ + --from=quay.io/openshift-release-dev/ocp-release:{{ version_openshift }}-x86_64 \ + --to-release-image=localhost:5000/openshift-release-dev:{{ version_openshift }}-x86_64 + when: image_mirror_utility == "oc" + + ######### Skopeo Copy Images to Registry + - name: '{{ ansible_name_module }} | shell:skopeo.copy | Sync content from quay.io' + shell: | + for i in $(cat /var/lib/koffer/release.list); do \ + skopeo copy docker://quay.io/$i \ + docker://localhost:5000/openshift-release-dev/$i ; \ + done + when: image_mirror_utility == "skopeo" + + ####### Block Conditionals + when: not mirror_lock_check.stat.exists + + - name: '{{ ansible_name_module }} | command:touch | Place mirror lock file' + command: + cmd: 'touch {{ dir_platform }}/mirror/ocp-release.{{ version_openshift }}.lock' + args: + warn: false diff --git a/collector/tree.yml b/collector/tree.yml index f4c6706..84d81ff 100755 --- a/collector/tree.yml +++ b/collector/tree.yml @@ -15,6 +15,7 @@ mode: '0744' recurse: yes with_items: + - '{{ local_tmp }}' - '{{ dir_platform }}' - '{{ dir_platform }}/mirror' - '{{ dir_platform }}/secrets' diff --git a/collector/vars/global.yml b/collector/vars/global.yml index dbc4bba..a5be7a6 100644 --- a/collector/vars/global.yml +++ b/collector/vars/global.yml @@ -18,6 +18,7 @@ ansible_ssh_common_args: '-o StrictHostKeyChecking=no' # Directory Inventory local_home: "{{ lookup('env', 'HOME') }}" +local_tmp: /tmp/koffer dir_iac: "{{ dir_platform }}/iac" dir_koffer: "{{ local_home }}/koffer" dir_bundle: "{{ local_home }}/bundle"