- name: Fix resource prefix set_fact: redis_name: "{{ (resource_group | replace('-','x'))[-8:] }}{{ 1000 | random }}redis" vnet_name: "{{ (resource_group | replace('-','x'))[-8:] }}{{ 1000 | random }}vnet" subnet_name: "{{ (resource_group | replace('-','x'))[-8:] }}{{ 1000 | random }}subnet" run_once: yes - name: Create a redis cache (Check Mode) azure_rm_rediscache: resource_group: "{{ resource_group }}" name: "{{ redis_name }}" sku: name: basic size: C1 check_mode: yes register: output - name: Assert creating redis cache check mode assert: that: - output.changed - name: Create a redis cache azure_rm_rediscache: resource_group: "{{ resource_group }}" name: "{{ redis_name }}" sku: name: basic size: C1 register: output - name: Assert creating redis cache check mode assert: that: - output.changed - output.id - name: Update the redis cache (idempotent) azure_rm_rediscache: resource_group: "{{ resource_group }}" name: "{{ redis_name }}" sku: name: basic size: C1 register: output - name: assert output not changed assert: that: - not output.changed # creating redis Cache costs about 20 mins async operation, # need to poll status from Creating to Running, then able to perform updating/deleting operation, # otherwise, will met error: # "The resource '' is busy processing a previous update request or is undergoing system maintenance. # As such, it is currently unable to accept the update request. Please try again later." # comment out updating/deleting tests for test efficiency. # - name: Update redis cache # azure_rm_rediscache: # resource_group: "{{ resource_group }}" # name: "{{ redis_name }}" # sku: # name: basic # size: C1 # enable_non_ssl_port: true # tags: # testing: foo # register: output # - name: assert output changed # assert: # that: # - output.changed # - name: Update redis cache configuration # azure_rm_rediscache: # resource_group: "{{ resource_group }}" # name: "{{ redis_name }}" # sku: # name: basic # size: C1 # enable_non_ssl_port: true # maxmemory_policy: allkeys_lru # tags: # testing: foo # register: output # - name: assert output changed # assert: # that: # - output.changed # - name: Scale up the redis cache # azure_rm_rediscache: # resource_group: "{{ resource_group }}" # name: "{{ redis_name }}" # sku: # name: standard # size: C1 # tags: # testing: foo # register: output # - assert: # that: # - output.changed # - name: Delete the redis cache (Check Mode) # azure_rm_rediscache: # resource_group: "{{ resource_group }}" # name: "{{ redis_name }}" # state: absent # check_mode: yes # register: output # - name: assert deleting redis cache check mode # assert: # that: output.changed # - name: Delete the redis cache # azure_rm_rediscache: # resource_group: "{{ resource_group }}" # name: "{{ redis_name }}" # state: absent # register: output # - assert: # that: # - output.changed - name: Create virtual network azure_rm_virtualnetwork: resource_group: "{{ resource_group }}" name: "{{ vnet_name }}" address_prefixes: "10.10.0.0/16" - name: Add subnet azure_rm_subnet: resource_group: "{{ resource_group }}" name: "{{ subnet_name }}" address_prefix: "10.10.0.0/24" virtual_network: "{{ vnet_name }}" - name: Create redis with subnet azure_rm_rediscache: resource_group: "{{ resource_group }}" name: "{{ redis_name }}2" sku: name: premium size: P1 subnet: name: "{{ subnet_name }}" virtual_network_name: "{{ vnet_name }}" register: output - name: Assert creating redis cache assert: that: - output.changed - output.id # - name: Delete the redis cache # azure_rm_rediscache: # resource_group: "{{ resource_group }}" # name: "{{ redis_name }}2" # state: absent # register: output