OpenShift Origin Implementation at ITIX (mostly Ansible Playbooks)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

105 lines
3.8 KiB

---
- name: Create a temporary directory
tempfile:
state: directory
register: tempfile
- name: Copy the Custom SSO template
copy:
src: 'sso71-allinone.yaml'
dest: '{{ tempfile.path }}/sso71-allinone.yaml'
- name: Clone the jboss-openshift/application-templates GIT repository
git:
repo: '{{ itix_application_templates_repo_url }}'
dest: '{{ tempfile.path }}/application-templates'
version: '{{ itix_application_templates_repo_tag|default(''master'') }}'
- name: Get an archive of the OpenShift GIT repository
get_url:
url: 'https://github.com/openshift/origin/archive/{{ itix_openshift_origin_repo_tag|default(''master'') }}.tar.gz'
dest: '{{ tempfile.path }}/openshift-origin.tar.gz'
- name: Get the Minio template
get_url:
url: 'https://raw.githubusercontent.com/nmasse-itix/OpenShift-Docker-Images/master/minio/minio.yaml'
dest: '{{ tempfile.path }}/minio.yaml'
- name: Extract the OpenShift GIT archive
unarchive:
remote_src: yes
src: '{{ tempfile.path }}/openshift-origin.tar.gz'
dest: '{{ tempfile.path }}'
- name: Symlink the OpenShift GIT repo
file:
src: '{{ tempfile.path }}/origin-{{ itix_openshift_origin_repo_tag|default(''master'') }}'
dest: '{{ tempfile.path }}/openshift-origin'
state: link
- set_fact:
objects_to_import:
- '{{ tempfile.path }}/application-templates/jboss-image-streams.json'
- '{{ tempfile.path }}/application-templates/openjdk/openjdk18-web-basic-s2i.json'
- '{{ tempfile.path }}/openshift-origin/examples/jenkins/jenkins-persistent-template.json'
- '{{ tempfile.path }}/sso71-allinone.yaml'
- '{{ tempfile.path }}/minio.yaml'
- name: Install new ImageStreams/Templates in the "openshift" namespace
command: oc create -n openshift -f "{{ item }}"
register: oc
failed_when: oc.rc > 0 and 'Error from server (AlreadyExists):' not in oc.stderr
changed_when: oc.rc == 0
with_items: '{{ objects_to_import }}'
- name: Update existing ImageStreams/Templates in the "openshift" namespace
command: oc replace -n openshift -f "{{ item }}"
register: oc
failed_when: oc.rc > 0 and 'Error from server (NotFound):' not in oc.stderr
changed_when: oc.rc == 0
with_items: '{{ objects_to_import }}'
- name: Get a list of currently installed templates
command: oc get templates -n openshift -o name
register: oc_get_templates
- name: Delete ephemeral templates
command: oc delete {{ item }} -n openshift
when: item|regex_search('-ephemeral$')
with_items: '{{ oc_get_templates.stdout_lines }}'
- name: Get a list of currently installed image streams
command: oc get is -n openshift -o name
register: oc_get_is
- name: Delete unwanted image streams
command: oc delete {{ item }} -n openshift
when: item|regex_search('(datagrid|datavirt|decisionserver|eap64|processserver|tomcat7)')
with_items: '{{ oc_get_is.stdout_lines }}'
- name: Get a list of the remaining image streams
command: oc get is -n openshift -o name
register: oc_get_is
- name: Update each image stream
command: oc import-image {{ item }} --confirm --scheduled --all -n openshift
with_items: '{{ oc_get_is.stdout_lines }}'
- name: Import additional Red Hat image streams (initial import)
command: oc import-image -n openshift {{ item.key }} --from {{ item.value }} --confirm --scheduled
with_dict:
rhel7-atomic: registry.access.redhat.com/rhel7-atomic:latest
rhel7: registry.access.redhat.com/rhel7:latest
when: '(''imagestreams/'' ~ item.key) not in oc_get_is.stdout_lines'
- name: Import additional Red Hat image streams (additional tags)
command: oc tag -n openshift {{ item.value }} {{ item.key }} --scheduled
with_dict:
'rhel7-atomic:7.4': registry.access.redhat.com/rhel7-atomic:7.4
'rhel7:7.4': registry.access.redhat.com/rhel7:7.4
- name: Delete the temporary directory
file:
path: '{{ tempfile.path }}'
state: absent