ansible.builtin.azure_rm_webapp (v2.8.19) — module

Manage Web App instance.

| "added in version" 2.7 of ansible.builtin"

Authors: Yunge Zhu (@yungezz)

preview | supported by community

Install Ansible via pip

Install with pip install ansible==2.8.19

Description

Create, update and delete instance of Web App.


Requirements

Usage examples

  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
    - name: Create a windows web app with non-exist app service plan
      azure_rm_webapp:
        resource_group: myresourcegroup
        name: mywinwebapp
        plan:
          resource_group: myappserviceplan_rg
          name: myappserviceplan
          is_linux: false
          sku: S1
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
    - name: Create a docker web app with some app settings, with docker image
      azure_rm_webapp:
        resource_group: myresourcegroup
        name: mydockerwebapp
        plan:
          resource_group: appserviceplan_test
          name: myappplan
          is_linux: true
          sku: S1
          number_of_workers: 2
        app_settings:
          testkey: testvalue
          testkey2: testvalue2
        container_settings:
          name: ansible/ansible:ubuntu1404
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
    - name: Create a docker web app with private acr registry
      azure_rm_webapp:
        resource_group: myresourcegroup
        name: mydockerwebapp
        plan: myappplan
        app_settings:
          testkey: testvalue
        container_settings:
          name: ansible/ubuntu1404
          registry_server_url: myregistry.io
          registry_server_user: user
          registry_server_password: pass
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
    - name: Create a linux web app with Node 6.6 framework
      azure_rm_webapp:
        resource_group: myresourcegroup
        name: mylinuxwebapp
        plan:
          resource_group: appserviceplan_test
          name: myappplan
        app_settings:
          testkey: testvalue
        frameworks:
          - name: "node"
            version: "6.6"
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
    - name: Create a windows web app with node, php
      azure_rm_webapp:
        resource_group: myresourcegroup
        name: mywinwebapp
        plan:
          resource_group: appserviceplan_test
          name: myappplan
        app_settings:
          testkey: testvalue
        frameworks:
          - name: "node"
            version: 6.6
          - name: "php"
            version: "7.0"
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
    - name: Create a stage deployment slot for an existing web app
      azure_rm_webapp:
        resource_group: myresourcegroup
        name: mywebapp/slots/stage
        plan:
          resource_group: myresourcegroup
          name: myappplan
        app_settings:
          testkey:testvalue
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
    - name: Create a linux web app with java framework
      azure_rm_webapp:
        resource_group: myresourcegroup
        name: mylinuxwebapp
        plan:
          resource_group: appserviceplan_test
          name: myappplan
        app_settings:
          testkey: testvalue
        frameworks:
          - name: "java"
            version: "8"
            settings:
              java_container: "Tomcat"
              java_container_version: "8.5"

Inputs

    
name:
    description:
    - Unique name of the app to create or update. To create or update a deployment slot,
      use the {slot} parameter.
    required: true

