Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

azure_rm_availabilityset: fix checkmode support #627

Merged
merged 4 commits into from
Feb 11, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions plugins/modules/azure_rm_availabilityset.py
Original file line number Diff line number Diff line change
Expand Up @@ -286,15 +286,19 @@ def exec_module(self, **kwargs):
self.faildeploy('sku')

if self.check_mode:
self.results['changed'] = to_be_updated
return self.results

if to_be_updated:
self.results['state'] = self.create_or_update_availabilityset()
self.results['changed'] = True

elif self.state == 'absent':
self.delete_availabilityset()
self.results['changed'] = True
response = self.get_availabilityset()
if response:
if not self.check_mode:
self.delete_availabilityset()
self.results['changed'] = True

return self.results

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
- name: Create an availability set with default options - Check Mode
azure_rm_availabilityset:
name: myavailabilityset1
resource_group: "{{ resource_group }}"
tags:
tag1: testtag
register: results
check_mode: yes

- assert:
that: results.changed

- name: Create an availability set with default options
azure_rm_availabilityset:
name: myavailabilityset1
Expand Down Expand Up @@ -113,7 +125,7 @@

- assert:
that:
- not results.changed
- results.changed
- results.state.tags.checktest1 == 'modified1'

#
Expand All @@ -134,13 +146,34 @@
- results.ansible_info.azure_availabilitysets[0].sku == 'Aligned'
- results.ansible_info.azure_availabilitysets[0].properties.proximityPlacementGroup.id.split('/')[-1] == ppgroup_name

- name: Delete an availability set - Check Mode
azure_rm_availabilityset:
name: myavailabilityset1
resource_group: "{{ resource_group }}"
state: absent
check_mode: yes
register: results
- assert:
that:
- results.changed

- name: Delete an availability set
azure_rm_availabilityset:
name: myavailabilityset1
resource_group: "{{ resource_group }}"
state: absent

- name: Delete an availability set already deleted - Check Mode
azure_rm_availabilityset:
name: myavailabilityset1
resource_group: "{{ resource_group }}"
state: absent
check_mode: yes
register: results
- assert:
that:
- not results.changed

- name: Delete an availability set
azure_rm_availabilityset:
name: myavailabilityset2
Expand Down