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 complains about sshd var naming #297

Open
bayramkzk opened this issue Sep 4, 2024 · 6 comments
Open

ansible-lint complains about sshd var naming #297

bayramkzk opened this issue Sep 4, 2024 · 6 comments
Labels
coding-standards Items related to coding standards that do not affect functionality

Comments

@bayramkzk
Copy link

I am using ansible-lint in Neovim and linter complains about sshd variable naming convention here:

    - name: Configure sshd server daemon config
      ansible.builtin.include_role:
        name: willshersystems.sshd
      vars:
        sshd: # here
          PubkeyAuthentication: true
          PasswordAuthentication: false
          ClientAliveInterval: 60
          Port: "{{ my_sshd_port }}"
        sshd_manage_firewall: true
site.yaml|27 col 1 error| Variables names from within roles should use sshd_ as a prefix. (vars: sshd)

Linter doesn't complain when, say, I rename sshd to sshd_config but as expected the playbook doesn't work properly then.

@mattwillsher
Copy link
Member

Hi @bayramkzk
The .ansible-lint file excludes this check.
There is issue #246 with a view to rename the variables, but that may not be implemented due to the extent of changes required and risks to existing use of the role.

@bayramkzk
Copy link
Author

The .ansible-lint file excludes this check.

Yes, I have used # noqa var-naming[no-role-prefix] right after creating the issue and it seems to work around the issue. I understand it might not be possible to change this naming convention because of backwards compatibility but perhaps in this case also having sshd_config as an alternative alongside sshd could be a possible solution?

Regardless, I think I should close this issue as it appears to be a somewhat duplicate of the issue #246 you mentioned.

@bayramkzk bayramkzk closed this as not planned Won't fix, can't repro, duplicate, stale Sep 4, 2024
@mattwillsher
Copy link
Member

I'm going to reopen this as it's different to the issue seen in #246 as this is linting from the calling play rather than the module itself. I can't give time scales on the fix, but @spetrosi's suggestion looks like a good way forward.

@mattwillsher mattwillsher reopened this Sep 4, 2024
@mattwillsher mattwillsher added the coding-standards Items related to coding standards that do not affect functionality label Sep 4, 2024
@Jakuje
Copy link
Collaborator

Jakuje commented Sep 12, 2024

Ugh. It looks like the sshd variable itself is an issue for ansible. Not sure how we should name it then. I can think of sshd_ but I feel that would be just a workaround for this policy and would make it just more confusing for everyone.

The obvious workaround is:

      vars:
        sshd_PubkeyAuthentication: true
        sshd_PasswordAuthentication: false
        sshd_ClientAliveInterval: 60
        sshd_Port: "{{ my_sshd_port }}"

but I like the first syntax much more.

@mattwillsher
Copy link
Member

sshd_config looks like it's not used. So we could take this suggestion to deprecate sshd, update the docs etc. to sshd_config.
Or we could use sshd_sshd, which looks weird but should stop the linter complaining.

@mattwillsher
Copy link
Member

I'll pick this up and get a PR put together.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
coding-standards Items related to coding standards that do not affect functionality
Projects
None yet
Development

No branches or pull requests

3 participants