sqlserver::user::permissions always applied as corrective
评估
调研方向
从 templates/query/user/permission_exists.sql.epp 开始,并将其与 templates/create/user/permission.sql.epp 和 templates/query/role/permission_exists.sql.epp 进行比较。检查 permission 变量的设置,然后按所述运行 Puppet 复现两次。完成的标准是,第二次运行报告 sqlserver_tsql 资源已同步,且不会重新应用 GRANT 权限。
由索引模型根据 Issue 内容生成。
描述
Describe the Bug
When declaring sqlserver::user::permissions with GRANT permissions, Puppet re-applies the permissions on every run as a corrective change, even though the permissions are already in the desired state.
Expected Behavior
On the second Puppet run (after permissions are already granted), the sqlserver_tsql resource should be in sync and no corrective change should occur.
Steps to Reproduce
- Declare
sqlserver::user::permissionswith e.g.permissions: ['SELECT', 'INSERT']andstate: GRANT - Run Puppet agent — permissions are applied
- Run Puppet agent again — permissions are re-applied as corrective
Root Cause
The onlyif query template templates/query/user/permission_exists.sql.epp iterates over permissions but never assigns the SQL variable @permission:
<% $permissions.each |$requested_permission| { %>
<% $permission = $requested_permission.upcase %>
<%= epp('sqlserver/snippets/user/permission/exists.sql.epp', ...) %>
<% } %>
The Puppet variable $permission is set, but the SQL variable @permission stays NULL. Since permission_name = NULL is never TRUE in SQL Server, the subquery always returns NULL, ISNULL coerces it to 'REVOKE', and the check always sees a mismatch — causing Puppet to re-grant every time.
The create template (templates/create/user/permission.sql.epp) and the role equivalent (templates/query/role/permission_exists.sql.epp) both correctly set @permission. This is the same class of bug as #464 / #500 which fixed the login permission template.
Fix
Add the missing SET @permission = '<%= $permission %>'; line in the query template, matching the create template.
- 主要语言
- Ruby
- 星标
- 5
- 派生
- 23
- 平均合并
- 3 小时 17 分钟
- 30 天内合并 PR
- 1
环境准备
在浏览器里用你自己的 GitHub 账号启动这个项目的开发容器。
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
puppetlabs/puppetlabs-sqlserver 的其他 Issue
-
Paramter as_sysadmin_accounts does not behave in the same way as sql_sysadmin_accounts可能已有人在做 @jst-cyr 于 49 天前认领。 未关闭bugfix community
难度 2/5 1-3 小时 新手友好度 72/100
puppetlabs/puppetlabs-sqlserver#505 · 1 条评论 · 2 个 reaction ·
-
community
难度 5/5 一周以上 新手友好度 25/100
puppetlabs/puppetlabs-sqlserver#465 · 1 个 reaction ·
-
community
难度 3/5 1-2 天 新手友好度 45/100
-
bugfix community
难度 4/5 3-5 天 新手友好度 35/100
puppetlabs/puppetlabs-sqlserver#427 · 4 条评论 · 2 个 reaction ·
查看 puppetlabs/puppetlabs-sqlserver 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 62/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 76/100
voxpupuli/puppet-archive#566 ·
-
area/tech debt
难度 2/5 1-3 小时 新手友好度 77/100
维护者通常 2 天内回复
-
verified
难度 2/5 1-3 小时 新手友好度 67/100
维护者通常 5 天内回复
-
难度 1/5 1 小时以内 新手友好度 86/100
akitaonrails/ai-book-2026#10 ·