Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

testing: lints partial fixes #22

Merged
merged 1 commit into from
Aug 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 0 additions & 13 deletions config/ansible-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,7 @@ skip_list:
- 'deprecated-local-action'
- 'no-free-form'
- 'chema[meta]'
- 'var-naming[no-reserved]'
- 'var-naming[no-role-prefix]'
- 'var-naming[pattern]'
- 'yaml[colons]'
- 'yaml[commas]'
- 'yaml[comments]'
- 'yaml[empty-lines]'
- 'yaml[indentation]'
- 'yaml[key-duplicates]'
- 'yaml[line-length]'
- 'yaml[octal-values]'
- 'yaml[truthy]'
- 'name[template]'
- 'name[casing]'
- 'risky-file-permissions'
- 'ignore-errors'
- 'no-changed-when'
Expand Down
2 changes: 1 addition & 1 deletion roles/cluster/cluster_create_osd/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
set -o pipefail;
test $(cat "{{ cluster_create_osd_kubeconfig }}" | wc -c) == 0

- name: Ensure that the secret file '{{ cluster_create_osd_secret_file }}' exists
- name: Ensure that following secret file exists {{ cluster_create_osd_secret_file }}
stat:
path: "{{ cluster_create_osd_secret_file }}"

Expand Down
4 changes: 2 additions & 2 deletions roles/cluster/cluster_deploy_aws_efs/tasks/aws-efs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@

- name: Populate the tags dict
set_fact:
tags: "{{ tags | default({}) | combine({item.key: item.value}) }}"
cluster_tags: "{{ cluster_tags | default({}) | combine({item.key: item.value}) }}"
with_items:
- {'key': 'Name' , 'value': '{{ cluster_name_cmd.stdout }}'}
- {'key': '{{ cluster_name_tag_cmd.stdout }}' , 'value': 'owned'}
Expand Down Expand Up @@ -130,7 +130,7 @@
region: "{{ cluster_region }}"
state: present
name: "EFS {{ cluster_name_cmd.stdout }}"
tags: "{{ tags }}"
tags: "{{ cluster_tags }}"
targets: "{{ targets }}"
register: aws_efs_fs

Expand Down
2 changes: 1 addition & 1 deletion roles/cluster/cluster_deploy_aws_efs/tasks/ocp-efs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
include_role:
name: entitlement_inspect
vars:
_entitlement_inspect_called_from_testwait: "yes"
entitlement_inspect_called_from_testwait: "yes"
when: entitlement_inspect_on_failure == 'yes'
8 changes: 4 additions & 4 deletions roles/cluster/cluster_deploy_ldap/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# content are secrets (passwords). With Python+envsubst, we're sure
# that the secrets won't be printed in clear.

- name: Ensure that the secret properties file '{{ cluster_deploy_ldap_secret_properties_file }}' exists and is a file
- name: Ensure that the following secret properties path exists and it is a file {{ cluster_deploy_ldap_secret_properties_file }}
stat:
path: "{{ cluster_deploy_ldap_secret_properties_file }}"
register: secret_props_file_stat
Expand Down Expand Up @@ -82,7 +82,7 @@
- name: Get LDAP Bind DN
command:
yq .ldap.bindDN "{{ artifact_extra_logs_dir }}/oauth_ldap.yaml"
register: ldap_bindDN_cmd
register: ldap_bind_dn_cmd

- name: Deploy on OCP
when: not cluster_deploy_ldap_use_ocm
Expand Down Expand Up @@ -120,7 +120,7 @@
--cluster "{{ cluster_deploy_ldap_cluster_name }}" \
--name "{{ cluster_deploy_ldap_idp_name }}" \
--url "{{ ldap_url_cmd.stdout }}" \
--bind-dn "{{ ldap_bindDN_cmd.stdout }}" \
--bind-dn "{{ ldap_bind_dn_cmd.stdout }}" \
--bind-password $(echo "$cluster_ldap_adminpassword") \
--insecure

Expand All @@ -137,7 +137,7 @@
--cluster "{{ cluster_deploy_ldap_cluster_name }}" \
--name "{{ cluster_deploy_ldap_idp_name }}" \
--url "{{ ldap_url_cmd.stdout }}" \
--bind-dn "{{ ldap_bindDN_cmd.stdout }}" \
--bind-dn "{{ ldap_bind_dn_cmd.stdout }}" \
--bind-password $(echo "$cluster_ldap_adminpassword")
# need to add --insecure here, when available in `ocm`.

Expand Down
2 changes: 1 addition & 1 deletion roles/cluster/cluster_deploy_nginx_server/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
path: "{{ cluster_deploy_nginx_server_directory }}"
register: directory_stats

