-
Notifications
You must be signed in to change notification settings - Fork 337
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Identity support to hdinsight cluster
- Loading branch information
Showing
4 changed files
with
200 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 57 additions & 0 deletions
57
tests/integration/targets/azure_rm_hdinsightcluster/tasks/managedidentity.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
- name: Set user managed identity name | ||
ansible.builtin.set_fact: | ||
identity_name: "ansible-test-{{ managed_identity_test_unique }}-identity-{{ managed_identity_unique }}" | ||
|
||
- name: Set user managed identity ID base path | ||
ansible.builtin.set_fact: | ||
base_path: "/subscriptions/{{ azure_subscription_id }}/resourcegroups/{{ resource_group }}" | ||
|
||
- name: Set user managed identity ID | ||
ansible.builtin.set_fact: | ||
identity_id: "{{ base_path }}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{{ identity_name }}" | ||
|
||
- name: Set managed identity ID into the ids list. | ||
ansible.builtin.set_fact: | ||
managed_identity_ids: "{{ managed_identity_ids + [identity_id] }}" | ||
when: managed_identity_action == 'create' | ||
|
||
- name: Create the user managed identity - {{ identity_name }} | ||
azure_rm_resource: | ||
resource_group: "{{ resource_group }}" | ||
provider: ManagedIdentity | ||
resource_type: userAssignedIdentities | ||
resource_name: "{{ identity_name }}" | ||
api_version: "2023-01-31" | ||
body: | ||
location: "{{ managed_identity_location }}" | ||
state: present | ||
when: managed_identity_action == 'create' | ||
|
||
- name: Lookup service principal object id for identity {{ identity_name }} | ||
azure_rm_resource_info: | ||
api_version: "2023-01-31" | ||
resource_group: "{{ resource_group }}" | ||
provider: ManagedIdentity | ||
resource_type: userAssignedIdentities | ||
resource_name: "{{ identity_name }}" | ||
register: output | ||
when: | ||
- access_policies_object_ids is defined | ||
- managed_identity_action == 'create' | ||
|
||
- name: Set object ID for identity {{ identity_name }} | ||
ansible.builtin.set_fact: | ||
access_policies_object_ids: "{{ access_policies_object_ids + [output.response[0].properties.principalId] }}" | ||
when: | ||
- access_policies_object_ids is defined | ||
- managed_identity_action == 'create' | ||
|
||
- name: Destroy the user managed identity - {{ identity_name }} | ||
azure_rm_resource: | ||
resource_group: "{{ resource_group }}" | ||
provider: ManagedIdentity | ||
resource_type: userAssignedIdentities | ||
resource_name: "{{ identity_name }}" | ||
api_version: "2023-01-31" | ||
state: absent | ||
when: managed_identity_action == 'delete' |