You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

IBM Cloud Secrets Manager API能否批量创建密钥组?Ansible调用报错

关于IBM Cloud Secrets Manager(CSM)批量创建密钥组的API限制问题

我在编写针对IBM Cloud Secrets Manager(CSM)API的Ansible Playbook,目标是批量创建密钥组。按照API文档给出的格式构造请求体:将密钥组列表长度传入collection_total参数,resources字段中包含24个密钥组对象(因迁移需求,description暂用name填充),每个对象格式为{ 'name': group_name, 'description': group_description}。

通过Ansible verbose模式验证的请求体内容如下:

"invocation": {
    "module_args": {
        "attributes": null,
        "body": {
            "metadata": {
                "collection_total": 24,
                "collection_type": "application/vnd.ibm.secrets-manager.secret.group+json"
            },
            "resources": [
                {
                    "description": "fail-safe-credentials",
                    "name": "fail-safe-credentials"
                },
                {
                    "description": "ebgp-password",
                    "name": "ebgp-password"
                }
                // 完整列表包含24条数据,此处省略剩余22条
            ]
        }
    }
}

对应的Ansible任务代码:

- name: Create new groups in CSM
  ansible.builtin.uri:
    url: "{{ csm_vault_url }}/api/v1/secret_groups"
    headers:
      Content-Type: application/json
      Authorization: "Bearer {{ iam_token }}"
    method: POST
    body_format: json
    body:
      metadata:
        collection_type: application/vnd.ibm.secrets-manager.secret.group+json
        collection_total: "{{ group_info.new | length }}"
      resources: "{{ group_info.new }}"
  register: created_groups
  tags: csm

执行Playbook时返回错误:

"json": {
    "errors": [
        {
            "code": "secrets-manager.00023E",
            "message": "You can create only one secret group at a time."
        }
    ]
}

疑问与后续方案

  • 官方API文档未明确说明该接口仅支持单次创建一个密钥组,需确认此是否为预期行为。
  • 若该限制属实,建议更新API文档:要么明确标注批量创建不被支持,要么移除易误导用户的collection_total参数。
  • 当前计划通过循环调用API,逐个创建所有24个密钥组。

内容的提问来源于stack exchange,提问作者Scott Strattner

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.28 03:35:42