- name: Fail if {{ cluster_deploy_nginx_server_directory }} is not a directory
- name: Fail if the following path is not a directory {{ cluster_deploy_nginx_server_directory }}
fail: msg="'{{ cluster_deploy_nginx_server_directory }}' isn't a reachable directory."
when: not directory_stats.stat.exists or not directory_stats.stat.isdir

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
-o json
> {{ artifact_extra_logs_dir }}/source_machineset.json

- name: Update the MachineSet with the requested instance type ({{ machineset_instance_type }}) and store in a file
- name: Update and store in a file the MachineSet with the requested instance type {{ machineset_instance_type }}
shell:
"{{ reconfigure_machineset }}
{{ artifact_extra_logs_dir }}/source_machineset.json
Expand All @@ -35,7 +35,7 @@
{{ machineset_taint }}
> {{ artifact_extra_logs_dir }}/new_machineset.json"

- name: Update the MachineSet {% if cluster_ensure_machineset_spot %}with{% else %}without{% endif %} the Spot instance flag
- name: Update the MachineSet spotMarketOptions spec to be {% if cluster_ensure_machineset_spot %}added{% else %}deleted{% endif %}
shell:
set -o pipefail;

Expand Down
2 changes: 1 addition & 1 deletion roles/cluster/cluster_ensure_machineset/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
- name: "Check if the cluster already has a {{ machineset_instance_type }} machineset"
- name: Check if the cluster already has a machineset of type {{ machineset_instance_type }}
shell:
set -o pipefail;
oc get machineset -n openshift-machine-api
Expand Down
16 changes: 8 additions & 8 deletions roles/cluster/cluster_preload_image/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,10 @@
oc get ds/{{ cluster_preload_image_name }}
'-ojsonpath={.status.desiredNumberScheduled}'
-n {{ cluster_preload_image_namespace }}
register: desiredNumberScheduled_cmd
register: desired_number_scheduled_cmd
retries: 3
delay: 15
until: desiredNumberScheduled_cmd or "0" | int > 0
until: desired_number_scheduled_cmd or "0" | int > 0

- name: Wait for the pods to be scheduled
shell:
Expand All @@ -53,10 +53,10 @@
-ojson
-n {{ cluster_preload_image_namespace }}
| jq '.status.desiredNumberScheduled - .status.currentNumberScheduled'
register: currentNumberNotScheduled_cmd
register: current_number_not_scheduled_cmd
retries: 3
delay: 15
until: currentNumberNotScheduled_cmd.stdout | int == 0
until: current_number_not_scheduled_cmd.stdout | int == 0

- name: Wait for the pods to be ready
shell:
Expand All @@ -65,21 +65,21 @@
-ojson
-n {{ cluster_preload_image_namespace }}
| jq '.status.desiredNumberScheduled - .status.numberReady'
register: currentNumberNotReady_cmd
register: current_number_not_ready_cmd
retries: 20
delay: 30
until: currentNumberNotReady_cmd.stdout | int == 0
until: current_number_not_ready_cmd.stdout | int == 0

- name: Get the final desired number
command:
oc get ds/{{ cluster_preload_image_name }}
'-ojsonpath={.status.desiredNumberScheduled}'
-n {{ cluster_preload_image_namespace }}
register: finalDesiredNumberScheduled_cmd
register: final_desired_number_scheduled_cmd

- name: Fail if the image has been preloaded on 0 nodes
fail: msg="The node selector '{{ cluster_preload_image_node_selector_key }}={{ cluster_preload_image_node_selector_value }}' did not match any node"
when: finalDesiredNumberScheduled_cmd.stdout | int == 0
when: final_desired_number_scheduled_cmd.stdout | int == 0

always:
- name: Get the description of the preload Pods
Expand Down
10 changes: 5 additions & 5 deletions roles/cluster/cluster_set_scale/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,12 @@
register: oc_get_machinesets
failed_when: not oc_get_machinesets.stdout

- name: Change all {{ machineset_instance_type }} machinesets replicas to have sum {{ scale }}
- name: Change all {{ machineset_instance_type + 'machinesets replicas to have sum' + scale | string }}
when: current_replicas_sum != scale
block:
- name: Do not downscale any machinesets other than the first one, unless the user used force
block:
- name: Calculate sum of replicas of machinesets with type {{ machineset_instance_type }}, except for the first one
- name: Calculate except for the first one, the sum of replicas of machinesets with type {{ machineset_instance_type }}
set_fact:
current_replicas_sum_non_first: "{{ machineset_replicas.stdout_lines[1:] | map('int') | sum(start=0) }}"

Expand All @@ -66,7 +66,7 @@
- name: End play
fail: msg="Missing force flag"

