diff --git a/.ansible-lint b/.ansible-lint index 6523fbec6..682997f12 100644 --- a/.ansible-lint +++ b/.ansible-lint @@ -2,11 +2,10 @@ exclude_paths: - .cache/ # implicit unless exclude_paths is defined in config - .github/ - - roles/ - Dockerfiles - - ./*.yml + - yamllint.yml -warn_list: [] # or 'skip_list' to silence them completely +warn_list: [] # or 'skip_list' to silence them completely skip_list: - deprecated-command-syntax # Using command rather than an argument to e.g. file @@ -17,4 +16,14 @@ skip_list: - command-instead-of-shell # Use shell only when shell functionality is required # - yaml # Violations reported by yamllint - line-length - - comments + - '102' # No Jinja2 + - '206' # Variables should have spaces before and after: {{ var_name}} + - '301' # All tasks should be named + - '302' # Include should has tags + - '303' # Use ":" YAML syntax when arguments are over 4 + - '305' # Variable should has space "{{ foo }}" + - '306' # Shells that use pipes should set the pipefail option + - '403' # Package installs should not use latest + - '502' # Use chown module + - '601' # trailing whitespace + - '602' # line too long diff --git a/ansible-lint.yml b/ansible-lint.yml deleted file mode 100644 index b18a59874..000000000 --- a/ansible-lint.yml +++ /dev/null @@ -1,27 +0,0 @@ ---- - -exclude_paths: - - ansible-lint.yml - - yamllint.yml -quiet: false -skip_list: - - 'colons' - - 'comments' - - 'line-length' - - 'empty-lines' - - 'indentation' - - 'new-line-at-end-of-file' - - 'truthy' - - 'braces' - - 'comments-indentation' - - '102' - - '206' - - '301' - - '302' - - '303' - - '305' - - '306' - - '403' - - '502' - - '601' - - '602' \ No newline at end of file diff --git a/deploy-olm-operator.yml b/deploy-olm-operator.yml index 856644239..883879a2a 100644 --- a/deploy-olm-operator.yml +++ b/deploy-olm-operator.yml @@ -1,5 +1,8 @@ --- -- name: Deploy the operator on an OCP cluster with OLM as part of the operator testing pipeline +- name: > + Deploy the operator on an OCP + cluster with OLM as part of the + operator testing pipeline hosts: all become: false gather_facts: false @@ -15,18 +18,19 @@ quay_token: "{{ quay_token }}" quay_namespace: "cvpops" oc_bin_path: "{{ 'kubectl' if run_upstream else 'oc' }}" - jq_bin_path : "/usr/bin/jq" + jq_bin_path: "/usr/bin/jq" yq_bin_path: "/usr/local/bin/yq" testing_bin_path: "/usr/local/bin" scorecard_first_cr: true run_scorecard: true - current_channel: '' # Added to avoid a bug with undefined variables - + current_channel: '' # Added to avoid a bug with undefined variables tasks: - name: "Login to the testing OpenShift instance" - shell: "{{ oc_bin_path }} login {{ openshift_url }} -u system:admin --insecure-skip-tls-verify" + shell: > + "{{ oc_bin_path }} login {{ openshift_url }} + -u system:admin --insecure-skip-tls-verify" register: login_result retries: 20 delay: 10 @@ -34,8 +38,8 @@ environment: KUBECONFIG: "{{ kubeconfig_path }}" when: - - openshift_url is defined - - not run_upstream|bool + - openshift_url is defined + - not run_upstream|bool - name: "Parse operator metadata needed to run the tests" include_role: @@ -52,8 +56,15 @@ include_role: name: deploy_olm_operator always: - - name: "Remove the quay release of the test operator in the testing namespace" - shell: "curl -s -H \"Authorization: basic {{ quay_token }}\" -X DELETE https://quay.io/cnr/api/v1/packages/{{ quay_namespace }}/{{ package_name }}-test/{{ quay_release }}/helm" + - name: > + "Remove the quay release of the + test operator in the testing namespace" + shell: > + "curl -s -H \"Authorization: basic + {{ quay_token }}\" -X DELETE + https://quay.io/cnr/api/v1/packages/{{ + quay_namespace }}/{{ package_name }}-test/{{ + quay_release }}/helm" when: - quay_release is defined - package_name is defined diff --git a/extract-operator-bundle.yml b/extract-operator-bundle.yml index b6d6c211f..b2a8a5007 100644 --- a/extract-operator-bundle.yml +++ b/extract-operator-bundle.yml @@ -15,7 +15,9 @@ umoci_bin_path: "/usr/local/bin/umoci" tasks: - - name: "Extract the operator bundle image into files needed to run the tests" + - name: > + "Extract the operator bundle + image into files needed to run the tests" include_role: name: extract_operator_bundle diff --git a/local-test-operator-bundle.yml b/local-test-operator-bundle.yml index 5b49b5d20..0340a8c11 100644 --- a/local-test-operator-bundle.yml +++ b/local-test-operator-bundle.yml @@ -12,7 +12,9 @@ run_catalog_init: true work_dir: "/tmp/operator-test" testing_bin_path: "{{ work_dir }}/bin" - current_channel: '' # Added to avoid a potential bug with undefined variables + current_channel: > + '' # Added to avoid a potential + bug with undefined variables olm_ver: 0.14.1 tasks: @@ -24,7 +26,9 @@ umoci_bin_path: "{{ testing_bin_path }}/umoci" opm_bin_path: "{{ testing_bin_path }}/opm" operator_sdk_bin_path: "{{ testing_bin_path }}/operator-sdk" - oc_bin_path: '{{ ''kubectl'' if run_upstream else "{{ testing_bin_path }}/oc" }}' + oc_bin_path: > + '{{ ''kubectl'' if run_upstream + else "{{ testing_bin_path }}/oc" }}' - name: "Install operator testing prerequisites" @@ -37,7 +41,9 @@ name: build_image_bundle when: run_upstream|bool - - name: "Extract the operator bundle image into files needed to run the tests" + - name: > + "Extract the operator bundle image + into files needed to run the tests" include_role: name: extract_operator_bundle @@ -64,10 +70,14 @@ - name: "Install OLM" block: - name: "Installing OLM" - shell: "{{ operator_sdk_bin_path }} olm install --version {{ olm_ver }}" + shell: > + "{{ operator_sdk_bin_path }} olm + install --version {{ olm_ver }}" - name: "Delete catalogsource" - shell: "{{ oc_bin_path }} delete catalogsource operatorhubio-catalog -n olm" + shell: > + "{{ oc_bin_path }} delete catalogsource + operatorhubio-catalog -n olm" ignore_errors: true when: - olm_needed.stdout != "operatorgroup" diff --git a/local-test-operator.yml b/local-test-operator.yml index dc705f079..a945abf8a 100644 --- a/local-test-operator.yml +++ b/local-test-operator.yml @@ -19,7 +19,9 @@ openshift_namespace: "test-operator" work_dir: "/tmp/operator-test" testing_bin_path: "{{ work_dir }}/bin" - current_channel: '' # Added to avoid a potential bug with undefined variables + current_channel: > + '' # Added to avoid a potential + bug with undefined variables olm_ver: 0.14.1 events_file_path: "{{ work_dir }}/events.json" @@ -39,7 +41,9 @@ scorecard_cr_dir: "{{ work_dir }}/scorecard-cr-files" kube_objects_dir: "{{ work_dir }}/kube_objects" testing_bin_path: "{{ work_dir }}/bin" - oc_bin_path: '{{ ''kubectl'' if run_upstream else "{{ testing_bin_path }}/oc" }}' + oc_bin_path: > + '{{ ''kubectl'' if run_upstream else + "{{ testing_bin_path }}/oc" }}' jq_bin_path: "{{ testing_bin_path }}/jq" yq_bin_path: "{{ testing_bin_path }}/yq" go_bin_path: "{{ testing_bin_path }}/go/bin/go" @@ -82,10 +86,14 @@ - name: "Install OLM" block: - name: "Installing OLM" - shell: "{{ operator_sdk_bin_path }} olm install --version {{ olm_ver }}" + shell: > + "{{ operator_sdk_bin_path }} + olm install --version {{ olm_ver }}" - name: "Delete catalogsource" - shell: "{{ oc_bin_path }} delete catalogsource operatorhubio-catalog -n olm" + shell: > + "{{ oc_bin_path }} delete catalogsource + operatorhubio-catalog -n olm" ignore_errors: true when: - olm_needed.stdout != "operatorgroup" @@ -96,7 +104,9 @@ name: build_catalog_upstream when: run_upstream|bool - - name: "Run operator-courier nest to copy the operator metadata in nested format to the work dir" + - name: > + "Run operator-courier nest to copy the + operator metadata in nested format to the work dir" shell: "operator-courier nest {{ operator_dir }} {{ operator_work_dir }}" when: not run_upstream|bool @@ -104,7 +114,7 @@ copy: src: "{{ operator_dir }}/" dest: "{{ operator_work_dir }}" - remote_src: yes + remote_src: true mode: 0644 when: run_upstream|bool @@ -112,7 +122,9 @@ include_role: name: parse_operator_metadata - - name: "Run linting tests with operator-courier verify on the deployed operator" + - name: > + "Run linting tests with operator-courier + verify on the deployed operator" include_role: name: operator_courier_verify when: run_lint|bool @@ -133,16 +145,27 @@ - run_scorecard|bool - not run_upstream|bool - - name: "Get all registry images on the OpenShift cluster before deploying the operator" - shell: "{{ oc_bin_path }} get is --all-namespaces -o json | jq '.items[].spec.tags[] | select(.from.kind == \"DockerImage\") | .from.name' --raw-output | sort -u" + - name: > + "Get all registry images on the OpenShift + cluster before deploying the operator" + shell: > + "{{ oc_bin_path }} get is --all-namespaces + -o json | jq '.items[].spec.tags[] | + select(.from.kind == \"DockerImage\") | + .from.name' --raw-output | sort -u" register: os_registry_is_result_before environment: KUBECONFIG: "{{ kubeconfig_path }}" no_log: true when: not run_upstream|bool - - name: "Get all pod images on the OpenShift cluster before deploying the operator" - shell: "{{ oc_bin_path }} get pods --all-namespaces -o json | jq '.items[].spec.containers[].image' --raw-output | sort -u" + - name: > + "Get all pod images on the OpenShift + cluster before deploying the operator" + shell: > + "{{ oc_bin_path }} get pods --all-namespaces + -o json | jq '.items[].spec.containers[].image' + --raw-output | sort -u" register: os_pod_is_result_before environment: KUBECONFIG: "{{ kubeconfig_path }}" @@ -150,7 +173,9 @@ when: not run_upstream|bool - set_fact: - openshift_images_before: " {{ os_registry_is_result_before.stdout_lines }} + {{ os_pod_is_result_before.stdout_lines }}" + openshift_images_before: > + " {{ os_registry_is_result_before.stdout_lines + }} + {{ os_pod_is_result_before.stdout_lines }}" when: not run_upstream|bool - name: "Set the deployment start time" @@ -186,7 +211,11 @@ - run_upstream|bool - name: "Get all openshift registry images" - shell: "{{ oc_bin_path }} get is --all-namespaces -o json | jq '.items[].spec.tags[] | select(.from.kind == \"DockerImage\") | .from.name' --raw-output | sort -u" + shell: > + "{{ oc_bin_path }} get is --all-namespaces + -o json | jq '.items[].spec.tags[] | + select(.from.kind == \"DockerImage\") | + .from.name' --raw-output | sort -u" register: os_registry_is_result_after environment: KUBECONFIG: "{{ kubeconfig_path }}" @@ -194,7 +223,10 @@ when: not run_upstream|bool - name: "Get all OpenShift pod images" - shell: "{{ oc_bin_path }} get pods --all-namespaces -o json | jq '.items[].spec.containers[].image' --raw-output | sort -u" + shell: > + "{{ oc_bin_path }} get pods --all-namespaces + -o json | jq '.items[].spec.containers[].image' + --raw-output | sort -u" register: os_pod_is_result_after environment: KUBECONFIG: "{{ kubeconfig_path }}" @@ -202,13 +234,17 @@ when: not run_upstream|bool - set_fact: - openshift_images_after: "{{ os_registry_is_result_after.stdout_lines }} + {{ os_pod_is_result_after.stdout_lines }}" + openshift_images_after: > + "{{ os_registry_is_result_after.stdout_lines }} + + {{ os_pod_is_result_after.stdout_lines }}" when: not run_upstream|bool - name: "Scorecard test" block: - name: "Find all extracted CRs from alm-examples" - shell: "find \"{{ scorecard_cr_dir }}\" -name \"*.cr.yaml\" -print" + shell: > + "find \"{{ scorecard_cr_dir }}\" + -name \"*.cr.yaml\" -print" register: scorecard_cr_files_result when: - run_scorecard|bool @@ -224,8 +260,14 @@ - run_scorecard|bool - run_deploy|bool always: - - name: "Get the pod container logs of the operator after running scorecard tests" - shell: "{{ oc_bin_path }} get --output=name pods | grep {{ operator_pod_name }} | xargs -I{} {{ oc_bin_path }} logs {} -c {{ operator_container_name }}" + - name: > + "Get the pod container logs of the + operator after running scorecard tests" + shell: > + "{{ oc_bin_path }} get --output=name pods + | grep {{ operator_pod_name }} | xargs -I{} + {{ oc_bin_path }} logs {} -c {{ + operator_container_name }}" register: operator_container_result ignore_errors: true environment: @@ -241,11 +283,15 @@ when: not run_upstream|bool - - name: "Test image sources of containers introduced with the testing operator" + - name: > + "Test image sources of containers + introduced with the testing operator" include_role: name: operator_imagesource_test vars: - operator_images: "{{ openshift_images_after | difference(openshift_images_before) | list }}" + operator_images: > + "{{ openshift_images_after | + difference(openshift_images_before) | list }}" when: - run_imagesource|bool - run_deploy|bool @@ -262,8 +308,14 @@ - run_cleanup|bool - run_deploy|bool - - name: "Remove the quay release of the test operator in the testing namespace" - shell: "curl -s -H \"Authorization: basic {{ quay_token }}\" -X DELETE https://quay.io/cnr/api/v1/packages/{{ quay_namespace }}/{{ package_name }}-test/{{ quay_release }}/helm" + - name: > + "Remove the quay release of the + test operator in the testing namespace" + shell: > + "curl -s -H \"Authorization: basic {{ quay_token }}\" + -X DELETE https://quay.io/cnr/api/v1/packages/{{ + quay_namespace }}/{{ package_name }}-test/{{ + quay_release }}/helm" when: - quay_release is defined - package_name is defined diff --git a/operator-bundle-scorecard-tests.yml b/operator-bundle-scorecard-tests.yml index 1902cc2bf..7a79832cb 100644 --- a/operator-bundle-scorecard-tests.yml +++ b/operator-bundle-scorecard-tests.yml @@ -8,7 +8,7 @@ # an existing deployment is a prerequisite for the scorecard tests - name: "Run optional operators subscribe step" include_role: - name: optional-operators-subscribe + name: optional_operators_subscribe - name: "Run the operator scorecard tests step" include_role: diff --git a/operator-scorecard-test.yml b/operator-scorecard-test.yml index b89172cfa..da8faecd3 100644 --- a/operator-scorecard-test.yml +++ b/operator-scorecard-test.yml @@ -1,5 +1,8 @@ --- -- name: Run scorecard tests on the OLM deployed operator as part of the operator testing pipeline +- name: > + Run scorecard tests on the OLM + deployed operator as part of + the operator testing pipeline hosts: all become: false gather_facts: false @@ -31,8 +34,14 @@ loop_control: loop_var: cr_path always: - - name: "Get the pod container logs of the operator after running scorecard tests" - shell: "{{ oc_bin_path }} get --output=name pods | grep {{ operator_pod_name }} | xargs -I{} {{ oc_bin_path }} logs {} -c {{ operator_container_name }}" + - name: > + "Get the pod container logs of the + operator after running scorecard tests" + shell: > + "{{ oc_bin_path }} get --output=name pods + | grep {{ operator_pod_name }} | + xargs -I{} {{ oc_bin_path }} logs {} -c + {{ operator_container_name }}" register: operator_container_result ignore_errors: true environment: diff --git a/parse-operator-metadata.yml b/parse-operator-metadata.yml index 68441c5ff..88edd92b2 100644 --- a/parse-operator-metadata.yml +++ b/parse-operator-metadata.yml @@ -8,10 +8,10 @@ run_upstream: false operator_work_dir: "/home/jenkins/agent/test-operator" work_dir: "{{ lookup('env', 'WORKSPACE') }}" - jq_bin_path : "/usr/bin/jq" + jq_bin_path: "/usr/bin/jq" yq_bin_path: "/usr/local/bin/yq" testing_bin_path: "/usr/local/bin" - current_channel: '' # Added to avoid a bug with undefined variables + current_channel: '' # Added to avoid a bug with undefined variables tasks: - name: "Parse operator metadata needed to run the tests" diff --git a/prepare-ocp4-aws-config.yml b/prepare-ocp4-aws-config.yml index fa6c82a2a..03e9723ed 100644 --- a/prepare-ocp4-aws-config.yml +++ b/prepare-ocp4-aws-config.yml @@ -1,29 +1,39 @@ # Extra_vars for the running this playbook # 1. cluster_name: Name of the cluster to be provisioned # 2. aws_region: region on which the ocp_cluster needs to be deployed -# 3. ocp_install_directory: Directory in which the cluster config files are generated -# by default it is fetched from pipleline_repo_path +# 3. ocp_install_directory: +# Directory in which the cluster config files are generated +# by default it is fetched from pipleline_repo_path # 4. ocp_install_config_template: ocp_config file template path # 5. pull_secret_file: path to file containing pull secret dictionary (required) # 6. ssh_key_file: path to file containing ssh_key_file (required) +--- - name: "Prepare OCP 4.x configuration for installation on AWS" hosts: localhost become: false gather_facts: false pre_tasks: # set the default variable using set_fact - - name: "Set default varibles such that they can be overridden by extra-vars and environment variables" + - name: > + "Set default varibles such that they can + be overridden by extra-vars and + environment variables" set_fact: cluster_name: "{{ cluster_name | default('test-cluster') }}" aws_region: "{{ aws_region | default('us-east-2') }}" - name: "Set OCP install directory" - # Note: all the set_fact variables are fetched from extra-vars passed to playbook - # if the variables are not found they would be assuming the default variables + # Note: all the set_fact variables are + # fetched from extra-vars passed to playbook + # if the variables are not found they + # would be assuming the default variables set_fact: - ocp_install_directory: "{{ ocp_install_directory | default(playbook_dir) }}" - ocp_install_config_template: "{{ ocp_install_config_template | - default(playbook_dir+'/install-config.yaml.j2') }}" + ocp_install_directory: > + "{{ ocp_install_directory | + default(playbook_dir) }}" + ocp_install_config_template: | + "{{ ocp_install_config_template | + default(playbook_dir+'/install-config.yaml.j2') }}" tasks: - name: "Ensure that the ocp install directory exists and is empty" file: @@ -34,10 +44,15 @@ - absent - directory - - name: "Inject cluster name: {{ cluster_name }} and region: {{ aws_region }} into the install config" + - name: > + "Inject cluster name: {{ cluster_name }} + and region: {{ aws_region }} into + the install config" template: src: "{{ ocp_install_config_template }}" - dest: "{{ ocp_install_directory }}/{{ cluster_name }}/install-config.yaml" + dest: > + "{{ ocp_install_directory }}/{{ + cluster_name }}/install-config.yaml" mode: 0644 - name: Read pull_secret_file @@ -50,12 +65,16 @@ when: pull_secret_file is defined and ssh_key_file is defined - name: "Prepare the dictionary" set_fact: - secret_dict: "pullSecret: '{{ pull_secret_contents.stdout }}'\nsshKey: '{{ ssh_key_file_contents.stdout }}'" + secret_dict: > + "pullSecret: '{{ pull_secret_contents.stdout + }}'\nsshKey: '{{ ssh_key_file_contents.stdout }}'" no_log: true when: pull_secret_file is defined and ssh_key_file is defined - name: "Inject secrets into the install-config" blockinfile: - path: "{{ ocp_install_directory }}/{{ cluster_name }}/install-config.yaml" + path: > + "{{ ocp_install_directory }}/{{ + cluster_name }}/install-config.yaml" block: "{{ secret_dict }}" insertafter: EOF marker: "" diff --git a/prepare-operator-metadata.yml b/prepare-operator-metadata.yml index 644cfd23a..e02729572 100644 --- a/prepare-operator-metadata.yml +++ b/prepare-operator-metadata.yml @@ -21,19 +21,24 @@ operator_work_dir: "/home/jenkins/agent/test-operator" operator_dir: "/tmp/test" work_dir: "{{ lookup('env', 'WORKSPACE') }}" - jq_bin_path : "/usr/bin/jq" + jq_bin_path: "/usr/bin/jq" yq_bin_path: "/usr/local/bin/yq" testing_bin_path: "/usr/local/bin" - current_channel: '' # Added to avoid a bug with undefined variables + current_channel: '' # Added to avoid a bug with undefined variables tasks: - name: "Set variables for operator_work_dir and operator_dir" set_fact: - operator_work_dir: "{{ operator_work_dir | default('/home/jenkins/agent/test-operator')}}" + operator_work_dir: > + "{{ operator_work_dir | + default('/home/jenkins/agent/test-operator')}}" operator_dir: "{{ operator_dir | default('/tmp/test') }}" - - name: "Run operator-courier nest to copy the operator metadata in nested format to the work dir" + - name: > + "Run operator-courier nest to + copy the operator metadata in + nested format to the work dir" shell: "operator-courier nest {{ operator_dir }} {{ operator_work_dir }}" - name: "Parse operator metadata needed to run the tests" diff --git a/roles/build_catalog_upstream/defaults/main.yml b/roles/build_catalog_upstream/defaults/main.yml index 46b343b22..9d6d89605 100644 --- a/roles/build_catalog_upstream/defaults/main.yml +++ b/roles/build_catalog_upstream/defaults/main.yml @@ -9,5 +9,3 @@ catalog_image_registry: localhost:5000 catalog_image_tag: dev catalog_source_namespace: test-operators catalog_source_name: test-operators - - diff --git a/roles/build_catalog_upstream/tasks/main.yml b/roles/build_catalog_upstream/tasks/main.yml index 5a54a747c..656a5d268 100644 --- a/roles/build_catalog_upstream/tasks/main.yml +++ b/roles/build_catalog_upstream/tasks/main.yml @@ -13,20 +13,20 @@ docker_image: name: "{{ catalog_image_registry }}/{{ catalog_image_namespace }}/{{ catalog_image_name }}" build: - pull: yes + pull: true path: "{{ catalog_repo_dir }}" dockerfile: "{{ catalog_repo_dir }}/{{ catalog_dockerfile }}" args: PERMISSIVE_LOAD: false tag: "{{ catalog_image_tag }}" - push: yes + push: true source: build tags: - catalog_build - name: "Delete previous catalog deployment (it may fail if not exists)" shell: "{{ oc_bin_path }} delete deployment {{ catalog_source_name }} -n {{ catalog_source_namespace }} --ignore-not-found=true" - ignore_errors: yes + ignore_errors: true tags: - catalog_build @@ -44,6 +44,9 @@ - catalog_build - name: "Deploy catalog image as deployment '{{ catalog_source_name }}' in '{{ catalog_source_namespace }}' namespace" - shell: "{{ oc_bin_path }} create deployment {{ catalog_source_name }} --image={{ catalog_image_registry }}/{{ catalog_image_namespace }}/{{ catalog_image_name }}:{{ catalog_image_tag }} -n={{ catalog_source_namespace }}" + shell: > + "{{ oc_bin_path }} create deployment {{ catalog_source_name }} --image={{ catalog_image_registry + }}/{{ catalog_image_namespace }}/{{ catalog_image_name }}:{{ catalog_image_tag }} + -n={{ catalog_source_namespace }}" tags: - - catalog_build \ No newline at end of file + - catalog_build diff --git a/roles/build_image_bundle/defaults/main.yml b/roles/build_image_bundle/defaults/main.yml index 090ef8f4f..173d2f927 100644 --- a/roles/build_image_bundle/defaults/main.yml +++ b/roles/build_image_bundle/defaults/main.yml @@ -4,4 +4,4 @@ operator_version: latest opm_container_tool: "docker" bundle_image_namespace: test-operator bundle_registry: localhost:5000 -operator_input_image_convert: false \ No newline at end of file +operator_input_image_convert: false diff --git a/roles/build_image_bundle/tasks/main.yml b/roles/build_image_bundle/tasks/main.yml index d1e5f38a9..37cc82531 100644 --- a/roles/build_image_bundle/tasks/main.yml +++ b/roles/build_image_bundle/tasks/main.yml @@ -27,14 +27,17 @@ src: "{{ operator_dir }}" dest: "{{ operator_bundle_src_dir }}" mode: 0644 - remote_src: yes + remote_src: true - set_fact: operator_name: "{{ operator_dir | basename }}" - set_fact: bundle_image: "{{ bundle_registry }}/{{ bundle_image_namespace }}/{{ operator_name }}:v{{ operator_version }}" - clusterserviceversion_bundle_file_path: "{{ operator_bundle_src_dir }}/{{ operator_name }}/{{ operator_version }}/manifests/{{ operator_name }}.v{{ operator_version }}.clusterserviceversion.yaml" + clusterserviceversion_bundle_file_path: > + "{{ operator_bundle_src_dir }}/{{ operator_name }}/{{ + operator_version }}/manifests/{{ operator_name }}.v{{ + operator_version }}.clusterserviceversion.yaml" annotation_file_path: "{{ operator_bundle_src_dir }}/{{ operator_name }}/{{ operator_version }}/metadata/annotations.yaml" - set_fact: @@ -90,19 +93,29 @@ operator_package_name: "{{ annotations_vars.annotations['operators.operatorframework.io.bundle.package.v1'] }}" - name: "Generate bundle image {{ bundle_image }} from bundle format" shell: - cmd: "{{ opm_bin_path }} alpha bundle build --directory {{ operator_version }}/{{ operator_manifest_dir }} --package {{ operator_package_name }} -t {{ bundle_image }} -c {{ operator_channels }} -e {{ operator_channel_default }} -b {{ opm_container_tool }}" + cmd: > + "{{ opm_bin_path }} alpha bundle build --directory {{ operator_version + }}/{{ operator_manifest_dir }} --package {{ operator_package_name }} -t {{ + bundle_image }} -c {{ operator_channels }} -e {{ operator_channel_default }} + -b {{ opm_container_tool }}" chdir: "{{ operator_bundle_src_dir }}/{{ operator_name }}" when: operator_format == "bundle" - name: "Generate bundle image {{ bundle_image }} from bundle format" shell: - cmd: "{{ opm_bin_path }} alpha bundle build --directory {{ operator_version }}/{{ operator_manifest_dir }} --package {{ operator_package_name }} -t {{ bundle_image }} -c {{ operator_channels }} -e {{ operator_channel_default }} -b {{ opm_container_tool }}" + cmd: > + "{{ opm_bin_path }} alpha bundle build --directory + {{ operator_version }}/{{ operator_manifest_dir }} --package {{ + operator_package_name }} -t {{ bundle_image }} -c {{ operator_channels }} + -e {{ operator_channel_default }} -b {{ opm_container_tool }}" chdir: "{{ operator_bundle_src_dir }}/{{ operator_name }}" when: operator_format == "bundle" - name: "Generate bundle image {{ bundle_image }} from manifest format" shell: - cmd: "{{ opm_bin_path }} alpha bundle build --directory {{ operator_version }} --package {{ operator_name }} -t {{ bundle_image }} -b {{ opm_container_tool }}" + cmd: > + "{{ opm_bin_path }} alpha bundle build --directory {{ operator_version }} + --package {{ operator_name }} -t {{ bundle_image }} -b {{ opm_container_tool }}" chdir: "{{ operator_bundle_src_dir }}/{{ operator_name }}" when: operator_format == "manifest" diff --git a/roles/build_index_bundle/defaults/main.yml b/roles/build_index_bundle/defaults/main.yml index 33eaa6836..774b483de 100644 --- a/roles/build_index_bundle/defaults/main.yml +++ b/roles/build_index_bundle/defaults/main.yml @@ -5,5 +5,3 @@ bundle_index_image_namespace: test-operator bundle_index_registry: localhost:5000 bundle_image_suffix: "index" bundle_index_image: "{{ bundle_index_registry }}/{{ bundle_index_image_namespace }}/{{ operator_name }}-{{ bundle_image_suffix }}:v{{ operator_version }}" - - diff --git a/roles/cleanup_operator_resources/defaults/main.yml b/roles/cleanup_operator_resources/defaults/main.yml index a55c10187..26bf3ea50 100644 --- a/roles/cleanup_operator_resources/defaults/main.yml +++ b/roles/cleanup_operator_resources/defaults/main.yml @@ -2,4 +2,4 @@ oc_bin_path: "{{ 'kubectl' if run_upstream else 'oc' }}" olm_operator_files_path: "{{ playbook_dir }}/../../operators/olm-operator-files" openshift_namespace: test-operator -kubeconfig_path: "{{ ansible_env.HOME }}/.kube/config" \ No newline at end of file +kubeconfig_path: "{{ ansible_env.HOME }}/.kube/config" diff --git a/roles/cleanup_operator_resources/tasks/main.yml b/roles/cleanup_operator_resources/tasks/main.yml index 2e861f859..dd84f9e68 100644 --- a/roles/cleanup_operator_resources/tasks/main.yml +++ b/roles/cleanup_operator_resources/tasks/main.yml @@ -14,18 +14,18 @@ loop_var: owned_crd_path - block: - - name: "Verify if {{ openshift_namespace }} project exists" - shell: "{{ oc_bin_path }} project {{ openshift_namespace }}" - register: openshift_namespace_check_result - ignore_errors: true - environment: - KUBECONFIG: "{{ kubeconfig_path }}" + - name: "Verify if {{ openshift_namespace }} project exists" + shell: "{{ oc_bin_path }} project {{ openshift_namespace }}" + register: openshift_namespace_check_result + ignore_errors: true + environment: + KUBECONFIG: "{{ kubeconfig_path }}" - - name: "Delete the project {{ openshift_namespace }}" - shell: "{{ oc_bin_path }} delete project {{ openshift_namespace }} --grace-period=1" - environment: - KUBECONFIG: "{{ kubeconfig_path }}" - when: + - name: "Delete the project {{ openshift_namespace }}" + shell: "{{ oc_bin_path }} delete project {{ openshift_namespace }} --grace-period=1" + environment: + KUBECONFIG: "{{ kubeconfig_path }}" + when: - openshift_namespace_check_result is defined - openshift_namespace_check_result.rc == 0 when: not run_upstream|bool diff --git a/roles/collect_modified_images/defaults/main.yml b/roles/collect_modified_images/defaults/main.yml index f8ab382ef..d08cde8fb 100644 --- a/roles/collect_modified_images/defaults/main.yml +++ b/roles/collect_modified_images/defaults/main.yml @@ -1,4 +1,4 @@ pulled_images: [] events_file_path: /tmp/events.json deployment_start_time: 1970-01-01T00:00:00Z -collect_pull_events: true \ No newline at end of file +collect_pull_events: true diff --git a/roles/convert_bundle_image_to_dir/defaults/main.yml b/roles/convert_bundle_image_to_dir/defaults/main.yml index 79003ec9c..a0dc50d35 100644 --- a/roles/convert_bundle_image_to_dir/defaults/main.yml +++ b/roles/convert_bundle_image_to_dir/defaults/main.yml @@ -1,4 +1,4 @@ operator_local_registry: "localhost:5000" -bundle_input_tmp_dir: "{{ work_dir }}/operator-bundle-input/tmp" -bundle_input_src_dir: "{{ work_dir }}/operator-bundle-input/src" -opm_container_tool: docker \ No newline at end of file +bundle_input_tmp_dir: "{{ work_dir }}/operator-bundle-input/tmp" +bundle_input_src_dir: "{{ work_dir }}/operator-bundle-input/src" +opm_container_tool: docker diff --git a/roles/convert_bundle_image_to_dir/tasks/main.yml b/roles/convert_bundle_image_to_dir/tasks/main.yml index d82538a8a..ece615773 100644 --- a/roles/convert_bundle_image_to_dir/tasks/main.yml +++ b/roles/convert_bundle_image_to_dir/tasks/main.yml @@ -63,12 +63,12 @@ with_items: - absent - directory - - name : Move bundle dir to {{ operator_dir }} + - name: Move bundle dir to {{ operator_dir }} copy: src: "{{ bundle_input_src_dir }}/{{ item }}" dest: "{{ operator_dir }}/" - remote_src: yes - directory_mode: yes + remote_src: true + directory_mode: true with_items: - manifests - metadata diff --git a/roles/deploy_olm_operator/defaults/main.yml b/roles/deploy_olm_operator/defaults/main.yml index 5831ecfb0..d05b86b47 100644 --- a/roles/deploy_olm_operator/defaults/main.yml +++ b/roles/deploy_olm_operator/defaults/main.yml @@ -2,4 +2,4 @@ oc_bin_path: oc openshift_namespace: test-operator current_channel: alpha operator_work_dir: /home/jenkins/agent/test-operator -quay_release: 0.0.1 \ No newline at end of file +quay_release: 0.0.1 diff --git a/roles/deploy_olm_operator/tasks/main.yml b/roles/deploy_olm_operator/tasks/main.yml index 400fb3534..199ebb065 100644 --- a/roles/deploy_olm_operator/tasks/main.yml +++ b/roles/deploy_olm_operator/tasks/main.yml @@ -5,12 +5,17 @@ - name: "Deploy olm operator" block: - name: "Check for the existence of earlier releases of the operator on the quay.io app repository" - shell: "curl -s -H \"Authorization: basic {{ quay_token }}\" https://quay.io/cnr/api/v1/packages/{{ quay_namespace }}/{{ package_name }}-test | {{ jq_bin_path }} '.[].release' | sort --version-sort | tail -n 1" + shell: > + "curl -s -H \"Authorization: basic {{ quay_token }}\" https://quay.io/cnr/api/v1/packages/{{ + quay_namespace }}/{{ package_name }}-test | {{ jq_bin_path }} '.[].release' | sort --version-sort | tail -n 1" register: quay_release_result no_log: true - name: "Increment testing quay app release if exists" - shell: "echo {{ quay_release_result.stdout }} | awk -F. -v OFS=. 'NF==1{print ++$NF}; NF>1{if(length($NF+1)>length($NF))$(NF-1)++; $NF=sprintf(\"%0*d\", length($NF), ($NF+1)%(10^length($NF))); print}'" + shell: > + "echo {{ quay_release_result.stdout }} | awk -F. -v OFS=. 'NF==1{print ++$NF}; + NF>1{if(length($NF+1)>length($NF))$(NF-1)++; $NF=sprintf(\"%0*d\", length($NF), + ($NF+1)%(10^length($NF))); print}'" register: quay_increment_release_result when: - quay_release_result is defined @@ -139,7 +144,9 @@ when: csv_describe_result.stdout != "" - name: "Get the pod status of the deployed operator" - shell: "{{ oc_bin_path }} get --output=name pods | grep {{ operator_pod_name }} | cut -f1 | xargs -I{} {{ oc_bin_path }} get {} -o yaml | {{ yq_bin_path }} r - \"status\"" + shell: > + "{{ oc_bin_path }} get --output=name pods | grep {{ operator_pod_name }} | cut -f1 + | xargs -I{} {{ oc_bin_path }} get {} -o yaml | {{ yq_bin_path }} r - \"status\"" register: operator_pod_result ignore_errors: true environment: @@ -156,7 +163,9 @@ - operator_pod_result.stdout != "" - name: "Get the pod container logs of the deployed operator" - shell: "{{ oc_bin_path }} get --output=name pods | grep {{ operator_pod_name }} | cut -d' ' -f1 | xargs -I{} {{ oc_bin_path }} logs {} -c {{ operator_container_name }}" + shell: > + "{{ oc_bin_path }} get --output=name pods | grep {{ operator_pod_name }} + | cut -d' ' -f1 | xargs -I{} {{ oc_bin_path }} logs {} -c {{ operator_container_name }}" register: operator_container_result ignore_errors: true environment: @@ -173,7 +182,10 @@ - operator_container_result.stdout != "" - name: "Get the catalogsource pod log" - shell: "{{ oc_bin_path }} get --output=name pods -n openshift-marketplace | grep test-operators | cut -d' ' -f1 | xargs -I{} {{ oc_bin_path }} logs {} -n openshift-marketplace" + shell: > + "{{ oc_bin_path }} get --output=name pods -n openshift-marketplace + | grep test-operators | cut -d' ' -f1 | xargs -I{} {{ oc_bin_path }} + logs {} -n openshift-marketplace" register: catalog_source_result environment: KUBECONFIG: "{{ kubeconfig_path }}" @@ -186,7 +198,10 @@ when: catalog_source_result.stdout is defined - name: "Get the catalog-operator pod log" - shell: "{{ oc_bin_path }} get --output=name pods -n openshift-operator-lifecycle-manager | grep catalog-operator | cut -d' ' -f1 | xargs -I{} {{ oc_bin_path }} logs {} -n openshift-operator-lifecycle-manager | tail -n 100" + shell: > + "{{ oc_bin_path }} get --output=name pods -n openshift-operator-lifecycle-manager + | grep catalog-operator | cut -d' ' -f1 | xargs -I{} {{ oc_bin_path }} logs {} + -n openshift-operator-lifecycle-manager | tail -n 100" register: catalog_operator_result environment: KUBECONFIG: "{{ kubeconfig_path }}" @@ -216,7 +231,10 @@ deploy_olm_operator_results: {'result': 'pass', 'msg': ''} - name: "Get replicaset logs for operators that failed olm-deployment output" - shell: "{{ oc_bin_path }} get replicasets -o go-template={%raw%}'{{range .items}}{{.status.conditions}}{{\"\\n\"}}{{end}}'{%endraw%} -n {{ openshift_namespace }}" + shell: > + "{{ oc_bin_path }} get replicasets -o + go-template={%raw%}'{{range .items}}{{.status.conditions}}{{\"\\n\"}}{{end}}'{%endraw%} + -n {{ openshift_namespace }}" register: olm_replicaset_output environment: KUBECONFIG: "{{ kubeconfig_path }}" @@ -260,7 +278,7 @@ - name: "Set failure result" set_fact: - deploy_olm_operator_results: {'result': 'fail', 'name': "{{ ansible_failed_task.name }}", 'msg': "{{ ansible_failed_result }}" } + deploy_olm_operator_results: {'result': 'fail', 'name': "{{ ansible_failed_task.name }}", 'msg': "{{ ansible_failed_result }}"} - name: "Failed on deploy_olm_operator_results" fail: diff --git a/roles/deploy_olm_operator_upstream/defaults/main.yml b/roles/deploy_olm_operator_upstream/defaults/main.yml index eb54b63c2..7d756701f 100644 --- a/roles/deploy_olm_operator_upstream/defaults/main.yml +++ b/roles/deploy_olm_operator_upstream/defaults/main.yml @@ -3,4 +3,4 @@ openshift_namespace: test-operator current_channel: alpha operator_work_dir: /home/jenkins/agent/test-operator quay_release: 0.0.1 -kubeconfig_path: "{{ ansible_env.HOME }}/.kube/config" \ No newline at end of file +kubeconfig_path: "{{ ansible_env.HOME }}/.kube/config" diff --git a/roles/deploy_olm_operator_upstream/tasks/main.yml b/roles/deploy_olm_operator_upstream/tasks/main.yml index c013f6523..333034803 100644 --- a/roles/deploy_olm_operator_upstream/tasks/main.yml +++ b/roles/deploy_olm_operator_upstream/tasks/main.yml @@ -26,57 +26,58 @@ - name: "Openshift only" block: - - name: "Check for the existence of earlier releases of the operator on the quay.io app repository" - shell: "curl -s -H \"Authorization: basic {{ quay_token }}\" https://quay.io/cnr/api/v1/packages/{{ quay_namespace }}/{{ package_name }}-test | {{ jq_bin_path }} '.[].release' | sort --version-sort | tail -n 1" - register: quay_release_result - no_log: true - - - name: "Increment testing quay app release if exists" - shell: "echo {{ quay_release_result.stdout }} | awk -F. -v OFS=. 'NF==1{print ++$NF}; NF>1{if(length($NF+1)>length($NF))$(NF-1)++; $NF=sprintf(\"%0*d\", length($NF), ($NF+1)%(10^length($NF))); print}'" - register: quay_increment_release_result - when: - - quay_release_result is defined - - quay_release_result.stdout is defined - - quay_release_result.stdout != "" - - quay_release_result.stdout != "null" - - - name: "Set quay release to the incremented one if exists" - set_fact: - quay_release: "{{ quay_increment_release_result.stdout }}" - when: - - quay_increment_release_result is defined - - quay_increment_release_result.stdout is defined - - quay_increment_release_result.stdout != "" - - - name: "Append the -test suffix to the packageName" - shell: "{{ yq_bin_path }} w -i {{ package_path }} 'packageName' '{{ package_name }}-test'" - - - name: "Push the operator metadata to the private quay.io repository" - shell: "operator-courier push {{ operator_work_dir }} {{ quay_namespace }} {{ package_name }}-test {{ quay_release }} \"basic {{ quay_token }}\"" - no_log: true - - - name: "Create {{ openshift_namespace }} project" - shell: "{{ oc_bin_path }} new-project {{ openshift_namespace }}" - register: openshift_namespace_result - environment: - KUBECONFIG: "{{ kubeconfig_path }}" - - - name: "Inject kube_objects on OpenShift cluster for Operator certification" - block: - - name: "Inject openshift kube_objects" - include_role: - name: inject_openshift_kube_objects - environment: - KUBECONFIG: "{{ kubeconfig_path }}" - when: - - kube_objects is defined - - kube_objects != "N/A" - - kube_objects != "null" + - name: "Check for the existence of earlier releases of the operator on the quay.io app repository" + shell: > + "curl -s -H \"Authorization: basic {{ quay_token }}\" https://quay.io/cnr/api/v1/packages/{{ + quay_namespace }}/{{ package_name }}-test | {{ jq_bin_path }} '.[].release' | sort --version-sort | tail -n 1" + register: quay_release_result + no_log: true + + - name: "Increment testing quay app release if exists" + shell: > + "echo {{ quay_release_result.stdout }} | awk -F. -v OFS=. 'NF==1{print ++$NF}; + NF>1{if(length($NF+1)>length($NF))$(NF-1)++; $NF=sprintf(\"%0*d\", length($NF), ($NF+1)%(10^length($NF))); print}'" + register: quay_increment_release_result + when: + - quay_release_result is defined + - quay_release_result.stdout is defined + - quay_release_result.stdout != "" + - quay_release_result.stdout != "null" + + - name: "Set quay release to the incremented one if exists" + set_fact: + quay_release: "{{ quay_increment_release_result.stdout }}" + when: + - quay_increment_release_result is defined + - quay_increment_release_result.stdout is defined + - quay_increment_release_result.stdout != "" + + - name: "Append the -test suffix to the packageName" + shell: "{{ yq_bin_path }} w -i {{ package_path }} 'packageName' '{{ package_name }}-test'" + + - name: "Push the operator metadata to the private quay.io repository" + shell: "operator-courier push {{ operator_work_dir }} {{ quay_namespace }} {{ package_name }}-test {{ quay_release }} \"basic {{ quay_token }}\"" + no_log: true + + - name: "Create {{ openshift_namespace }} project" + shell: "{{ oc_bin_path }} new-project {{ openshift_namespace }}" + register: openshift_namespace_result + environment: + KUBECONFIG: "{{ kubeconfig_path }}" + - name: "Inject kube_objects on OpenShift cluster for Operator certification" + block: + - name: "Inject openshift kube_objects" + include_role: + name: inject_openshift_kube_objects + environment: + KUBECONFIG: "{{ kubeconfig_path }}" + when: + - kube_objects is defined + - kube_objects != "N/A" + - kube_objects != "null" when: not run_upstream|bool - - - name: "Create the olm operator files directory" file: path: "{{ olm_operator_files_path }}" @@ -194,7 +195,9 @@ KUBECONFIG: "{{ kubeconfig_path }}" - name: "Wait for the operator {{ operator_pod_name }} pod to stay healthy for specific time (upstream only)" - shell: "[ $(echo `{{ oc_bin_path }} get pods {{ upstream_namespace_param }}| grep {{ operator_pod_name }} | grep Running| rev | cut -d' ' -f 1 | rev|sed 's/.$//'`) -ge 60 ]" + shell: > + "[ $(echo `{{ oc_bin_path }} get pods {{ upstream_namespace_param }}| grep + {{ operator_pod_name }} | grep Running| rev | cut -d' ' -f 1 | rev|sed 's/.$//'`) -ge 60 ]" register: operator_uptime retries: 15 delay: 5 @@ -219,7 +222,10 @@ when: csv_describe_result.stdout != "" - name: "Get the pod status of the deployed operator" - shell: "{{ oc_bin_path }} get --output=name pods {{ upstream_namespace_param }}| grep {{ operator_pod_name }} | cut -f1 | xargs -I{} {{ oc_bin_path }} get {} {{ upstream_namespace_param }} -o yaml | {{ yq_bin_path }} r - \"status\"" + shell: > + "{{ oc_bin_path }} get --output=name pods {{ upstream_namespace_param }}| grep + {{ operator_pod_name }} | cut -f1 | xargs -I{} {{ oc_bin_path }} get {} {{ upstream_namespace_param + }} -o yaml | {{ yq_bin_path }} r - \"status\"" register: operator_pod_result ignore_errors: true environment: @@ -236,7 +242,10 @@ - operator_pod_result.stdout != "" - name: "Get the pod container logs of the deployed operator" - shell: "{{ oc_bin_path }} get --output=name pods {{ upstream_namespace_param }}| grep {{ operator_pod_name }} | cut -d' ' -f1 | xargs -I{} {{ oc_bin_path }} logs {} -c {{ operator_container_name }} {{ upstream_namespace_param }}" + shell: > + "{{ oc_bin_path }} get --output=name pods {{ upstream_namespace_param }}| grep {{ + operator_pod_name }} | cut -d' ' -f1 | xargs -I{} {{ oc_bin_path }} logs {} -c {{ + operator_container_name }} {{ upstream_namespace_param }}" register: operator_container_result ignore_errors: true environment: @@ -253,14 +262,18 @@ - operator_container_result.stdout != "" - name: "Get the catalogsource pod log" - shell: "{{ oc_bin_path }} get --output=name pods -n openshift-marketplace | grep test-operators | cut -d' ' -f1 | xargs -I{} {{ oc_bin_path }} logs {} -n openshift-marketplace" + shell: > + "{{ oc_bin_path }} get --output=name pods -n openshift-marketplace | grep test-operators | + cut -d' ' -f1 | xargs -I{} {{ oc_bin_path }} logs {} -n openshift-marketplace" register: catalog_source_result environment: KUBECONFIG: "{{ kubeconfig_path }}" when: not run_upstream|bool - name: "Get the catalogsource pod log (upstream)" - shell: "{{ oc_bin_path }} get --output=name pods {{ upstream_namespace_param }} | grep test-operators-ocs | cut -d' ' -f1 | xargs -I{} {{ oc_bin_path }} logs {} {{ upstream_namespace_param }}" + shell: > + "{{ oc_bin_path }} get --output=name pods {{ upstream_namespace_param }} | grep test-operators-ocs + | cut -d' ' -f1 | xargs -I{} {{ oc_bin_path }} logs {} {{ upstream_namespace_param }}" register: catalog_source_result environment: KUBECONFIG: "{{ kubeconfig_path }}" @@ -274,7 +287,10 @@ when: catalog_source_result.stdout is defined - name: "Get the catalog-operator pod log" - shell: "{{ oc_bin_path }} get --output=name pods -n openshift-operator-lifecycle-manager | grep catalog-operator | cut -d' ' -f1 | xargs -I{} {{ oc_bin_path }} logs {} -n openshift-operator-lifecycle-manager | tail -n 100" + shell: > + "{{ oc_bin_path }} get --output=name pods -n openshift-operator-lifecycle-manager + | grep catalog-operator | cut -d' ' -f1 | xargs -I{} {{ oc_bin_path }} logs {} -n + openshift-operator-lifecycle-manager | tail -n 100" register: catalog_operator_result environment: KUBECONFIG: "{{ kubeconfig_path }}" @@ -324,4 +340,3 @@ when: - run_upstream|bool - operator_uptime.rc != 0 - diff --git a/roles/deploy_olm_operator_upstream_bundle/defaults/main.yml b/roles/deploy_olm_operator_upstream_bundle/defaults/main.yml index eb54b63c2..7d756701f 100644 --- a/roles/deploy_olm_operator_upstream_bundle/defaults/main.yml +++ b/roles/deploy_olm_operator_upstream_bundle/defaults/main.yml @@ -3,4 +3,4 @@ openshift_namespace: test-operator current_channel: alpha operator_work_dir: /home/jenkins/agent/test-operator quay_release: 0.0.1 -kubeconfig_path: "{{ ansible_env.HOME }}/.kube/config" \ No newline at end of file +kubeconfig_path: "{{ ansible_env.HOME }}/.kube/config" diff --git a/roles/deploy_olm_operator_upstream_bundle/tasks/main.yml b/roles/deploy_olm_operator_upstream_bundle/tasks/main.yml index 028338e6d..b7d0fc322 100644 --- a/roles/deploy_olm_operator_upstream_bundle/tasks/main.yml +++ b/roles/deploy_olm_operator_upstream_bundle/tasks/main.yml @@ -89,7 +89,9 @@ KUBECONFIG: "{{ kubeconfig_path }}" - name: "Wait for the operator {{ operator_pod_name }} pod to stay healthy for specific time (upstream only)" - shell: "[ $(echo `{{ oc_bin_path }} get pods {{ upstream_namespace_param }}| grep {{ operator_pod_name }} | grep Running| rev | cut -d' ' -f 1 | rev|sed 's/.$//'`) -ge 60 ]" + shell: > + "[ $(echo `{{ oc_bin_path }} get pods {{ upstream_namespace_param }}| grep {{ operator_pod_name }} | + grep Running| rev | cut -d' ' -f 1 | rev|sed 's/.$//'`) -ge 60 ]" register: operator_uptime retries: 15 delay: 5 @@ -113,7 +115,9 @@ when: csv_describe_result.stdout != "" - name: "Get the pod status of the deployed operator" - shell: "{{ oc_bin_path }} get --output=name pods {{ upstream_namespace_param }}| grep {{ operator_pod_name }} | cut -f1 | xargs -I{} {{ oc_bin_path }} get {} {{ upstream_namespace_param }} -o yaml | {{ yq_bin_path }} r - \"status\"" + shell: > + "{{ oc_bin_path }} get --output=name pods {{ upstream_namespace_param }}| grep {{ operator_pod_name }} | + cut -f1 | xargs -I{} {{ oc_bin_path }} get {} {{ upstream_namespace_param }} -o yaml | {{ yq_bin_path }} r - \"status\"" register: operator_pod_result ignore_errors: true environment: @@ -130,7 +134,9 @@ - operator_pod_result.stdout != "" - name: "Get the pod container logs of the deployed operator" - shell: "{{ oc_bin_path }} get --output=name pods {{ upstream_namespace_param }}| grep {{ operator_pod_name }} | cut -d' ' -f1 | xargs -I{} {{ oc_bin_path }} logs {} -c {{ operator_container_name }} {{ upstream_namespace_param }}" + shell: > + "{{ oc_bin_path }} get --output=name pods {{ upstream_namespace_param }}| grep {{ operator_pod_name }} | + cut -d' ' -f1 | xargs -I{} {{ oc_bin_path }} logs {} -c {{ operator_container_name }} {{ upstream_namespace_param }}" register: operator_container_result ignore_errors: true environment: @@ -147,7 +153,9 @@ - operator_container_result.stdout != "" - name: "Get the catalogsource pod log (upstream)" - shell: "{{ oc_bin_path }} get --output=name pods {{ upstream_namespace_param }} | grep test-operators-ocs | cut -d' ' -f1 | xargs -I{} {{ oc_bin_path }} logs {} {{ upstream_namespace_param }}" + shell: > + "{{ oc_bin_path }} get --output=name pods {{ upstream_namespace_param }} | grep test-operators-ocs + | cut -d' ' -f1 | xargs -I{} {{ oc_bin_path }} logs {} {{ upstream_namespace_param }}" register: catalog_source_result environment: KUBECONFIG: "{{ kubeconfig_path }}" @@ -210,4 +218,4 @@ msg: 'Operator was not capable to stay healthy for a specific time' when: - operator_uptime.rc != 0 - - run_upstream|bool \ No newline at end of file + - run_upstream|bool diff --git a/roles/detect_format/defaults/main.yml b/roles/detect_format/defaults/main.yml index 4d70f3110..695a0cb9f 100644 --- a/roles/detect_format/defaults/main.yml +++ b/roles/detect_format/defaults/main.yml @@ -1,5 +1,3 @@ operator_local_registry: "localhost:5000" -bundle_input_tmp_dir: "{{ work_dir }}/operator-bundle-input/tmp" -bundle_input_src_dir: "{{ work_dir }}/operator-bundle-input/src" - - +bundle_input_tmp_dir: "{{ work_dir }}/operator-bundle-input/tmp" +bundle_input_src_dir: "{{ work_dir }}/operator-bundle-input/src" diff --git a/roles/detect_format/tasks/main.yml b/roles/detect_format/tasks/main.yml index 83e36c13e..35bc14ca6 100644 --- a/roles/detect_format/tasks/main.yml +++ b/roles/detect_format/tasks/main.yml @@ -25,11 +25,11 @@ - name: Operator version block: - - name: "Check operator version" - shell: "cd {{ operator_dir }}; ls -d */| sort --version-sort | tail -n 1|sed s/.$//" - register: operator_version_raw - - set_fact: - operator_version: "{{ operator_version_raw.stdout }}" + - name: "Check operator version" + shell: "cd {{ operator_dir }}; ls -d */| sort --version-sort | tail -n 1|sed s/.$//" + register: operator_version_raw + - set_fact: + operator_version: "{{ operator_version_raw.stdout }}" when: operator_version is undefined - name: "Export CSV variables" diff --git a/roles/export_csv/defaults/main.yml b/roles/export_csv/defaults/main.yml index 79c93e475..bf4be710a 100644 --- a/roles/export_csv/defaults/main.yml +++ b/roles/export_csv/defaults/main.yml @@ -1,2 +1,2 @@ op_dir: "dummy" -op_ver: "dummy" \ No newline at end of file +op_ver: "dummy" diff --git a/roles/export_csv/tasks/main.yml b/roles/export_csv/tasks/main.yml index f87928d46..e9edfb414 100644 --- a/roles/export_csv/tasks/main.yml +++ b/roles/export_csv/tasks/main.yml @@ -4,7 +4,7 @@ - name: "Searching for file cvs file (bundle)" find: paths: "{{ op_csv_dir }}/manifests/" - recurse: no + recurse: false file_type: file patterns: '*.clusterserviceversion.yaml' register: csv_find_bundle @@ -24,7 +24,7 @@ - name: "Searching for file cvs file (manifest)" find: paths: "{{ op_csv_dir }}" - recurse: no + recurse: false file_type: file patterns: '*.clusterserviceversion.yaml' register: csv_find_manifest @@ -37,19 +37,19 @@ - name: "Include the package path into the operator_vars (upstream only)" block: - - name: "Check if package file exists" - stat: - path: "{{ csv_file_path }}" - register: csv_file_st - - name: "Fail if package file doesn't exists" - fail: - when: not csv_file_st.stat.exists - - name: "Getting content of package file" - shell: "cat {{ csv_file_path }}" - register: csv_data - - name: Set facts - set_fact: - operator_vars_tmp: "{{ csv_data.stdout | from_yaml }}" - - name: Set facts - set_fact: - operator_vars: "{{ operator_vars_tmp | from_yaml }}" \ No newline at end of file + - name: "Check if package file exists" + stat: + path: "{{ csv_file_path }}" + register: csv_file_st + - name: "Fail if package file doesn't exists" + fail: + when: not csv_file_st.stat.exists + - name: "Getting content of package file" + shell: "cat {{ csv_file_path }}" + register: csv_data + - name: Set facts + set_fact: + operator_vars_tmp: "{{ csv_data.stdout | from_yaml }}" + - name: Set facts + set_fact: + operator_vars: "{{ operator_vars_tmp | from_yaml }}" diff --git a/roles/extract_operator_bundle/defaults/main.yml b/roles/extract_operator_bundle/defaults/main.yml index 1b952e08e..e99d61310 100644 --- a/roles/extract_operator_bundle/defaults/main.yml +++ b/roles/extract_operator_bundle/defaults/main.yml @@ -4,4 +4,4 @@ skopeo_bin_path: skopeo image_protocol: "docker://" umoci_bin_path: umoci operator_work_dir: /home/jenkins/agent/test-operator -operator_bundle_dir: /home/jenkins/agent/operator-bundle \ No newline at end of file +operator_bundle_dir: /home/jenkins/agent/operator-bundle diff --git a/roles/final_cleanup_upstream/defaults/main.yml b/roles/final_cleanup_upstream/defaults/main.yml index d947bb072..241fb932b 100644 --- a/roles/final_cleanup_upstream/defaults/main.yml +++ b/roles/final_cleanup_upstream/defaults/main.yml @@ -1,4 +1,4 @@ oc_bin_path: "{{ 'kubectl' if run_upstream else 'oc' }}" openshift_namespace: test-operator current_channel: alpha -kubeconfig_path: "{{ ansible_env.HOME }}/.kube/config" \ No newline at end of file +kubeconfig_path: "{{ ansible_env.HOME }}/.kube/config" diff --git a/roles/final_cleanup_upstream/tasks/main.yml b/roles/final_cleanup_upstream/tasks/main.yml index a17d02deb..98d8b1a5e 100644 --- a/roles/final_cleanup_upstream/tasks/main.yml +++ b/roles/final_cleanup_upstream/tasks/main.yml @@ -1,2 +1,2 @@ - name: "Delete namespace" - shell: "{{ oc_bin_path }} delete -f {{ olm_operator_files_path }}/namespace.yml" \ No newline at end of file + shell: "{{ oc_bin_path }} delete -f {{ olm_operator_files_path }}/namespace.yml" diff --git a/roles/inject_openshift_kube_objects/defaults/main.yml b/roles/inject_openshift_kube_objects/defaults/main.yml index 696a465e9..98070d936 100644 --- a/roles/inject_openshift_kube_objects/defaults/main.yml +++ b/roles/inject_openshift_kube_objects/defaults/main.yml @@ -3,4 +3,4 @@ kube_objects_dir: "/home/jenkins/agent/kube_objects" # Assumed that real values will be passed in for these: kube_objects: kube_objects kubeconfig_path: "$WORKSPACE/operators/ocp-cluster-deployment/${clusterName}/auth/kubeconfig" -openshift_namespace: default \ No newline at end of file +openshift_namespace: default diff --git a/roles/inject_openshift_kube_objects/tasks/main.yml b/roles/inject_openshift_kube_objects/tasks/main.yml index e808a4cae..aba799f9e 100644 --- a/roles/inject_openshift_kube_objects/tasks/main.yml +++ b/roles/inject_openshift_kube_objects/tasks/main.yml @@ -33,5 +33,5 @@ register: kube_objects_directory_removed - debug: - msg: "The kube_objects directory has been removed successfully" + msg: "The kube_objects directory has been removed successfully" when: kube_objects_directory_removed.rc == 0 diff --git a/roles/inject_scorecard_metadata/defaults/main.yml b/roles/inject_scorecard_metadata/defaults/main.yml index bd06ebd4b..25299436a 100644 --- a/roles/inject_scorecard_metadata/defaults/main.yml +++ b/roles/inject_scorecard_metadata/defaults/main.yml @@ -1,4 +1,4 @@ --- sc_proxy_image: quay.io/operator-framework/scorecard-proxy:master operator_work_dir: /tmp/cvp/operator-files -openshift_namespace: test-operator \ No newline at end of file +openshift_namespace: test-operator diff --git a/roles/inject_scorecard_metadata/tasks/main.yml b/roles/inject_scorecard_metadata/tasks/main.yml index 9f52276ed..5fb28b56e 100644 --- a/roles/inject_scorecard_metadata/tasks/main.yml +++ b/roles/inject_scorecard_metadata/tasks/main.yml @@ -68,11 +68,13 @@ set_fact: csv_vars_spec_crds_owned: "{{ csv_vars_spec_crds['owned'] | default([]) }}" - # RUNS the following block only when csv_vars_spec_crds_owned is not empty +# RUNS the following block only when csv_vars_spec_crds_owned is not empty - name: "Extract CR only when the CRs defined" block: - name: "Extract only the first CR from alm-examples in the CSV" - shell: "{{ yq_bin_path }} r {{ csv_path }} \"metadata.annotations.alm-examples\" | {{ jq_bin_path }} -c .[0] | {{ yq_bin_path }} w - \"metadata.namespace\" \"{{ openshift_namespace }}\" > {{ scorecard_cr_dir }}/first.cr.yaml" + shell: > + "{{ yq_bin_path }} r {{ csv_path }} \"metadata.annotations.alm-examples\" | {{ jq_bin_path }} -c .[0] | + {{ yq_bin_path }} w - \"metadata.namespace\" \"{{ openshift_namespace }}\" > {{ scorecard_cr_dir }}/first.cr.yaml" when: scorecard_first_cr|bool - name: "Extract all CRs from alm-examples in the CSV" diff --git a/roles/install_base_packages/tasks/main.yml b/roles/install_base_packages/tasks/main.yml index a5b0ca8fc..1ced0a9fa 100644 --- a/roles/install_base_packages/tasks/main.yml +++ b/roles/install_base_packages/tasks/main.yml @@ -8,8 +8,8 @@ - python3-pip - python3-setuptools state: latest - update_cache: yes - become: yes + update_cache: true + become: true tags: - install - host_build @@ -23,12 +23,12 @@ - software-properties-common - virtualenv state: latest - update_cache: yes + update_cache: true - name: Install python modules pip: name: - docker - become: yes + become: true when: ansible_distribution == 'Debian' or ansible_distribution == 'Ubuntu' tags: - install @@ -41,10 +41,10 @@ - python3-virtualenv - python3-dockerpty state: latest - update_cache: yes - become: yes + update_cache: true + become: true when: ansible_distribution == 'CentOS' or ansible_distribution == 'Red Hat Enterprise Linux' tags: - - install - - host_build - - image_build \ No newline at end of file + - install + - host_build + - image_build diff --git a/roles/install_docker/defaults/main.yml b/roles/install_docker/defaults/main.yml index 034a6bf7a..7453f7ee4 100644 --- a/roles/install_docker/defaults/main.yml +++ b/roles/install_docker/defaults/main.yml @@ -1,2 +1,2 @@ docker_group: "docker" -docker_user: "{{ ansible_user_id }}" \ No newline at end of file +docker_user: "{{ ansible_user_id }}" diff --git a/roles/install_docker/tasks/main.yml b/roles/install_docker/tasks/main.yml index 4d1b53b42..3c8a5db51 100644 --- a/roles/install_docker/tasks/main.yml +++ b/roles/install_docker/tasks/main.yml @@ -15,7 +15,7 @@ - name: "Update apt and install docker-ce" apt: update_cache=yes name=docker-ce state=latest - become: yes + become: true when: ansible_distribution == 'Debian' or ansible_distribution == 'Ubuntu' tags: - install @@ -32,7 +32,7 @@ yum: name: docker-ce state: latest - become: yes + become: true when: ansible_distribution == 'CentOS' or ansible_distribution == 'Red Hat Enterprise Linux' tags: - install @@ -42,7 +42,7 @@ group: name: "{{ docker_group }}" state: present - become: yes + become: true tags: - install - host_build @@ -51,8 +51,8 @@ user: name: "{{ docker_user }}" groups: docker - append: yes - become: yes + append: true + become: true tags: - install - host_build @@ -67,10 +67,7 @@ service: name: docker state: started - become: yes + become: true tags: - install - host_build - - - diff --git a/roles/install_kind/defaults/main.yml b/roles/install_kind/defaults/main.yml index 34fe0a55f..764c17c62 100644 --- a/roles/install_kind/defaults/main.yml +++ b/roles/install_kind/defaults/main.yml @@ -1,7 +1,7 @@ kind_version: v0.8.1 -#kind_kube_ver: v1.17.0 +# kind_kube_ver: v1.17.0 kind_kube_ver: v1.18.2 kind_bin_path: "/usr/local/bin/kind" # KIND_bin_path: "{{ testing_bin_path }}/kind" kind_cluster_name: operator-test -kind_tmp_dir: /tmp \ No newline at end of file +kind_tmp_dir: /tmp diff --git a/roles/install_kind/tasks/main.yml b/roles/install_kind/tasks/main.yml index 38657d475..7653abde2 100644 --- a/roles/install_kind/tasks/main.yml +++ b/roles/install_kind/tasks/main.yml @@ -18,7 +18,7 @@ # - check if registry exists - name: "Destroy current registry" shell: "docker rm -f kind-registry" - ignore_errors: yes + ignore_errors: true tags: - never - reset @@ -29,7 +29,7 @@ file: path: "{{ kind_bin_path }}" state: absent - become: yes + become: true tags: - never - uninstall @@ -46,7 +46,7 @@ url: "https://github.com/kubernetes-sigs/kind/releases/download/{{ kind_version }}/kind-linux-amd64" dest: "{{ kind_bin_path }}" mode: '0755' - become: yes + become: true when: rc_kind.stat.exists == false tags: - install diff --git a/roles/install_kubectl/defaults/main.yml b/roles/install_kubectl/defaults/main.yml index bf793dc6c..ab49bc5e6 100644 --- a/roles/install_kubectl/defaults/main.yml +++ b/roles/install_kubectl/defaults/main.yml @@ -1 +1 @@ -kubectl_version_tmp_dir: /tmp \ No newline at end of file +kubectl_version_tmp_dir: /tmp diff --git a/roles/install_kubectl/tasks/main.yml b/roles/install_kubectl/tasks/main.yml index 4326eacc9..1a6e98738 100644 --- a/roles/install_kubectl/tasks/main.yml +++ b/roles/install_kubectl/tasks/main.yml @@ -1,33 +1,32 @@ --- - - name: "Uninstall kubectl binary" - file: - path: /usr/local/bin/kubectl - state: absent - become: yes - tags: - - uninstall - - - name: "Install kubectl" - block: - - name: "Remove kubectl Version file" - file: - path: "{{ kubectl_version_tmp_dir }}/kubectl_version" - state: absent - - name: "Get kubectl Version from url" - get_url: - url: "https://storage.googleapis.com/kubernetes-release/release/stable.txt" - dest: "{{ kubectl_version_tmp_dir }}/kubectl_version" - - name: "Read kubectl Version from url" - command: cat {{ kubectl_version_tmp_dir }}/kubectl_version - register: kubectl_version - - name: "Install kubectl" - get_url: - url: https://storage.googleapis.com/kubernetes-release/release/{{ kubectl_version.stdout }}/bin/linux/amd64/kubectl - dest: /usr/local/bin/kubectl - mode: '0755' - become: yes - tags: - - install - - image_build - - host_build +- name: "Uninstall kubectl binary" + file: + path: /usr/local/bin/kubectl + state: absent + become: true + tags: + - uninstall +- name: "Install kubectl" + block: + - name: "Remove kubectl Version file" + file: + path: "{{ kubectl_version_tmp_dir }}/kubectl_version" + state: absent + - name: "Get kubectl Version from url" + get_url: + url: "https://storage.googleapis.com/kubernetes-release/release/stable.txt" + dest: "{{ kubectl_version_tmp_dir }}/kubectl_version" + - name: "Read kubectl Version from url" + command: cat {{ kubectl_version_tmp_dir }}/kubectl_version + register: kubectl_version + - name: "Install kubectl" + get_url: + url: https://storage.googleapis.com/kubernetes-release/release/{{ kubectl_version.stdout }}/bin/linux/amd64/kubectl + dest: /usr/local/bin/kubectl + mode: '0755' + become: true + tags: + - install + - image_build + - host_build diff --git a/roles/install_operator_prereqs/tasks/main.yml b/roles/install_operator_prereqs/tasks/main.yml index 46ab8d4f3..b5caa9f72 100644 --- a/roles/install_operator_prereqs/tasks/main.yml +++ b/roles/install_operator_prereqs/tasks/main.yml @@ -23,7 +23,7 @@ unarchive: src: "https://mirror.openshift.com/pub/openshift-v4/clients/ocp/{{ oc_version }}/openshift-client-linux-{{ oc_version }}.tar.gz" dest: "{{ testing_bin_path }}" - remote_src: yes + remote_src: true when: not run_upstream|bool tags: - install @@ -33,7 +33,7 @@ unarchive: src: "https://storage.googleapis.com/golang/go{{ go_version }}.linux-amd64.tar.gz" dest: "{{ testing_bin_path }}" - remote_src: yes + remote_src: true tags: - install - image_build diff --git a/roles/operator_bundle_scorecard_tests/files/scorecard-basic-config.yml b/roles/operator_bundle_scorecard_tests/files/scorecard-basic-config.yml index 961d845d0..d5a70cd95 100644 --- a/roles/operator_bundle_scorecard_tests/files/scorecard-basic-config.yml +++ b/roles/operator_bundle_scorecard_tests/files/scorecard-basic-config.yml @@ -5,19 +5,19 @@ apiversion: scorecard.operatorframework.io/v1alpha3 metadata: name: config stages: -- parallel: true - tests: - - image: quay.io/operator-framework/scorecard-test:latest - entrypoint: - - scorecard-test - - basic-check-spec - labels: - suite: basic - test: basic-check-spec-test - - image: quay.io/operator-framework/scorecard-test:latest - entrypoint: - - scorecard-test - - olm-bundle-validation - labels: - suite: olm - test: olm-bundle-validation-test + - parallel: true + tests: + - image: quay.io/operator-framework/scorecard-test:latest + entrypoint: + - scorecard-test + - basic-check-spec + labels: + suite: basic + test: basic-check-spec-test + - image: quay.io/operator-framework/scorecard-test:latest + entrypoint: + - scorecard-test + - olm-bundle-validation + labels: + suite: olm + test: olm-bundle-validation-test diff --git a/roles/operator_bundle_scorecard_tests/tasks/main.yml b/roles/operator_bundle_scorecard_tests/tasks/main.yml index f451f05f5..14eda8463 100644 --- a/roles/operator_bundle_scorecard_tests/tasks/main.yml +++ b/roles/operator_bundle_scorecard_tests/tasks/main.yml @@ -21,8 +21,8 @@ msg: "{{ shell_script_output.stdout_lines }}" always: - - name: "Store the result in a text file" - copy: - dest: "{{ ARTIFACT_DIR }}/operator_bundle_scorecard_tests.txt" - content: "{{ shell_script_output }}" - mode: 0644 + - name: "Store the result in a text file" + copy: + dest: "{{ ARTIFACT_DIR }}/operator_bundle_scorecard_tests.txt" + content: "{{ shell_script_output }}" + mode: 0644 diff --git a/roles/operator_catalog_initialization_test/defaults/main.yml b/roles/operator_catalog_initialization_test/defaults/main.yml index aba513bfd..4099fe587 100644 --- a/roles/operator_catalog_initialization_test/defaults/main.yml +++ b/roles/operator_catalog_initialization_test/defaults/main.yml @@ -4,4 +4,3 @@ operator_registry_branch: "release-4.3" check_initializer_result: true oc_bin_path: oc run_cleanup: true - diff --git a/roles/operator_courier_verify/defaults/main.yml b/roles/operator_courier_verify/defaults/main.yml index 8e4c0c887..c2029255a 100644 --- a/roles/operator_courier_verify/defaults/main.yml +++ b/roles/operator_courier_verify/defaults/main.yml @@ -1,2 +1,2 @@ operator_work_dir: /tmp/cvp/operator-files -check_verify_result: true \ No newline at end of file +check_verify_result: true diff --git a/roles/operator_courier_verify/tasks/main.yml b/roles/operator_courier_verify/tasks/main.yml index dfe9a8031..53fb03ffa 100644 --- a/roles/operator_courier_verify/tasks/main.yml +++ b/roles/operator_courier_verify/tasks/main.yml @@ -14,7 +14,9 @@ when: courier_version_result.stdout is defined - name: "Verify the operator metadata with operator-courier" - shell: "operator-courier verify {{ operator_work_dir }} --ui_validate_io --validation-output {{ work_dir}}/linting-results.json > {{ work_dir}}/linting-output.txt 2> {{ work_dir}}/linting-errors.txt" + shell: > + "operator-courier verify {{ operator_work_dir }} --ui_validate_io --validation-output + {{ work_dir}}/linting-results.json > {{ work_dir}}/linting-output.txt 2> {{ work_dir}}/linting-errors.txt" register: courier_verify_result ignore_errors: true diff --git a/roles/operator_scorecard_tests/defaults/main.yml b/roles/operator_scorecard_tests/defaults/main.yml index edc1e76ea..fe57beb37 100644 --- a/roles/operator_scorecard_tests/defaults/main.yml +++ b/roles/operator_scorecard_tests/defaults/main.yml @@ -5,4 +5,4 @@ current_csv_dir: /tmp/cvp/operator-files openshift_namespace: test-operator operator_sdk_bin_path: operator-sdk jq_bin_path: jq -check_scorecard_results: true \ No newline at end of file +check_scorecard_results: true diff --git a/roles/operator_scorecard_tests/tasks/main.yml b/roles/operator_scorecard_tests/tasks/main.yml index 82beda855..2811aa659 100644 --- a/roles/operator_scorecard_tests/tasks/main.yml +++ b/roles/operator_scorecard_tests/tasks/main.yml @@ -20,19 +20,23 @@ mode: 0644 - name: "Run operator-sdk scorecard tests on the deployed operator in json form" - shell: "{{ operator_sdk_bin_path }} scorecard --version=v1alpha2 --verbose --config {{ work_dir }}/osdk-scorecard.yml > {{ work_dir }}/{{ cr_kind }}-{{ cr_name }}-scorecard-results.json 2> {{ work_dir}}/{{ cr_name }}-scorecard-errors.txt" + shell: > + "{{ operator_sdk_bin_path }} scorecard --version=v1alpha2 --verbose --config {{ work_dir }}/osdk-scorecard.yml > + {{ work_dir }}/{{ cr_kind }}-{{ cr_name }}-scorecard-results.json 2> {{ work_dir}}/{{ cr_name }}-scorecard-errors.txt" environment: KUBECONFIG: "{{ kubeconfig_path }}" ignore_errors: true - name: "Parse json operator scorecard results" - shell: "cat {{ work_dir }}/{{ cr_kind }}-{{ cr_name }}-scorecard-results.json | {{ jq_bin_path }} '.results[] | select(.labels.suite == \"basic\") | select(.state == \"pass\").name' | wc -l" + shell: > + "cat {{ work_dir }}/{{ cr_kind }}-{{ cr_name }}-scorecard-results.json | {{ jq_bin_path }} '.results[] | + select(.labels.suite == \"basic\") | select(.state == \"pass\").name' | wc -l" register: scorecard_results_passed_result - debug: msg: "Scorecard Basic Tests passed: {{ scorecard_results_passed_result.stdout }}" - # The scorecard test may have already deleted the CR, so ignore any errors +# The scorecard test may have already deleted the CR, so ignore any errors - name: "Delete the operator CR" shell: "{{ oc_bin_path }} delete -f {{ cr_path }} --ignore-not-found=true --grace-period=60 --timeout=120s" environment: diff --git a/roles/optional-operators-subscribe/defaults/main.yml b/roles/optional_operators_subscribe/defaults/main.yml similarity index 76% rename from roles/optional-operators-subscribe/defaults/main.yml rename to roles/optional_operators_subscribe/defaults/main.yml index bd06ebd4b..25299436a 100644 --- a/roles/optional-operators-subscribe/defaults/main.yml +++ b/roles/optional_operators_subscribe/defaults/main.yml @@ -1,4 +1,4 @@ --- sc_proxy_image: quay.io/operator-framework/scorecard-proxy:master operator_work_dir: /tmp/cvp/operator-files -openshift_namespace: test-operator \ No newline at end of file +openshift_namespace: test-operator diff --git a/roles/optional-operators-subscribe/tasks/main.yml b/roles/optional_operators_subscribe/tasks/main.yml similarity index 70% rename from roles/optional-operators-subscribe/tasks/main.yml rename to roles/optional_operators_subscribe/tasks/main.yml index f0239d709..8318ab3ea 100644 --- a/roles/optional-operators-subscribe/tasks/main.yml +++ b/roles/optional_operators_subscribe/tasks/main.yml @@ -1,5 +1,5 @@ --- -- name: "Run optional-operators-subscribe" +- name: "Run optional_operators_subscribe" block: - name: "Set facts for the Operator groups" set_fact: @@ -38,26 +38,25 @@ set_fact: finished_json_contents: "{{ finished_json_contents | combine(new_item, recursive=true) }}" vars: - new_item: { 'passed': true } + new_item: {'passed': true} with_dict: "{{ finished_json_contents }}" when: shell_script_output.rc == 0 always: - - name: "Store the result of the shell script output to build-log.txt" - copy: - dest: "{{ ARTIFACT_DIR }}/build-log.txt" - content: "{{ shell_script_output.stdout }}" - mode: 0644 + - name: "Store the result of the shell script output to build-log.txt" + copy: + dest: "{{ ARTIFACT_DIR }}/build-log.txt" + content: "{{ shell_script_output.stdout }}" + mode: 0644 - - name: "Store the result in a JSON file" - copy: - dest: "{{ ARTIFACT_DIR }}/optional_operator_subscribe.json" - content: "{{ shell_script_output }}" - mode: 0644 - - - name: "Store the finished.json" - copy: - dest: "{{ ARTIFACT_DIR }}/finished.json" - content: "{{ finished_json_contents }}" - mode: 0644 + - name: "Store the result in a JSON file" + copy: + dest: "{{ ARTIFACT_DIR }}/optional_operator_subscribe.json" + content: "{{ shell_script_output }}" + mode: 0644 + - name: "Store the finished.json" + copy: + dest: "{{ ARTIFACT_DIR }}/finished.json" + content: "{{ finished_json_contents }}" + mode: 0644 diff --git a/roles/optional-operators-subscribe/templates/optional-operators-subscribe-commands.sh b/roles/optional_operators_subscribe/templates/optional-operators-subscribe-commands.sh similarity index 100% rename from roles/optional-operators-subscribe/templates/optional-operators-subscribe-commands.sh rename to roles/optional_operators_subscribe/templates/optional-operators-subscribe-commands.sh diff --git a/roles/parse_operator_bundle/tasks/bundle_sanity_checks.yml b/roles/parse_operator_bundle/tasks/bundle_sanity_checks.yml index 7e175062d..40b66b09e 100644 --- a/roles/parse_operator_bundle/tasks/bundle_sanity_checks.yml +++ b/roles/parse_operator_bundle/tasks/bundle_sanity_checks.yml @@ -26,20 +26,23 @@ - name: "Check if the operators.operatorframework.io.bundle.channels.v1 from annotation.yaml matches the bundle image label" fail: msg: "The operators.operators.operatorframework.io.bundle.channels.v1 value in the annotations yaml doesn't match the corresponding bundle image label!" - when: - - annotations_vars.annotations['operators.operatorframework.io.bundle.channels.v1'] != skopeo_inspect_json.Labels['operators.operatorframework.io.bundle.channels.v1'] + when: > + - annotations_vars.annotations['operators.operatorframework.io.bundle.channels.v1'] + != skopeo_inspect_json.Labels['operators.operatorframework.io.bundle.channels.v1'] - name: "Check if the operators.operatorframework.io.bundle.manifests.v1 from annotation.yaml matches the bundle image label" fail: msg: "The operators.operators.operatorframework.io.bundle.manifests.v1 value in the annotations yaml doesn't match the corresponding bundle image label!" - when: - - annotations_vars.annotations['operators.operatorframework.io.bundle.manifests.v1'] != skopeo_inspect_json.Labels['operators.operatorframework.io.bundle.manifests.v1'] + when: > + - annotations_vars.annotations['operators.operatorframework.io.bundle.manifests.v1'] + != skopeo_inspect_json.Labels['operators.operatorframework.io.bundle.manifests.v1'] - name: "Check if the operators.operatorframework.io.bundle.mediatype.v1 from annotation.yaml matches the bundle image label" fail: msg: "The operators.operatorframework.io.bundle.mediatype.v1 value in the annotations yaml doesn't match the corresponding bundle image label!" - when: - - annotations_vars.annotations['operators.operatorframework.io.bundle.mediatype.v1'] != skopeo_inspect_json.Labels['operators.operatorframework.io.bundle.mediatype.v1'] + when: > + - annotations_vars.annotations['operators.operatorframework.io.bundle.mediatype.v1'] + != skopeo_inspect_json.Labels['operators.operatorframework.io.bundle.mediatype.v1'] - name: "Check if the operators.operatorframework.io.bundle.mediatype.v1 is set to the expected value" fail: @@ -50,11 +53,13 @@ - name: "Check if the operators.operatorframework.io.bundle.metadata.v1 from annotation.yaml matches the bundle image label" fail: msg: "The operators.operatorframework.io.bundle.metadata.v1 value in the annotations yaml doesn't match the corresponding bundle image label!!" - when: - - annotations_vars.annotations['operators.operatorframework.io.bundle.metadata.v1'] != skopeo_inspect_json.Labels['operators.operatorframework.io.bundle.metadata.v1'] + when: > + - annotations_vars.annotations['operators.operatorframework.io.bundle.metadata.v1'] + != skopeo_inspect_json.Labels['operators.operatorframework.io.bundle.metadata.v1'] - name: "Check if the operators.operatorframework.io.bundle.package.v1 from annotation.yaml matches the bundle image label" fail: msg: "The operators.operatorframework.io.bundle.package.v1 value in the annotations yaml doesn't match the corresponding bundle image label!" - when: - - annotations_vars.annotations['operators.operatorframework.io.bundle.package.v1'] != skopeo_inspect_json.Labels['operators.operatorframework.io.bundle.package.v1'] + when: > + - annotations_vars.annotations['operators.operatorframework.io.bundle.package.v1'] + != skopeo_inspect_json.Labels['operators.operatorframework.io.bundle.package.v1'] diff --git a/roles/parse_operator_bundle/tasks/main.yml b/roles/parse_operator_bundle/tasks/main.yml index 2ea132437..1182404e8 100644 --- a/roles/parse_operator_bundle/tasks/main.yml +++ b/roles/parse_operator_bundle/tasks/main.yml @@ -1,7 +1,7 @@ --- - name: "Parsing the operator bundle data" block: - ## Must use this in conjunction with extract bundle + ## Must use this in conjunction with extract bundle - name: "Inspect the bundle image with skopeo" shell: "skopeo inspect oci:{{ operator_bundle_dir }}:latest" register: skopeo_inspect_result diff --git a/roles/parse_operator_metadata/defaults/main.yml b/roles/parse_operator_metadata/defaults/main.yml index 210541339..7eeaf723c 100644 --- a/roles/parse_operator_metadata/defaults/main.yml +++ b/roles/parse_operator_metadata/defaults/main.yml @@ -1,4 +1,4 @@ --- jq_bin_path: jq yq_bin_path: yq -operator_work_dir: /home/jenkins/agent/test-operator \ No newline at end of file +operator_work_dir: /home/jenkins/agent/test-operator diff --git a/roles/parse_operator_metadata/tasks/main.yml b/roles/parse_operator_metadata/tasks/main.yml index 7123f49a8..9402d51e0 100644 --- a/roles/parse_operator_metadata/tasks/main.yml +++ b/roles/parse_operator_metadata/tasks/main.yml @@ -16,7 +16,7 @@ debug: msg: "{{ package_path_result }}" - # assuming only one file matches the file path + # assuming only one file matches the file path - name: "set variable for package_path from package_path_result" set_fact: package_path: "{{ package_path_result.files[0].path }}" @@ -36,23 +36,23 @@ - name: "Load variables from package path into variable package_vars (upstream only)" block: - - name: Check if package file exists - stat: - path: "{{ package_path }}" - register: package_file_st - - - name: Fail if package file doesn't exists - fail: - msg: "{{ package_path }} does not exist" - when: not package_file_st.stat.exists - - - name: "Getting content of package file" - shell: "cat {{ package_path }}" - register: package_data - - - name: Set facts - set_fact: - package_vars: "{{ package_data.stdout | from_yaml }}" + - name: Check if package file exists + stat: + path: "{{ package_path }}" + register: package_file_st + + - name: Fail if package file doesn't exists + fail: + msg: "{{ package_path }} does not exist" + when: not package_file_st.stat.exists + + - name: "Getting content of package file" + shell: "cat {{ package_path }}" + register: package_data + + - name: Set facts + set_fact: + package_vars: "{{ package_data.stdout | from_yaml }}" when: run_upstream|bool - name: "GET package_name variable from loaded package_vars" @@ -216,7 +216,7 @@ - name: "Set failure result" set_fact: - parse_operator_metadata_results: {'result': 'fail', 'msg': "{{ ansible_failed_result }}" } + parse_operator_metadata_results: {'result': 'fail', 'msg': "{{ ansible_failed_result }}"} - name: "Fail the play with the results" debug: diff --git a/roles/prepare_catalog_repo_upstream/defaults/main.yml b/roles/prepare_catalog_repo_upstream/defaults/main.yml index 012282858..48b657a76 100644 --- a/roles/prepare_catalog_repo_upstream/defaults/main.yml +++ b/roles/prepare_catalog_repo_upstream/defaults/main.yml @@ -2,6 +2,3 @@ catalog_repo: https://github.com/operator-framework/community-operators.git catalog_repo_branch: master catalog_repo_dir: /tmp/community-operators-for-catalog operator_input_image: "" - - - diff --git a/roles/prepare_catalog_repo_upstream/tasks/main.yml b/roles/prepare_catalog_repo_upstream/tasks/main.yml index d63f35f30..672ecfbba 100644 --- a/roles/prepare_catalog_repo_upstream/tasks/main.yml +++ b/roles/prepare_catalog_repo_upstream/tasks/main.yml @@ -22,4 +22,4 @@ when: not operator_dir_st.stat.exists when: operator_input_image == "" tags: - - catalog_build \ No newline at end of file + - catalog_build diff --git a/roles/validate_operator_bundle/defaults/main.yml b/roles/validate_operator_bundle/defaults/main.yml index 73b172609..451e81e74 100644 --- a/roles/validate_operator_bundle/defaults/main.yml +++ b/roles/validate_operator_bundle/defaults/main.yml @@ -3,4 +3,4 @@ operator_work_dir: /tmp/operator-test/operator-files operator_sdk_bin_path: operator-sdk check_validation_result: true select_optional_tests: "" -run_operatorhub_checks: false \ No newline at end of file +run_operatorhub_checks: false diff --git a/roles/validate_operator_bundle/tasks/main.yml b/roles/validate_operator_bundle/tasks/main.yml index 52b119f7d..299e80331 100644 --- a/roles/validate_operator_bundle/tasks/main.yml +++ b/roles/validate_operator_bundle/tasks/main.yml @@ -56,4 +56,4 @@ msg: 'Operator sdk validation test failed, check validation-output.txt for more details' when: - check_validation_result|bool - - sdk_validation_result.rc != 0 \ No newline at end of file + - sdk_validation_result.rc != 0 diff --git a/upstream/local-test-operator.yml b/upstream/local-test-operator.yml index a1c8597a9..696753a23 100644 --- a/upstream/local-test-operator.yml +++ b/upstream/local-test-operator.yml @@ -19,7 +19,7 @@ openshift_namespace: "test-operator" work_dir: "/tmp/operator-test" testing_bin_path: "{{ work_dir }}/bin" - current_channel: "" # Added to avoid a potential bug with undefined variables + current_channel: "" # Added to avoid a potential bug with undefined variables olm_version: 0.14.1 environment: diff --git a/upstream/local.yml b/upstream/local.yml index 88d3be661..c1e4acfe6 100644 --- a/upstream/local.yml +++ b/upstream/local.yml @@ -18,10 +18,10 @@ run_bundle_test: true run_prepare_catalog_repo_upstream: true work_dir: "/tmp/operator-test" - operator_dir: "dummy" # so operator-courier will be installed + operator_dir: "dummy" # so operator-courier will be installed operator_input_image: "" image_protocol: "docker://" - bundle_image: "dummy" # so skopeo and umoci will be installed + bundle_image: "dummy" # so skopeo and umoci will be installed operator_work_dir: "{{ work_dir }}/operator-files" operator_bundle_src_dir: "{{ work_dir }}/operator-bundle/src" testing_bin_path: "{{ work_dir }}/bin" diff --git a/upstream/roles/deploy_olm_operator_openshift_upstream/tasks/main.yml b/upstream/roles/deploy_olm_operator_openshift_upstream/tasks/main.yml index 02dcf1e16..a1cf08d8b 100644 --- a/upstream/roles/deploy_olm_operator_openshift_upstream/tasks/main.yml +++ b/upstream/roles/deploy_olm_operator_openshift_upstream/tasks/main.yml @@ -88,9 +88,9 @@ vars: run_upstream: true -#- name: "Set upstream false" -# set_fact: -# run_upstream: false +# - name: "Set upstream false" +# set_fact: +# run_upstream: false - name: "Check suggested_namespace" include_tasks: get_namespace.yml diff --git a/upstream/roles/detect_operators_in_cluster/tasks/op_ver_own_logic.yml b/upstream/roles/detect_operators_in_cluster/tasks/op_ver_own_logic.yml index d90df99d8..8bb3869bc 100644 --- a/upstream/roles/detect_operators_in_cluster/tasks/op_ver_own_logic.yml +++ b/upstream/roles/detect_operators_in_cluster/tasks/op_ver_own_logic.yml @@ -16,7 +16,7 @@ when: - ocp_version_annotation_stdout is defined - ocp_version_annotation_stdout != "NotFound" - - ocp_version_annotation_stdout.find("v4.5,v4.6") != -1 #found + - ocp_version_annotation_stdout.find("v4.5,v4.6") != -1 # found set_fact: ocp_range_start_old: "4.5" ovol_appreg_supported: true @@ -69,7 +69,7 @@ when: - ocp_version_annotation_stdout is defined - ocp_version_annotation_stdout != "NotFound" - - ocp_version_annotation_stdout.find("-") == -1 # '-' not found + - ocp_version_annotation_stdout.find("-") == -1 # '-' not found - ocp_version_annotation_stdout.find("=") == -1 - ocp_version_annotation_stdout.find("v4.5,v4.6") == -1 @@ -79,7 +79,7 @@ when: - ocp_version_annotation_stdout is defined - ocp_version_annotation_stdout != "NotFound" - - ocp_version_annotation_stdout.find("-") == -1 # '-' not found + - ocp_version_annotation_stdout.find("-") == -1 # '-' not found - ocp_version_annotation_stdout.find("=") == -1 # - ocp_version_annotation_stdout.find("v4.5,v4.6") != -1 @@ -90,7 +90,7 @@ - ocp_version_annotation_stdout is defined - ocp_version_annotation_stdout != "NotFound" - ocp_version_annotation_stdout.find("=") == -1 - - ocp_version_annotation_stdout.find("-") == -1 # '-' not found + - ocp_version_annotation_stdout.find("-") == -1 # '-' not found - dov_cluster_ver is version(ocp_range_start, '>=') when: (ocp_version_annotation_stdout is defined) and (ocp_version_annotation_stdout != "NotFound")