From 5977167e4b768bc7a63eb65346ec808ded0aaeba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicolas=20Mass=C3=A9?= Date: Thu, 7 Dec 2017 16:49:37 +0100 Subject: [PATCH] filter the list of available templates --- ...sion-global-templates-and-imagestreams.yml | 72 +++++++++++++++++++ playbooks/site.yml | 4 +- prod.hosts | 10 +++ 3 files changed, 85 insertions(+), 1 deletion(-) create mode 100644 playbooks/provision-global-templates-and-imagestreams.yml diff --git a/playbooks/provision-global-templates-and-imagestreams.yml b/playbooks/provision-global-templates-and-imagestreams.yml new file mode 100644 index 0000000..1739225 --- /dev/null +++ b/playbooks/provision-global-templates-and-imagestreams.yml @@ -0,0 +1,72 @@ +--- + + - 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: Delete the temporary directory + file: + path: '{{ tempfile.path }}' + state: absent diff --git a/playbooks/site.yml b/playbooks/site.yml index fb4afd3..8f48483 100644 --- a/playbooks/site.yml +++ b/playbooks/site.yml @@ -5,8 +5,10 @@ - include: "preparation.yml" # Launch the OpenShift Installer Playbook - - include: "./openshift-ansible/playbooks/byo/config.yml" + - include: "../openshift-ansible/playbooks/byo/config.yml" - include: "post-install.yml" + - include: "provision-global-templates-and-imagestreams.yml" + - include: "configure-openshift-access-control.yml" diff --git a/prod.hosts b/prod.hosts index 3cff188..46267b3 100644 --- a/prod.hosts +++ b/prod.hosts @@ -4,6 +4,8 @@ [itix:vars] itix_dns_suffix=itix.fr itix_openshift_version=3.7 +itix_application_templates_repo_tag=ose-v1.4.7 +itix_openshift_origin_repo_tag=release-3.7 [itix:children] masters @@ -33,6 +35,14 @@ nodes etcd [OSEv3:vars] +# +# Starting with 3.6, default templates and imagestreams can be left out +# see https://bugzilla.redhat.com/show_bug.cgi?id=1506578 +# +openshift_install_examples=true +openshift_examples_load_quickstarts=false +openshift_examples_load_xpaas=false + # Yes, we need to use sudo ansible_become=yes