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

fix ansible lint seperate commits #684

Merged
merged 15 commits into from Oct 27, 2022

Conversation

dangel101
Copy link
Member

@dangel101 dangel101 commented Sep 28, 2022

  • fix ansible lint: risky file permissions: File permissions unset or incorrect
  • fix ansible lint: risky-shell-pipe: Shells that use pipes should set the pipefail option
  • fix ansible lints: - role-name: Role name does not match ^*$ pattern. - name: All tasks should be named. (name[missing])
  • fix ansible lint: package-latest: Package installs should not use latest
  • fix ansible lint: no-changed-when: Commands should not change things if nothing needs doing
  • fix ansible lints: - command-instead-of-module: systemctl used in place of systemd module (+ merged tasks), rpm used in place of yum or rpm_key module - command-instead-of-shell: Use shell only when shell functionality is required
  • fix ansible lint: ignore-errors: Use failed_when and specify error conditions instead of using ignore_errors
  • fix ansible lint: no-handler: Tasks that run when changed should likely be handlers
  • adding ansible-lint tests to CI (CI: enable ansible-lint run #484)

Fixes: #710

@dangel101
Copy link
Member Author

/ost

@dangel101 dangel101 force-pushed the fix_ansible_lint_seperate_commits branch from 6b8a262 to c50a679 Compare September 29, 2022 08:29
@dangel101
Copy link
Member Author

/ost

Copy link
Member

@mz-pdm mz-pdm left a comment

Choose a reason for hiding this comment

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

It's reviewable now, thank you for splitting it. Some comments inside. Besides that, please pay attention to the titles of the commits, almost all look weird.

vars:
gluster_cgroup_cpu_quota : "{{ [(ansible_processor_vcpus/3)|int,1]|max * 100 }}"
gluster_cgroup_cpu_quota: "{{ [(ansible_processor_vcpus / 3) | int, 1] | max * 100 }}"
Copy link
Member

Choose a reason for hiding this comment

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

Shouldn't there be a space also after the slash?

Copy link
Member Author

Choose a reason for hiding this comment

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

about the titles- it's because the title is long, looks like it was split automatically
space- yes, I fixed it in a commit I posted today: 0575c14

Copy link
Member

Choose a reason for hiding this comment

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

about the titles- it's because the title is long, looks like it was split automatically

Please don't respond to comments in unrelated places, otherwise it's hard to track discussions.

space- yes, I fixed it in a commit I posted today: 0575c14

Great, OK.

- name: Fetch the directory and volume details
block:
- name: Get the list of volumes on the machine
shell: ls "{{ glusterd_libdir }}/vols"
ansible.builtin.command: ls "{{ glusterd_libdir }}/vols"
Copy link
Member

Choose a reason for hiding this comment

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

Better (or mandatory?) to use argv with command rather than quoting inside the command. Also in other changes from shell where switching to command, not only here.

Copy link
Member Author

Choose a reason for hiding this comment

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

done- 564b39e

path: "{{ mntpath }}"
state: directory
mode: '755'
Copy link
Member

Choose a reason for hiding this comment

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

To specify the mode, '755' notation is used in some places and 0755 in other places. Since it's part of cleanup, it would be good to be consistent and preferably use one or the other everywhere.

Copy link
Member Author

Choose a reason for hiding this comment

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

done

@@ -14,5 +14,5 @@
disable virtstoraged.socket
disable virtproxyd.socket
enable libvirtd.service

when: el_ver|int >= 9
mode: preserve
Copy link
Member

Choose a reason for hiding this comment

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

When the dest file doesn't exist, system umask is used. This calls for problems, is there a reason not to specify the file mode directly here?

Copy link
Member Author

Choose a reason for hiding this comment

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

fixed

@@ -1,36 +1,36 @@
---
- block:
- name: Stop iptables service if running
service:
ansible.builtin.service: # noqa ignore-errors
Copy link
Member

Choose a reason for hiding this comment

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

I don't understand the reasoning in the commit message behind silencing this (and the related) warnings.

Copy link
Member Author

Choose a reason for hiding this comment

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

for this task- the task for running firewalld (2 tasks after this one) will fail anyway if iptables is running.
If iptables is stopped and the role can continue, and we don't care about iptables at this point- I don't see a reason to handle any errors related to iptables at this point.

host upgrade-
line #12: see my discussion with @almusil here-
#413

line #46: this is not a mandatory part of the upgrade process. we added it to clear space before upgrading, and If cleaning cache fails, in most cases there'll be enough space to continue with upgrading the packages.

Copy link
Member

Choose a reason for hiding this comment

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

for this task- the task for running firewalld (2 tasks after this one) will fail anyway if iptables is running. If iptables is stopped and the role can continue, and we don't care about iptables at this point- I don't see a reason to handle any errors related to iptables at this point.

OK. Please put this information to the commit message. The current explanation there, "Use failed_when and specify error conditions instead of using ignore_errors", talks about something different and unrelated to the current version, which confused me. It has probably been forgotten to update when the patch changed?

host upgrade- line #12: see my discussion with @almusil here- #413

line #46: this is not a mandatory part of the upgrade process. we added it to clear space before upgrading, and If cleaning cache fails, in most cases there'll be enough space to continue with upgrading the packages.

I'm losing the context here.

@mz-pdm
Copy link
Member

mz-pdm commented Oct 3, 2022

about the titles- it's because the title is long, looks like it was split automatically

Make sure each commit message has its short single-line title, separated from the following content by a blank line.

@dangel101 dangel101 force-pushed the fix_ansible_lint_seperate_commits branch from 1079e9a to 983aa07 Compare October 3, 2022 11:18
@dangel101
Copy link
Member Author

about the titles- it's because the title is long, looks like it was split automatically

Make sure each commit message has its short single-line title, separated from the following content by a blank line.

done

@dangel101 dangel101 force-pushed the fix_ansible_lint_seperate_commits branch from 983aa07 to 564b39e Compare October 6, 2022 12:55
@dangel101
Copy link
Member Author

@mz-pdm I pushed the fixes we discussed
thanks

@dangel101
Copy link
Member Author

/ost

@mwperina mwperina force-pushed the fix_ansible_lint_seperate_commits branch 2 times, most recently from 48fe11a to fcf3b2d Compare October 7, 2022 07:19
@mwperina
Copy link
Member

mwperina commented Oct 7, 2022

/ost

1 similar comment
@mwperina
Copy link
Member

mwperina commented Oct 7, 2022

/ost

@mwperina mwperina force-pushed the fix_ansible_lint_seperate_commits branch from fcf3b2d to 7d3601c Compare October 7, 2022 13:13
@dangel101
Copy link
Member Author

/ost

@dangel101 dangel101 force-pushed the fix_ansible_lint_seperate_commits branch from fd72d56 to f85875f Compare October 20, 2022 11:10
@dangel101
Copy link
Member Author

/ost

3 similar comments
@dangel101
Copy link
Member Author

/ost

@dangel101
Copy link
Member Author

/ost

@dangel101
Copy link
Member Author

/ost

@dangel101 dangel101 force-pushed the fix_ansible_lint_seperate_commits branch from b6a7f48 to a798cae Compare October 24, 2022 10:31
@dangel101
Copy link
Member Author

/ost

@dangel101 dangel101 force-pushed the fix_ansible_lint_seperate_commits branch from a798cae to 56a7a69 Compare October 25, 2022 14:50
@dangel101
Copy link
Member Author

/ost

1 similar comment
@dangel101
Copy link
Member Author

/ost

Bug-Url: https://bugzilla.redhat.com/show_bug.cgi?id=2100137

including fixes for:
- use FQCN for builtin actions
- missing starting space in comment
- jinja2 spacing could be improved
- line too long
- no new line character at the end of file
- trailing spaces
- too many spaces before colon
- too many spaces after colon
- too many blank lines
- all names should start with an uppercase letter
- truthy value should be one of  (yaml[truthy])
- wrong indentation
'File permissions unset or incorrect'
'Shells that use pipes should set the pipefail option'
- role-name: Role name <role-name> does not match ``^*$`` pattern.
- name: All tasks should be named. (name[missing])
'Commands should not change things if nothing needs doing'

Since the tag 'skip_ansible_lint oVirt#301' doesn't work and '# noqa no-changed-when' cannot be set on code blocks,
adding it to skip list
- command-instead-of-module: systemctl used in place of systemd module (+ merged tasks), rpm used in
  place of yum or rpm_key module
- command-instead-of-shell: Use shell only when shell functionality is required
The error 'Use failed_when and specify error conditions instead of using ignore_errors'
was handled by adding '# noqa ignore-errors' tag, since failure in these tasks shouldn't
block from continuing the execution of the role
Tasks that run when changed should likely be handlers
'Templated files should use template instead of copy'
fixed in all places that replaced shell with command
- use FQCN for builtin module actions (include_tasks, import_tasks)
- Use FQCN for module actions
Ignoring because when using 'set -o pipefail &&' the task fails due to
non zero return code
@dangel101 dangel101 force-pushed the fix_ansible_lint_seperate_commits branch from 56a7a69 to 88febb7 Compare October 26, 2022 10:54
@dangel101
Copy link
Member Author

/ost

Copy link
Member

@mwperina mwperina left a comment

Choose a reason for hiding this comment

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

+1

@mwperina mwperina merged commit 0a578cb into oVirt:master Oct 27, 2022
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.

Fix ansible-lint 6.0.0 for engine roles
4 participants