gpt4 book ai didi

salt-stack - 在 SaltStack SLS 中配置 MongoDB 3 用户角色

转载 作者:行者123 更新时间:2023-12-02 20:57:20 25 4
gpt4 key购买 nike

有没有办法使用 SaltStack for MongoDB 3 配置用户角色?我看到mongodb module具有相关的角色管理功能,但是mongodb_user state没有在任何地方引用角色。

最佳答案

是的,当然有!

您需要使用Mongodb module ,和 execute it from a state using module.run.

例如,如果您想管理用户“TestUser”的角色,您需要创建“manage_mongo_roles.sls”,它将包含如下状态:

manage_mongo_roles:
module.run:
- name: mongodb.user_grant_roles
- m_name: TestUser
- roles: ["admin"]
- database: admin
- user: admin
- password: ''
- host: localhost
- port: 27017

模块的“名称”参数必须以 m_ 开头,以便状态知道将其传递给模块,而不是将其用作要执行的模块的名称。

另请注意,角色必须采用以下格式

["role"]

文档表明,如果从 salt CLI 运行,它应该包含在单引号中,如下所示:

'["role"]'

但是在 module.run 状态下这样做会导致它失败,并返回一条缺乏描述性的错误消息。

关于salt-stack - 在 SaltStack SLS 中配置 MongoDB 3 用户角色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39793152/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com