#12284 no-changed-when: Commands should not change things if nothing needs doing. [openshift playbooks linting]
Closed: Fixed by zlopez. Opened by ryanlerch.

I am trying to fix all the linting issues for the openshift playbooks, and came across these. Any ideas on best practise to fix this?

WARNING  Listing 21 violation(s) that are fatal
Read documentation for instructions on how to ignore specific rule violations.
  Rule Violation Summary                  
 count tag             profile rule associated tags       
    21 no-changed-when shared  command-shell, idempotency 
Failed: 21 failure(s), 0 warning(s) on 64 files. 
no-changed-when: Commands should not change things if nothing needs doing.
playbooks/openshift-apps/application-monitoring.yml:21 Task/Handler: Apply node labels
no-changed-when: Commands should not change things if nothing needs doing.
playbooks/openshift-apps/application-monitoring.yml:24 Task/Handler: Apply node labels for bodhi POC
no-changed-when: Commands should not change things if nothing needs doing.
playbooks/openshift-apps/application-monitoring.yml:27 Task/Handler: Make other pods available to the application-monitoring project
no-changed-when: Commands should not change things if nothing needs doing.
playbooks/openshift-apps/application-monitoring.yml:33 Task/Handler: Prometheus CRDs
no-changed-when: Commands should not change things if nothing needs doing.
playbooks/openshift-apps/application-monitoring.yml:36 Task/Handler: Prometheus CRD RBAC
no-changed-when: Commands should not change things if nothing needs doing.
playbooks/openshift-apps/application-monitoring.yml:39 Task/Handler: Prometheus Operator RBAC
no-changed-when: Commands should not change things if nothing needs doing.
playbooks/openshift-apps/application-monitoring.yml:42 Task/Handler: Prometheus RBAC
no-changed-when: Commands should not change things if nothing needs doing.
playbooks/openshift-apps/bodhi.yml:156 Task/Handler: Scale up pods
no-changed-when: Commands should not change things if nothing needs doing.
playbooks/openshift-apps/bodhi.yml:159 Task/Handler: Scale up pods
no-changed-when: Commands should not change things if nothing needs doing.
playbooks/openshift-apps/bodhi.yml:162 Task/Handler: Scale up pods
no-changed-when: Commands should not change things if nothing needs doing.
playbooks/openshift-apps/bodhi.yml:165 Task/Handler: Scale up pods
no-changed-when: Commands should not change things if nothing needs doing.
playbooks/openshift-apps/bodhi.yml:168 Task/Handler: Scale up pods
no-changed-when: Commands should not change things if nothing needs doing.
playbooks/openshift-apps/bodhi.yml:171 Task/Handler: Scale up pods
no-changed-when: Commands should not change things if nothing needs doing.
playbooks/openshift-apps/bodhi.yml:174 Task/Handler: Set the timeout to the openshift route
no-changed-when: Commands should not change things if nothing needs doing.
playbooks/openshift-apps/bodhi.yml:178 Task/Handler: Trigger critpath cronjob
no-changed-when: Commands should not change things if nothing needs doing.
playbooks/openshift-apps/custom-error-pages.yml:27 Task/Handler: Patch ingress controller with custom error pages
no-changed-when: Commands should not change things if nothing needs doing.
playbooks/openshift-apps/greenwave.yml:101 Task/Handler: Set the timeout to the openshift route
no-changed-when: Commands should not change things if nothing needs doing.
playbooks/openshift-apps/languages.yml:73 Task/Handler: Run initial f.10 import
no-changed-when: Commands should not change things if nothing needs doing.
playbooks/openshift-apps/languages.yml:80 Task/Handler: Run initial f.20 import
no-changed-when: Commands should not change things if nothing needs doing.
playbooks/openshift-apps/languages.yml:87 Task/Handler: Run initial f.30 import
no-changed-when: Commands should not change things if nothing needs doing.
playbooks/openshift-apps/languages.yml:94 Task/Handler: Run initial f.latest import

Metadata Update from @phsmoura:
- Issue priority set to: Waiting on Assignee (was: Needs Review)
- Issue tagged with: medium-gain, medium-trouble, ops

There is an explanation how to fix it in https://ansible.readthedocs.io/projects/lint/rules/no-changed-when/ It's to prevent the command to be run when nothing needs to be done, it will also help with showing you correctly which tasks changed things.

You can either do it like it's changed always or just look for specific output for example, like it is done in ipa role

Yeah, we just oc apply and let openshift decide when something needs to change.

I guess we can set them to always changed... which kinda sucks, but there's not a good way I don't think for oc apply to tell us if it had to change something or not.

@zlopez is just going to add some lint handling for these.

The changes is added in https://pagure.io/fedora-infra/ansible/pull-request/2940

Commit 607fca57 fixes this issue

Metadata Update from @zlopez:
- Issue assigned to zlopez

Metadata
Related Pull Requests