Skip to content

Instantly share code, notes, and snippets.

@nmasse-itix
Created May 31, 2018 06:23
Show Gist options
  • Save nmasse-itix/464cfd27a66dda71fce81febb424f233 to your computer and use it in GitHub Desktop.
Save nmasse-itix/464cfd27a66dda71fce81febb424f233 to your computer and use it in GitHub Desktop.
OpenShift Image Download
---
- name: Fetch OpenShift Images
hosts: localhost
become: yes
gather_facts: no
vars:
openshift_base_image: openshift3/ose
redhat_registry: registry.access.redhat.com
openshift_images:
- openshift3/ose-ansible
- openshift3/ose-cluster-capacity
- openshift3/ose-deployer
- openshift3/ose-docker-builder
- openshift3/ose-docker-registry
- openshift3/ose-egress-http-proxy
- openshift3/ose-egress-router
- openshift3/ose-f5-router
- openshift3/ose-haproxy-router
- openshift3/ose-keepalived-ipfailover
- openshift3/ose-pod
- openshift3/ose-sti-builder
- openshift3/ose
- openshift3/container-engine
- openshift3/node
- openshift3/openvswitch
- rhel7/etcd
- openshift3/logging-auth-proxy
- openshift3/logging-curator
- openshift3/logging-elasticsearch
- openshift3/logging-fluentd
- openshift3/logging-kibana
- openshift3/metrics-cassandra
- openshift3/metrics-hawkular-metrics
- openshift3/metrics-hawkular-openshift-agent
- openshift3/metrics-heapster
- openshift3/prometheus
- openshift3/prometheus-alert-buffer
- openshift3/prometheus-alertmanager
- openshift3/prometheus-node-exporter
- cloudforms46/cfme-openshift-postgresql
- cloudforms46/cfme-openshift-memcached
- cloudforms46/cfme-openshift-app-ui
- cloudforms46/cfme-openshift-app
- cloudforms46/cfme-openshift-embedded-ansible
- cloudforms46/cfme-openshift-httpd
- cloudforms46/cfme-httpd-configmap-generator
- rhgs3/rhgs-server-rhel7
- rhgs3/rhgs-volmanager-rhel7
- rhgs3/rhgs-gluster-block-prov-rhel7
- rhgs3/rhgs-s3-server-rhel7
- openshift3/ose-service-catalog
- openshift3/ose-ansible-service-broker
- openshift3/mediawiki-apb
- openshift3/postgresql-apb
tasks:
- name: Get available tags
command: skopeo inspect 'docker://{{ redhat_registry }}/{{ openshift_base_image }}'
register: skopeo
- set_fact:
openshift_tags: '{{ (skopeo.stdout|from_json).RepoTags|sort }}'
- debug:
msg: 'No tag specified, using the latest available tag'
when: 'tag is not defined'
- assert:
that:
- tag in openshift_tags
msg: "invalid tag {{ tag }} !"
when: tag is defined
- set_fact:
tag: '{{ openshift_tags|last }}'
when: tag is not defined
- set_fact:
outdir: 'images-{{ tag }}'
- name: Create a directory to hold the images
file:
path: '{{ outdir }}'
state: directory
- name: Read the OCI index.json
slurp:
src: '{{ outdir }}/index.json'
register: slurp
- set_fact:
existing_images: '{{ slurp.content|b64decode|from_json|json_query(''manifests[*].annotations."org.opencontainers.image.ref.name"'') }}'
- name: Downloading OpenShift images...
command: skopeo copy 'docker://{{ redhat_registry }}/{{ item }}:{{ tag }}' 'oci:{{ outdir }}:{{ item }}:{{ tag }}'
with_items: '{{ openshift_images }}'
when: item ~ ":" ~ tag not in existing_images
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment