|
| 1 | +# Description |
| 2 | +# =========== |
| 3 | +# This playbook creates |
| 4 | +# - An Azure Linux Web app with Java container Tomcat 8.5. |
| 5 | +# - An Azure Traffic manager profile. |
| 6 | +# - Add the web site created as an endpoint of the Traffic Manager Profile. |
| 7 | +# |
| 8 | +# This playbook requires Ansible version >=2.7, or you could use role Azure.azure_preview_modules |
| 9 | +# If you're using Ansible >=2.7, just remove the role lines. |
| 10 | + |
| 11 | +- hosts: localhost |
| 12 | + connection: local |
| 13 | + vars: |
| 14 | + app_name: testapp0917 |
| 15 | + location: eastus |
| 16 | + linux_plan_name: testplan0917 |
| 17 | + traffic_manager_profile_name: profile0917 |
| 18 | + traffic_manager_endpoint_name: endpoint1 |
| 19 | + |
| 20 | + roles: |
| 21 | + - Azure.azure_preview_modules |
| 22 | + |
| 23 | + tasks: |
| 24 | + - name: Create resource group |
| 25 | + azure_rm_resourcegroup: |
| 26 | + name: "{{ resource_group_name }}" |
| 27 | + location: "{{ location }}" |
| 28 | + |
| 29 | + - name: Create resource group for app service plan |
| 30 | + azure_rm_resourcegroup: |
| 31 | + name: "{{ resource_group_name }}2nd" |
| 32 | + location: "{{ location }}" |
| 33 | + |
| 34 | + - name: Create App Service Plan |
| 35 | + azure_rm_appserviceplan: |
| 36 | + resource_group: "{{ resource_group_name }}2nd" |
| 37 | + name: "{{ linux_plan_name }}" |
| 38 | + location: "{{ location }}" |
| 39 | + is_linux: true |
| 40 | + sku: S1 |
| 41 | + number_of_workers: 1 |
| 42 | + |
| 43 | + - name: Create a Linux web app with Java framework and Tomcat |
| 44 | + azure_rm_webapp: |
| 45 | + resource_group: "{{ resource_group_name }}" |
| 46 | + name: "{{ app_name }}" |
| 47 | + plan: |
| 48 | + resource_group: "{{ resource_group_name }}2nd" |
| 49 | + name: "{{ linux_plan_name }}" |
| 50 | + app_settings: |
| 51 | + testkey: "testvalue" |
| 52 | + frameworks: |
| 53 | + - name: java |
| 54 | + version: 8 |
| 55 | + settings: |
| 56 | + java_container: "Tomcat" |
| 57 | + java_container_version: "8.5" |
| 58 | + |
| 59 | + - name: Get web app facts |
| 60 | + azure_rm_webapp_facts: |
| 61 | + resource_group: "{{ resource_group_name }}" |
| 62 | + name: "{{ app_name }}" |
| 63 | + return_publish_profile: true |
| 64 | + register: webapp |
| 65 | + |
| 66 | + - name: Create Traffic Manager Profile |
| 67 | + azure_rm_trafficmanagerprofile: |
| 68 | + resource_group: "{{ resource_group_name }}" |
| 69 | + name: "{{ traffic_manager_profile_name }}" |
| 70 | + location: global |
| 71 | + routing_method: performance |
| 72 | + dns_config: |
| 73 | + relative_name: "{{ traffic_manager_profile_name }}" |
| 74 | + ttl: 60 |
| 75 | + monitor_config: |
| 76 | + protocol: HTTPS |
| 77 | + port: 80 |
| 78 | + path: '/' |
| 79 | + |
| 80 | + - name: Add endpoint to traffic manager profile, using the web site created above |
| 81 | + azure_rm_trafficmanagerendpoint: |
| 82 | + resource_group: "{{ resource_group_name }}" |
| 83 | + profile_name: "{{ traffic_manager_profile_name }}" |
| 84 | + name: "{{ traffic_manager_endpoint_name }}" |
| 85 | + type: azure_endpoints |
| 86 | + location: "{{ location }}" |
| 87 | + target_resource_id: "{{ webapp.webapps[0].id }}" |
| 88 | + |
| 89 | + - name: Get Traffic Manager Profile facts |
| 90 | + azure_rm_trafficmanagerprofile_facts: |
| 91 | + resource_group: "{{ resource_group_name }}" |
| 92 | + name: "{{ traffic_manager_profile_name }}" |
0 commit comments