azure
azure copied to clipboard
azure_rm_adserviceprincipal_info returns a empty list
SUMMARY
I'm trying to do the equivalent of this az ad sp list --filter "displayname eq 'Azure Red Hat OpenShift RP'" --query "[?appDisplayName=='Azure Red Hat OpenShift RP'].{objectId: objectId}" -o tsv
.
however when I run the following I get an empty list .. which means I can't use a jmesquery or similar to find the correct service principal.
- name: list service principals
azure.azcollection.azure_rm_adserviceprincipal_info:
tenant: "{{ azr_tenant_id }}"
register: _sp
@paulczar In this module, if you want to obtain AD SP information, at least one app_id or object_id should be configured. Can you try it on? Thank you very much!
- name: list service principals
azure.azcollection.azure_rm_adserviceprincipal_info:
tenant: "{{ azr_tenant_id }}"
app_id: "{{ app_id }}"
register: _sp
or
- name: list service principals
azure.azcollection.azure_rm_adserviceprincipal_info:
tenant: "{{ azr_tenant_id }}"
object_id: "{{ obuect_id }}"
register: _sp
Here's the problem though, I don't know the app_id or object_id. The scenario is that I want to see if a SP already exists (to ensure creating one is idempotent, but also to determine what to delete when I want to clean up my environment).
I want to be able to do something like this (ignore the syntax errors):
- name: list service principals
azure.azcollection.azure_rm_adserviceprincipal_info:
tenant: "{{ azr_tenant_id }}"
filter: "displayname eq 'Azure Red Hat OpenShift RP'"
register: _sp
- name: delete ARO service principals
azure.azcollection.azure_rm_adserviceprincipal:
tenant: "{{ azr_tenant_id }}"
app_id: "{{ item.app_id }}"
with_items: _sp.serviceprincipals
@paulczar This is a good suggestion and we will discuss internally whether to add filter or return all service pricipals under tenant_id. Thank you very much!
#1325 Fixes