From 44fba037f5b448b57cda0ba17293cf1236863c32 Mon Sep 17 00:00:00 2001 From: usrbinkat Date: Sun, 18 Oct 2020 04:16:57 +0000 Subject: [PATCH] img infra artifacts isolation wip --- collector/images.yml | 2 +- collector/site.yml | 3 +- collector/tools.yml | 59 ++++++++------------------------------- collector/tree.yml | 1 + collector/vars/global.yml | 1 + 5 files changed, 17 insertions(+), 49 deletions(-) diff --git a/collector/images.yml b/collector/images.yml index acf7051..ab06ff1 100755 --- a/collector/images.yml +++ b/collector/images.yml @@ -36,7 +36,7 @@ ######### 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 \ + {{ dir_bin }}/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 \ diff --git a/collector/site.yml b/collector/site.yml index e1cb3db..84d6896 100755 --- a/collector/site.yml +++ b/collector/site.yml @@ -20,6 +20,7 @@ - import_playbook: tree.yml # Create base directory tree - import_playbook: secrets.yml # Collect Secrets -- import_playbook: images.yml # Pull cloudctl images & Download container images to directory +- import_playbook: tools.yml # Pull OpenShift oc, openshift-install, and kubectl binaries +- import_playbook: images.yml # Download OCP Infra Container Images - import_playbook: bundle.yml # Bundle artifacts for airgap pivot # import_playbook: upload.yml # Push artifacts to desired location diff --git a/collector/tools.yml b/collector/tools.yml index 275ad9f..f152027 100755 --- a/collector/tools.yml +++ b/collector/tools.yml @@ -10,53 +10,18 @@ tasks: - ####### Place OpenShift Version Manifest + ####### Place OpenShift Install Binary - 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' + unarchive: + src: "https://mirror.openshift.com/pub/openshift-v4/clients/ocp/{{ version_openshift }}/openshift-install-linux.tar.gz" + dest: '{{ dir_bin }}' + remote_src: yes 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 + ####### Place OpenShift Install Binary + - name: '{{ ansible_name_module }} | get_url:url | Place OpenShift release.txt | {{ version_openshift }}' + unarchive: + src: "https://mirror.openshift.com/pub/openshift-v4/clients/ocp/{{ version_openshift }}/openshift-client-linux.tar.gz" + dest: '{{ dir_bin }}' + remote_src: yes + mode: 0775 diff --git a/collector/tree.yml b/collector/tree.yml index 84d81ff..487b8fd 100755 --- a/collector/tree.yml +++ b/collector/tree.yml @@ -15,6 +15,7 @@ mode: '0744' recurse: yes with_items: + - '{{ dir_bin }}' - '{{ local_tmp }}' - '{{ dir_platform }}' - '{{ dir_platform }}/mirror' diff --git a/collector/vars/global.yml b/collector/vars/global.yml index a5be7a6..4a861d4 100644 --- a/collector/vars/global.yml +++ b/collector/vars/global.yml @@ -19,6 +19,7 @@ ansible_ssh_common_args: '-o StrictHostKeyChecking=no' # Directory Inventory local_home: "{{ lookup('env', 'HOME') }}" local_tmp: /tmp/koffer +dir_bin: "{{ dir_platform }}/bin" dir_iac: "{{ dir_platform }}/iac" dir_koffer: "{{ local_home }}/koffer" dir_bundle: "{{ local_home }}/bundle"