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

ansible-lint 6.x fixes; add ansible-lint github action #43

Merged
merged 1 commit into from
Jan 17, 2023

Conversation

richm
Copy link
Contributor

@richm richm commented Jan 13, 2023

Get ansible-pcp working with ansible-lint 6.x and minimal exceptions
All tasks must be named - even include_tasks and meta tasks
Task names must start with uppercase letter
Use true/false instead of yes/no
Use changed_when: false for command and shell that run unconditionally
Add set -o pipefail for shell that use pipes. Note that pipefail is not
supported on Debian and some Ubuntu platforms, and the roles list them as
supported platforms.
Fix up jinja spacing
no spaces after [, { - no spaces before ], }
should have a single space before and after |
Other cleanup e.g. role meta/main.yml

In addition:
Do not use quotes for strings if not needed (Ansible "modern" style)
Remove unused handlers
Clean up tox.yml
Add separate github action for ansible-lint
Remove anything having to do with python code since this does not
provide any Ansible modules or other plugins

@richm richm requested a review from natoscott January 13, 2023 18:56
- { user: 'grafana' }
- { user: 'metrics', sasluser: 'metrics', saslpassword: 'p4ssw0rd' }
- {user: 'grafana'}
- {user: 'metrics', sasluser: 'metrics', saslpassword: 'p4ssw0rd'}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Out of curiosity, in which case are we supposed to keep single quotes vs. eliminate them?

Copy link
Contributor Author

@richm richm Jan 14, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://github.com/redhat-cop/automation-good-practices/tree/main/coding_style#yaml-and-jinja2-syntax

Do not use quotes unless you have to, especially for short module-keyword-like strings like present, absent, etc. But do use quotes for user-side strings such as descriptions, names, and messages.

In this case, {user: 'grafana'} - I would have to refer to the YAML standard to see if {user: grafana} is ok, since it is a JSON construct embedded within a YAML document.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see. Thanks!

Copy link
Contributor

@nhosoi nhosoi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

Copy link
Member

@natoscott natoscott left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm, thanks @richm

Get ansible-pcp working with ansible-lint 6.x and minimal exceptions
All tasks must be named - even `include_tasks` and `meta` tasks
Task names must start with uppercase letter
Use `true`/`false` instead of `yes`/`no`
Use `changed_when: false` for `command` and `shell` that run unconditionally
Add `set -o pipefail` for `shell` that use pipes.  Note that `pipefail` is not
supported on Debian and some Ubuntu platforms, and the roles list them as
supported platforms.
Fix up jinja spacing
  no spaces after `[`, `{` - no spaces before `]`, `}`
  should have a single space before and after `|`
Other cleanup e.g. role meta/main.yml

In addition:
Do not use quotes for strings if not needed (Ansible "modern" style)
Remove unused handlers
Clean up tox.yml
Add separate github action for ansible-lint
Remove anything having to do with python code since this does not
provide any Ansible modules or other plugins
@richm richm force-pushed the ansible-lint-6.x-fixes branch from 32e6d42 to b47459a Compare January 17, 2023 15:18
@richm richm merged commit 6dd0e92 into performancecopilot:main Jan 17, 2023
@richm richm deleted the ansible-lint-6.x-fixes branch January 17, 2023 15:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants