lowlydba / lowlydba.sqlserver

:spoon: A cross-platform Ansible collection using PowerShell to configure and maintain SQL Server.
https://galaxy.ansible.com/ui/repo/published/lowlydba/sqlserver
GNU General Public License v3.0
20 stars 12 forks source link

[Bug] Login always reports changed #164

Closed jkrilov closed 1 year ago

jkrilov commented 1 year ago

Describe the bug lowlydba.sqlserver.login always shows as changed

To Reproduce

Redacted code snipped:

- name: Create login
  lowlydba.sqlserver.login:
    sql_instance: "{{ SQL_HOSTNAME }}"
    sql_username: "{{ SQL_ADMIN_USER }}"
    sql_password: "{{ SQL_ADMIN_PASS }}"
    login: "{{ SQL_USER }}"
    password: "{{ SQL_PASS }}"
    password_expiration_enabled: false
    password_policy_enforced: false
    language: "us_english"

Expected behavior Login should only change when first created.

Versions(please complete the following information):

Additional context

lowlydba commented 1 year ago

Thanks for the issue! I think its a matter of not handling the default NULL properties properly when comparing to existing values, should be an easy fix.

lowlydba commented 1 year ago

Ok, so after taking a look I think the issue is probably from supplying a Password. Since we can't fetch the existing password, we can't really know if the one being supplied is different, so every time it is supplied it gets set for the Login and the result is always changed in that case.

Even if the password is set the same, properties like PasswordLastSetTime are updated.

I can definitely add a callout about this in the documentation, but don't have any other ideas how to make it more accurate. Open to suggestions if you have any.

lowlydba commented 1 year ago

I closed this with the aforementioned docs update, but if you have any other ideas feel free to comment here or open a new issue!