Skip to content

Commit

Permalink
img infra artifacts isolation wip
Browse files Browse the repository at this point in the history
  • Loading branch information
usrbinkat committed Oct 18, 2020
1 parent fb63daa commit 76891b3
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 3 deletions.
6 changes: 3 additions & 3 deletions collector/bundle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@
- 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

####### SHA256sum ArtifactsBundle.tar.xz
- 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
62 changes: 62 additions & 0 deletions collector/tools.yml
Original file line number Diff line number Diff line change
@@ -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
1 change: 1 addition & 0 deletions collector/tree.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
mode: '0744'
recurse: yes
with_items:
- '{{ local_tmp }}'
- '{{ dir_platform }}'
- '{{ dir_platform }}/mirror'
- '{{ dir_platform }}/secrets'
Expand Down
1 change: 1 addition & 0 deletions collector/vars/global.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit 76891b3

Please sign in to comment.