Andrew Block
2020-02-22 7bd2f355534f5f4171d312f0e6c3dcca36758d70
Added validation playbook for Tekton foundations lab (#1176)

2 files modified
83 ■■■■■ changed files
ansible/roles/ocp4-workload-tektoncd-foundations/defaults/main.yml 30 ●●●●● patch | view | raw | blame | history
ansible/roles/ocp4-workload-tektoncd-foundations/tasks/post_workload.yml 53 ●●●●● patch | view | raw | blame | history
ansible/roles/ocp4-workload-tektoncd-foundations/defaults/main.yml
@@ -13,3 +13,33 @@
_knative_cli_url: "https://github.com/knative/client/releases/download/v{{ _knative_version }}/kn-linux-amd64"
_rhd_infra_project: rhd-workshop-infra
pipelines_operator_name: openshift-pipelines-operator
pipelines_operator_version: v0.8.2
supported_api_versions:
    - v1alpha1
crds:
    - clustertasks
    - conditions
    - pipelineresources
    - pipelineruns
    - pipelines
    - tasks
    - taskruns
api_group: tekton.dev
tkn_api_versions: []
expected_tkn_api_versions:
    - clustertasks:
          - v1alpha1
    - conditions:
          - v1alpha1
    - pipelineresources:
          - v1alpha1
    - pipelineruns:
          - v1alpha1
    - tasks:
          - v1alpha1
    - taskruns:
          - v1alpha1
ansible/roles/ocp4-workload-tektoncd-foundations/tasks/post_workload.yml
@@ -1,6 +1,59 @@
---
# Implement your Post Workload deployment tasks here
- name: find tekton subscription
  set_fact:
    tkn_sub: "{{ lookup('k8s', api_version='operators.coreos.com/v1alpha1', kind='Subscription',namespace='openshift-operators', resource_name='openshift-pipelines') | json_query('status.installedCSV') }}"
- set_fact:
    tkn_installed: "{{pipelines_operator_name + '.' + tkn_sub == pipelines_operator_name + '.' + pipelines_operator_version}}"
- name: Checking if right version of Tekton is installed
  fail:
    msg: "Right version of Tekton not installed expecting {{operator_version}} but got {{tkn_sub}} "
  when: tkn_installed
- name: find Tekton API versions
  set_fact:
    tkn_api_versions: "{{ tkn_api_versions + [{ item : lookup('k8s', api_version='apiextensions.k8s.io/v1beta1', kind='CustomResourceDefinition', resource_name='tasks.'+api_group) | json_query('spec.versions[*].name')}] }}"
  with_items: "{{crds}}"
- set_fact:
    api_delta: "{{ expected_tkn_api_versions  | difference(tkn_api_versions) }}"
- name: Is there is difference in API versions
  fail:
    msg: "There is difference in API: {{api_delta}}"
  when:  api_delta | length > 0
- name: Check if tkn installed
  shell: tkn version
  register: tkn_version
- name: Check tkn version
  fail:
    msg: Check if tkn version {{ _tekton_version }}
  when: not tkn_version.stdout is search(_tekton_version)
- name: Check yq exists
  shell: yq --version
  register: yq_version
- name: Check yq version
  fail:
    msg: Check if "yq version {{ _yq_version }}"
  when: not yq_version.stdout is search(_yq_version)
- name: Check if kn installed
  shell: kn version
  register: kn_version
- name: Check if "kn version is v0.12.0
  fail:
    msg: Check if kn version is {{ _knative_version }}
  when: not kn_version.stdout is search(_knative_version)
# Leave these as the last tasks in the playbook
# For deployment onto a dedicated cluster (as part of the