这是我的代码rolename/tasks/main.yml
:
- name: CREATE KEYVAULT INSTANCE
azure_rm_keyvault:
client_id: "{{ AZURE_CLIENT_ID }}"
secret: "{{ AZURE_CLIENT_SECRET }}"
tenant: "{{ AZURE_TENANT_ID }}"
vault_tenant: "{{ AZURE_TENANT_ID }}"
subscription_id: "{{ AZURE_SUBSCRIPTION_ID }}"
vault_name: "{{ AZURE_KEYVAULT_NAME }}"
sku:
name: "{{ SKU_NAME }}"
resource_group: "{{ RESOURCEGROUP_NAME }}"
access_policies:
- application_id: "{{ AZURE_CLIENT_ID }}"
object_id: "{{ AZURE_OBJECT_ID }}"
tenant_id: "{{ AZURE_TENANT_ID }}"
keys:
- encrypt
- decrypt
- get
- list
- create
- update
- delete
secrets:
- get
- list
- set
- delete
# WANT TO LOOP FROM HERE <---------------
- object_id: aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaa
secrets:
- get
- list
- set
- delete
- object_id: bbbbbbbb-bbbb-bbbb-bbbb-bbbbbbbbbbbb
secrets:
- get
- list
- set
- delete
# AND LOOP UNTIL HERE ONLY <---------------
在代码中,我已经标记了要为不同的对象ID 循环的部分,以便不必为不同的object_id
重复相同的内容。我无法使用with_items
,因为这将重新运行模块,其次数将与项目数相同。可以为标记的部分编写某种for循环吗?
(模块中的object_id
仅接受字符串,因此不能为object_id
使用列表。)
谢谢。