- name: Set the replicas of all {{ machineset_instance_type }} machinesets to 0 except the first
- name: Set the replicas of all machinesets to 0 except the first for {{ machineset_instance_type }}
command: |
oc patch machineset -n openshift-machine-api {{ item }} --patch '{"spec": {"replicas": 0 }}' --type merge
loop: "{{ oc_get_machinesets.stdout_lines[1:] }}"
Expand All @@ -75,14 +75,14 @@
set_fact:
first_machineset: "{{ oc_get_machinesets.stdout_lines[0] }}"

- name: Set the replicas of the first {{ machineset_instance_type }} machineset ({{ first_machineset }}) to {{ scale }}
- name: Set the replicas of the first {{ machineset_instance_type + 'machineset (' + first_machineset + ') to ' + scale | string }}
command: >
oc patch machineset -n openshift-machine-api {{ first_machineset }}
--patch '{"spec": {"replicas": {{ scale }} }}' --type merge

- name: Make sure the machinesets are ready
block:
- name: Wait for all machinesets with type {{ machineset_instance_type }} to be ready
- name: Wait for readiness for all machinesets with type {{ machineset_instance_type }}
# This is done by verifying that at the availableReplicas

# jq purpose, respectively:
Expand Down
10 changes: 5 additions & 5 deletions roles/entitlement/entitlement_deploy/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
---
- name: "Ensure that the entitlement file 'entitlement_pem={{ entitlement_pem }}' exists"
- name: Ensure that the entitlement file exists entitlement_pem={{ entitlement_pem }}
stat:
path: '{{ entitlement_pem }}'
register: entitlement_pem_stat
failed_when: not entitlement_pem_stat.stat.exists

- name: "Ensure that the entitlement RHSM file 'entitlement_rhsm={{ entitlement_rhsm }}' exists"
- name: Ensure that the entitlement RHSM file exists entitlement_rhsm={{ entitlement_rhsm }}
stat:
path: '{{ entitlement_rhsm }}'
register: entitlement_rhsm_stat
Expand All @@ -28,23 +28,23 @@
set_fact:
machine_config_role: worker

- name: "Deploy RHSM from file '{{ entitlement_rhsm }}'"
- name: Deploy RHSM from file {{ entitlement_rhsm }}
shell:
set -o pipefail;
cat "{{ entitlement_mc_rhsm }}"
| python3 "{{ entitlement_py_apply }}" BASE64_ENCODED_RHSM_FILE @"{{ entitlement_rhsm }}"
| python3 "{{ entitlement_py_apply }}" MACHINE_CONFIG_ROLE "{{ machine_config_role }}"
| oc apply -f-

- name: "Deploy the pem and key-pem from file '{{ entitlement_pem }}'"
- name: Deploy the pem and key-pem from file {{ entitlement_pem }}
shell:
set -o pipefail;
cat "{{ entitlement_mc_pem }}"
| python3 "{{ entitlement_py_apply }}" BASE64_ENCODED_PEM_FILE @"{{ entitlement_pem }}"
| python3 "{{ entitlement_py_apply }}" MACHINE_CONFIG_ROLE "{{ machine_config_role }}"
| oc apply -f-

- name: "Deploy the repo CA from file '{{ entitlement_mc_rhsm_ca }}' if requested"
- name: If requested deploy the repo CA from file {{ entitlement_mc_rhsm_ca }}
when: entitlement_repo_ca | default('', true) | trim != ''
block:
- name: Compute the md5sum of the CA file (debug)
Expand Down
2 changes: 1 addition & 1 deletion roles/entitlement/entitlement_inspect/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
- name: Run the entitlement test taskbook
include_role:
name: entitlement_test_wait_deployment
when: _entitlement_inspect_called_from_testwait == "no"
when: entitlement_inspect_called_from_testwait == "no"

- name: List entitlement MachineConfig objects
command: oc get MachineConfig 50-entitlement-key-pem 50-entitlement-pem 50-rhsm-conf
Expand Down
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
_entitlement_inspect_called_from_testwait: "no"
entitlement_inspect_called_from_testwait: "no"
4 changes: 2 additions & 2 deletions roles/entitlement/entitlement_test_in_cluster/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
---
- name: "Ensure that the entitlement file 'entitlement_pem={{ entitlement_pem }}' exists"
- name: Ensure that the entitlement file exists entitlement_pem={{ entitlement_pem }}
stat:
path: '{{ entitlement_pem }}'
register: entitlement_pem_stat
failed_when: not entitlement_pem_stat.stat.exists

- name: "Ensure that the entitlement RHSM file 'entitlement_rhsm={{ entitlement_rhsm }}' exists"
- name: Ensure that the entitlement RHSM file exists entitlement_rhsm={{ entitlement_rhsm }}
stat:
path: '{{ entitlement_rhsm }}'
register: entitlement_rhsm_stat
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
- name: "Ensure that the entitlement file 'entitlement_pem={{ entitlement_pem }}' exists"
- name: Ensure that the entitlement file exists entitlement_pem={{ entitlement_pem }}
stat:
path: '{{ entitlement_pem }}'
register: entitlement_pem_stat
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
---
- name: "Set the number of retry loop to 0 as waiting not requested"
- name: Set the number of retry loop to 0 as waiting not requested
set_fact:
entitlement_retries: 0
when: entitlement_test_and_wait != 'yes'

