2018-03-22 04:58:28 +01:00
|
|
|
- name: Fix resource prefix
|
|
|
|
set_fact:
|
2019-04-08 05:05:21 +02:00
|
|
|
fixed_resource_prefix: "{{ resource_group | hash('md5') | truncate(7, True, '') }}{{ 1000 | random }}"
|
|
|
|
|
|
|
|
- name: Fix resource prefix
|
|
|
|
set_fact:
|
|
|
|
funcapp_name_basic: "fa{{ fixed_resource_prefix }}basic"
|
|
|
|
funcapp_name_container: "fa{{ fixed_resource_prefix }}container"
|
|
|
|
funcapp_name_params: "fa{{ fixed_resource_prefix }}params"
|
|
|
|
storage_account_name: "sa{{ fixed_resource_prefix }}"
|
|
|
|
plan_name: "ap{{ fixed_resource_prefix }}"
|
2018-03-22 04:58:28 +01:00
|
|
|
|
2017-08-30 03:54:58 +02:00
|
|
|
- name: create storage account for function apps
|
|
|
|
azure_rm_storageaccount:
|
|
|
|
resource_group: '{{ resource_group }}'
|
2019-04-08 05:05:21 +02:00
|
|
|
name: "{{ storage_account_name }}"
|
2017-08-30 03:54:58 +02:00
|
|
|
account_type: Standard_LRS
|
|
|
|
|
|
|
|
- name: create basic function app
|
|
|
|
azure_rm_functionapp:
|
2019-04-08 05:05:21 +02:00
|
|
|
resource_group: "{{ resource_group }}"
|
|
|
|
name: "{{ funcapp_name_basic }}"
|
|
|
|
storage_account: "{{ storage_account_name }}"
|
2017-08-30 03:54:58 +02:00
|
|
|
register: output
|
|
|
|
|
|
|
|
- name: assert the function was created
|
|
|
|
assert:
|
|
|
|
that: output.changed
|
|
|
|
|
|
|
|
- name: list facts for function
|
2019-08-29 11:00:45 +02:00
|
|
|
azure_rm_functionapp_info:
|
2017-08-30 03:54:58 +02:00
|
|
|
resource_group: '{{ resource_group }}'
|
2019-04-08 05:05:21 +02:00
|
|
|
name: "{{ funcapp_name_basic }}"
|
2017-12-07 18:41:19 +01:00
|
|
|
register: results
|
2017-08-30 03:54:58 +02:00
|
|
|
|
|
|
|
- name: assert the facts were retrieved
|
|
|
|
assert:
|
2017-12-07 18:41:19 +01:00
|
|
|
that:
|
2019-08-29 11:00:45 +02:00
|
|
|
- results.ansible_info.azure_functionapps|length == 1
|
|
|
|
- results.ansible_info.azure_functionapps[0].name == "{{ funcapp_name_basic }}"
|
2017-08-30 03:54:58 +02:00
|
|
|
|
|
|
|
- name: delete basic function app
|
|
|
|
azure_rm_functionapp:
|
|
|
|
resource_group: '{{ resource_group }}'
|
2019-04-08 05:05:21 +02:00
|
|
|
name: "{{ funcapp_name_basic }}"
|
2017-08-30 03:54:58 +02:00
|
|
|
state: absent
|
|
|
|
register: output
|
|
|
|
|
|
|
|
- name: assert the function was deleted
|
|
|
|
assert:
|
|
|
|
that: output.changed
|
|
|
|
|
|
|
|
- name: create a function with app settings
|
|
|
|
azure_rm_functionapp:
|
|
|
|
resource_group: '{{ resource_group }}'
|
2019-04-08 05:05:21 +02:00
|
|
|
name: "{{ funcapp_name_params }}"
|
|
|
|
storage_account: "{{ storage_account_name }}"
|
2017-08-30 03:54:58 +02:00
|
|
|
app_settings:
|
|
|
|
hello: world
|
|
|
|
things: more stuff
|
2019-04-01 10:50:08 +02:00
|
|
|
FUNCTIONS_EXTENSION_VERSION: "~2"
|
2017-08-30 03:54:58 +02:00
|
|
|
register: output
|
|
|
|
|
|
|
|
- name: assert the function with app settings was created
|
|
|
|
assert:
|
|
|
|
that: output.changed
|
|
|
|
|
|
|
|
- name: change app settings
|
|
|
|
azure_rm_functionapp:
|
|
|
|
resource_group: '{{ resource_group }}'
|
2019-04-08 05:05:21 +02:00
|
|
|
name: "{{ funcapp_name_params }}"
|
|
|
|
storage_account: "{{ storage_account_name }}"
|
2017-08-30 03:54:58 +02:00
|
|
|
app_settings:
|
|
|
|
hello: world
|
|
|
|
things: more stuff
|
2019-04-01 10:50:08 +02:00
|
|
|
FUNCTIONS_EXTENSION_VERSION: "~2"
|
2017-08-30 03:54:58 +02:00
|
|
|
another: one
|
|
|
|
register: output
|
|
|
|
|
|
|
|
- name: assert the function was changed
|
|
|
|
assert:
|
|
|
|
that: output.changed
|
|
|
|
|
|
|
|
- name: delete the function app
|
|
|
|
azure_rm_functionapp:
|
|
|
|
resource_group: '{{ resource_group }}'
|
2019-04-08 05:05:21 +02:00
|
|
|
name: "{{ funcapp_name_params }}"
|
2017-08-30 03:54:58 +02:00
|
|
|
state: absent
|
|
|
|
register: output
|
|
|
|
|
|
|
|
- name: assert the function was deleted
|
|
|
|
assert:
|
|
|
|
that: output.changed
|
|
|
|
|
2019-04-08 05:05:21 +02:00
|
|
|
- name: Create a linux app service plan
|
|
|
|
azure_rm_appserviceplan:
|
|
|
|
resource_group: "{{ resource_group }}"
|
|
|
|
name: "{{ plan_name }}"
|
|
|
|
sku: S1
|
|
|
|
is_linux: true
|
|
|
|
number_of_workers: 1
|
|
|
|
|
|
|
|
- name: "Create azure function app {{ function_app }}"
|
|
|
|
azure_rm_functionapp:
|
|
|
|
resource_group: "{{ resource_group }}"
|
|
|
|
name: "{{ funcapp_name_container }}"
|
|
|
|
storage_account: "{{ storage_account_name }}"
|
|
|
|
plan:
|
|
|
|
resource_group: "{{ resource_group }}"
|
|
|
|
name: "{{ plan_name }}"
|
|
|
|
container_settings:
|
|
|
|
name: httpd
|
|
|
|
app_settings:
|
|
|
|
FUNCTIONS_EXTENSION_VERSION: "~2"
|
|
|
|
register: output
|
|
|
|
|
|
|
|
- name: assert the function was changed
|
|
|
|
assert:
|
|
|
|
that: output.changed
|
|
|
|
|
|
|
|
- name: delete the function app
|
|
|
|
azure_rm_functionapp:
|
|
|
|
resource_group: '{{ resource_group }}'
|
|
|
|
name: "{{ funcapp_name_container }}"
|
|
|
|
state: absent
|
|
|
|
|
2017-08-30 03:54:58 +02:00
|
|
|
- name: delete storage account
|
|
|
|
azure_rm_storageaccount:
|
|
|
|
resource_group: '{{ resource_group }}'
|
2019-04-08 05:05:21 +02:00
|
|
|
name: "{{ storage_account_name }}"
|
2017-08-30 03:54:58 +02:00
|
|
|
state: absent
|