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.
96 lines
3.7 KiB
96 lines
3.7 KiB
---
|
|
|
|
- include: "../openshift-ansible/playbooks/byo/openshift-master/additional_config.yml"
|
|
|
|
- name: Provision the default templates and image streams in OpenShift
|
|
hosts: itix
|
|
become: yes
|
|
vars:
|
|
itix_application_templates_repo_url: https://github.com/jboss-openshift/application-templates.git
|
|
tasks:
|
|
- name: Create a temporary directory
|
|
tempfile:
|
|
state: directory
|
|
register: tempfile
|
|
|
|
- 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: 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/sso/sso71-postgresql-persistent.json'
|
|
- '{{ tempfile.path }}/application-templates/openjdk/openjdk18-web-basic-s2i.json'
|
|
- '{{ tempfile.path }}/openshift-origin/examples/jenkins/jenkins-persistent-template.json'
|
|
|
|
- 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
|
|
command: oc import-image -n openshift {{ item.key }} --from {{ item.value }} --confirm --scheduled --all
|
|
with_dict:
|
|
rhel-atomic: rhel-atomic
|
|
rhel: rhel7.4
|
|
when: '(''imagestreams/'' ~ item.key) not in oc_get_is.stdout_lines'
|
|
|
|
- name: Delete the temporary directory
|
|
file:
|
|
path: '{{ tempfile.path }}'
|
|
state: absent
|
|
|