plan:
    description:
    - App service plan. Required for creation.
    - It can be name of existing app service plan in same resource group as web app.
    - It can be resource id of existing app service plan. eg., /subscriptions/<subs_id>/resourceGroups/<resource_group>/providers/Microsoft.Web/serverFarms/<plan_name>
    - It can be a dict which contains C(name), C(resource_group), C(sku), C(is_linux)
      and C(number_of_workers).
    - C(name). Name of app service plan.
    - C(resource_group). Resource group name of app service plan.
    - C(sku). SKU of app service plan. For allowed sku, please refer to U(https://azure.microsoft.com/en-us/pricing/details/app-service/linux/).
    - C(is_linux). Indicates Linux app service plan. type bool. default False.
    - C(number_of_workers). Number of workers.

tags:
    description:
    - Dictionary of string:string pairs to assign as metadata to the object.
    - Metadata tags on the object will be updated with any provided values.
    - To remove tags set append_tags option to false.
    - Currently, Azure DNS zones and Traffic Manager services also don't allow the use
      of spaces in the tag.
    - Azure Front Door doesn't support the use of
    - Azure Automation and Azure CDN only support 15 tags on resources.
    type: dict

state:
    choices:
    - absent
    - present
    default: present
    description:
    - Assert the state of the Web App.
    - Use C(present) to create or update a Web App and C(absent) to delete it.

secret:
    description:
    - Azure client secret. Use when authenticating with a Service Principal.
    type: str

tenant:
    description:
    - Azure tenant ID. Use when authenticating with a Service Principal.
    type: str

ad_user:
    description:
    - Active Directory username. Use when authenticating with an Active Directory user
      rather than service principal.
    type: str

profile:
    description:
    - Security profile found in ~/.azure/credentials file.
    type: str

location:
    description:
    - Resource location. If not set, location from the resource group will be used as
      default.

log_mode:
    description:
    - Parent argument.
    type: str

log_path:
    description:
    - Parent argument.
    type: str

password:
    description:
    - Active Directory user password. Use when authenticating with an Active Directory
      user rather than service principal.
    type: str

scm_type:
    description:
    - Repository type of deployment source. Eg. LocalGit, GitHub.
    - Please see U(https://docs.microsoft.com/en-us/rest/api/appservice/webapps/createorupdate#scmtype)
      for more info.

app_state:
    choices:
    - started
    - stopped
    - restarted
    default: started
    description:
    - Start/Stop/Restart the web app.
    type: str

client_id:
    description:
    - Azure client ID. Use when authenticating with a Service Principal.
    type: str

frameworks:
    description:
    - Set of run time framework settings. Each setting is a dictionary.
    - See U(https://docs.microsoft.com/en-us/azure/app-service/app-service-web-overview)
      for more info.
    suboptions:
      name:
        choices:
        - java
        - net_framework
        - php
        - python
        - ruby
        - dotnetcore
        - node
        description:
        - Name of the framework.
        - Supported framework list for Windows web app and Linux web app is different.
        - For Windows web app, supported names(June 2018) java, net_framework, php, python,
          node. Multiple framework can be set at same time.
        - For Linux web app, supported names(June 2018) java, ruby, php, dotnetcore, node.
          Only one framework can be set.
        - Java framework is mutually exclusive with others.
      settings:
        description:
        - List of settings of the framework.
        suboptions:
          java_container:
            description: Name of Java container. This is supported by specific framework
              C(java) only. e.g. Tomcat, Jetty.
          java_container_version:
            description:
            - Version of Java container. This is supported by specific framework C(java)
              only.
            - For Tomcat, e.g. 8.0, 8.5, 9.0. For Jetty, e.g. 9.1, 9.3.
      version:
        description:
        - Version of the framework. For Linux web app supported value, see U(https://aka.ms/linux-stacks)
          for more info.
        - net_framework supported value sample, 'v4.0' for .NET 4.6 and 'v3.0' for .NET
          3.5.
        - php supported value sample, 5.5, 5.6, 7.0.
        - python supported value sample, e.g., 5.5, 5.6, 7.0.
        - node supported value sample, 6.6, 6.9.
        - dotnetcore supported value sample, 1.0, 1,1, 1.2.
        - ruby supported value sample, 2.3.
        - java supported value sample, 1.8, 1.9 for windows web app. 8 for linux web app.

https_only:
    description:
    - Configures web site to accept only https requests.
    type: bool

thumbprint:
    description:
    - The thumbprint of the private key specified in I(x509_certificate_path).
    - Use when authenticating with a Service Principal.
    - Required if I(x509_certificate_path) is defined.
    type: str
    version_added: 1.14.0
    version_added_collection: azure.azcollection

api_profile:
    default: latest
    description:
    - Selects an API profile to use when communicating with Azure services. Default value
      of C(latest) is appropriate for public clouds; future values will allow use with
      Azure Stack.
    type: str
    version_added: 0.0.1
    version_added_collection: azure.azcollection

append_tags:
    default: true
    description:
    - Use to control if tags field is canonical or just appends to existing tags.
    - When canonical, any tags not found in the tags parameter will be removed from the
      object's metadata.
    type: bool

auth_source:
    choices:
    - auto
    - cli
    - credential_file
    - env
    - msi
    default: auto
    description:
    - Controls the source of the credentials to use for authentication.
    - Can also be set via the C(ANSIBLE_AZURE_AUTH_SOURCE) environment variable.
    - When set to C(auto) (the default) the precedence is module parameters -> C(env)
      -> C(credential_file) -> C(cli).
    - When set to C(env), the credentials will be read from the environment variables
    - When set to C(credential_file), it will read the profile from C(~/.azure/credentials).
    - When set to C(cli), the credentials will be sources from the Azure CLI profile.
      C(subscription_id) or the environment variable C(AZURE_SUBSCRIPTION_ID) can be used
      to identify the subscription ID if more than one is present otherwise the default
      az cli subscription is used.
    - When set to C(msi), the host machine must be an azure resource with an enabled MSI
      extension. C(subscription_id) or the environment variable C(AZURE_SUBSCRIPTION_ID)
      can be used to identify the subscription ID if the resource is granted access to
      more than one subscription, otherwise the first subscription is chosen.
    - The C(msi) was added in Ansible 2.6.
    type: str
    version_added: 0.0.1
    version_added_collection: azure.azcollection

app_settings:
    description:
    - Configure web app application settings. Suboptions are in key value pair format.

startup_file:
    description:
    - The web's startup file.
    - This only applies for linux web app.

resource_group:
    description:
    - Name of the resource group to which the resource belongs.
    required: true

ttl_in_seconds:
    description:
    - Time to live in seconds for web app default domain name.

subscription_id:
    description:
    - Your Azure subscription Id.
    type: str

dns_registration:
    description:
    - If true web app hostname is not registered with DNS on creation.
    type: bool

cloud_environment:
    default: AzureCloud
    description:
    - For cloud environments other than the US public cloud, the environment name (as
      defined by Azure Python SDK, eg, C(AzureChinaCloud), C(AzureUSGovernment)), or a
      metadata discovery endpoint URL (required for Azure Stack). Can also be set via
      credential file profile or the C(AZURE_CLOUD_ENVIRONMENT) environment variable.
    type: str
    version_added: 0.0.1
    version_added_collection: azure.azcollection

deployment_source:
    description:
    - Deployment source for git
    suboptions:
      branch:
        description:
        - The branch name of the repository.
      url:
        description:
        - Repository url of deployment source.

adfs_authority_url:
    description:
    - Azure AD authority url. Use when authenticating with Username/password, and has
      your own ADFS authority.
    type: str
    version_added: 0.0.1
    version_added_collection: azure.azcollection

container_settings:
    description: Web app container settings.
    suboptions:
      name:
        description: Name of container. eg. "imagename:tag"
      registry_server_password:
        description:
        - The container registry server password.
      registry_server_url:
        description: Container registry server url. eg. mydockerregistry.io
      registry_server_user:
        description: The container registry server user name.

purge_app_settings:
    description:
    - Purge any existing application settings. Replace web app application settings with
      app_settings.
    type: bool

cert_validation_mode:
    choices:
    - ignore
    - validate
    description:
    - Controls the certificate validation behavior for Azure endpoints. By default, all
      modules will validate the server certificate, but when an HTTPS proxy is in use,
      or against Azure Stack, it may be necessary to disable this behavior by passing
      C(ignore). Can also be set via credential file profile or the C(AZURE_CERT_VALIDATION)
      environment variable.
    type: str
    version_added: 0.0.1
    version_added_collection: azure.azcollection

x509_certificate_path:
    description:
    - Path to the X509 certificate used to create the service principal in PEM format.
    - The certificate must be appended to the private key.
    - Use when authenticating with a Service Principal.
    type: path
    version_added: 1.14.0
    version_added_collection: azure.azcollection

client_affinity_enabled:
    default: true
    description:
    - True to enable client affinity; False to stop sending session affinity cookies,
      which route client requests in the same session to the same instance.
    type: bool

skip_custom_domain_verification:
    description:
    - If true, custom (non *.azurewebsites.net) domains associated with web app are not
      verified.
    type: bool

Outputs

azure_webapp:
  description: Id of current web app.
  returned: always
  sample:
    id: /subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroups/myResourceGroup/providers/Microsoft.Web/sites/ansiblewindowsaaa
  type: dict

See also