- name: "Set the number of retry loop to {{ entitlement_nb_wait_retries }} as waiting is requested"
- name: As waiting is requested set the number of retry loop to {{ entitlement_nb_wait_retries }}
set_fact:
entitlement_retries: "{{ entitlement_nb_wait_retries }}"
when: entitlement_test_and_wait == 'yes'
Expand Down Expand Up @@ -53,7 +53,7 @@
include_role:
name: entitlement_inspect
vars:
_entitlement_inspect_called_from_testwait: "yes"
entitlement_inspect_called_from_testwait: "yes"
when: entitlement_inspect_on_failure == 'yes'

- name: Store the description of the test Pod (debug)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,28 +12,28 @@

# ---

- name: "Get the GPU Operator Pod in {{ gpu_operator_operator_namespace }} (list)"
- name: Get the GPU Operator Pod as a list from {{ gpu_operator_operator_namespace }}
shell:
oc get pods -lapp=gpu-operator
-n {{ gpu_operator_operator_namespace }} -owide
> {{ artifact_extra_logs_dir }}/gpu_operator_pod.list
failed_when: false

- name: "Get the GPU Operator Pod in {{ gpu_operator_operator_namespace }} (yaml)"
- name: Get the GPU Operator Pod as yaml from {{ gpu_operator_operator_namespace }}
shell:
oc get pods -lapp=gpu-operator
-n {{ gpu_operator_operator_namespace }} -oyaml
> {{ artifact_extra_logs_dir }}/gpu_operator_pod.yaml
failed_when: false

- name: "Get the Pods in {{ gpu_operator_namespace }} (list)"
- name: Get the Pods as a list from {{ gpu_operator_namespace }}
shell:
oc get pods -owide
-n {{ gpu_operator_namespace }}
> {{ artifact_extra_logs_dir }}/all_gpu_pods.list
failed_when: false

- name: "Get the Pods in {{ gpu_operator_namespace }} (yaml)"
- name: Get the Pods as yaml from {{ gpu_operator_namespace }}
shell:
oc get pods -oyaml
-n {{ gpu_operator_namespace }}
Expand All @@ -52,14 +52,14 @@
done
failed_when: false

- name: "Get the DaemonSets in {{ gpu_operator_namespace }} (list)"
- name: Get the following DaemonSets as a list from {{ gpu_operator_namespace }}
shell:
oc get ds
-n {{ gpu_operator_namespace }}
> {{ artifact_extra_logs_dir }}/all_gpu_ds.list
failed_when: false

- name: "Get the DaemonSets in {{ gpu_operator_namespace }} (yaml)"
- name: Get the following DaemonSets in yaml from {{ gpu_operator_namespace }}
shell:
oc get ds -oyaml
-n {{ gpu_operator_namespace }}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
- name: Get the operator version
block:
- name: check if env is available
- name: Check if env is available
shell: echo "$GPU_OPERATOR_VERSION"
register: gpu_operator_csv_version_cmd
failed_when: gpu_operator_csv_version_cmd.stdout | length == 0
Expand Down Expand Up @@ -36,10 +36,10 @@
register: gpu_operator_csv_version_cmd
failed_when: gpu_operator_csv_version_cmd.stdout | length == 0

- name: Store the version '{{ gpu_operator_csv_version_cmd.stdout }}' as an ansible variable
- name: Store the version as an ansible variable '{{ gpu_operator_csv_version_cmd.stdout }}'
set_fact:
gpu_operator_version: '{{ gpu_operator_csv_version_cmd.stdout }}'

- name: Store the veersion '{{ gpu_operator_csv_version_cmd.stdout }}' as an artifacts file
- name: Store the version as an artifacts file '{{ gpu_operator_csv_version_cmd.stdout }}'
shell:
echo '{{ gpu_operator_version }}' > {{ artifact_extra_logs_dir }}/gpu_operator.version
2 changes: 1 addition & 1 deletion roles/nfd/nfd_test_wait_gpu/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
nfd_wait_gpu_retries: 0
when: nfd_wait_gpu_nodes != 'yes'

- name: "Set the number of retry loop to {{ nfd_wait_gpu_nb_retries }} if waiting is requested"
- name: Set the number of retry loop if waiting is requested to {{ nfd_wait_gpu_nb_retries }}
set_fact:
nfd_wait_gpu_retries: "{{ nfd_wait_gpu_nb_retries }}"
when: nfd_wait_gpu_nodes == 'yes'
Expand Down
Loading
Loading