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

Correct idempotency for azure_rm_appserviceplan and premium SKU plans #693

Merged
merged 2 commits into from
Nov 23, 2021
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
2 changes: 1 addition & 1 deletion plugins/modules/azure_rm_appserviceplan.py
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ def exec_module(self, **kwargs):
self.tags = newtags

# check if sku changed
if self.sku and _normalize_sku(self.sku) != old_response['sku']['size']:
if self.sku and _normalize_sku(self.sku) != _normalize_sku(old_response['sku']['size']):
to_be_updated = True

# check if number_of_workers changed
Expand Down
38 changes: 35 additions & 3 deletions tests/integration/targets/azure_rm_appserviceplan/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
- name: Prepare facts
set_fact:
resource_prefix: "{{ resource_group_secondary | hash('md5') | truncate(7, True, '') }}{{ 1000 | random }}"
run_once: yes

- name: Prepare facts
set_fact:
linux_plan_resource_group: "{{ resource_group_secondary }}"
win_plan_name: "{{ (resource_prefix | replace('-','x'))[-8:] }}winplan"
linux_plan_name: "{{ (resource_prefix | replace('-','x'))[-8:] }}linplan"
run_once: yes

- name: create a windows plan
azure_rm_appserviceplan:
Expand All @@ -13,7 +19,7 @@

- name: assert app service was created
assert:
that:
that:
- output.changed
- output.id

Expand All @@ -28,7 +34,7 @@

- name: assert app service was created
assert:
that:
that:
- output.changed
- output.id

Expand All @@ -53,7 +59,7 @@
number_of_workers: 1
register: output

- name: assert app service was created
- name: assert app service is not updated
assert:
that: not output.changed

Expand Down Expand Up @@ -82,3 +88,29 @@
assert:
that:
- output.changed

- name: create premium linux plan
azure_rm_appserviceplan:
resource_group: "{{ linux_plan_resource_group }}"
name: "{{ linux_plan_name }}-premium"
sku: P1v2
is_linux: true
register: output

- name: assert app service was created
assert:
that:
- output.changed
- output.id

- name: create premium linux plan idempotent
azure_rm_appserviceplan:
resource_group: "{{ linux_plan_resource_group }}"
name: "{{ linux_plan_name }}-premium"
sku: P1v2
is_linux: true
register: output

- name: assert app service is not updated
assert:
that: not output.changed