azure_rm_backuppolicy
Manage Azure Backup Policy
Collection: azure.azcollection
Full Name: azure.azcollection.azure_rm_backuppolicy
Synopsis
Manage Azure Backup Policy
Parameters
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
| ad_user | string | Active Directory username. Use when authenticating with an Active Directory user rather than service principal. | ||
| adfs_authority_url | string | Azure AD authority url. Use when authenticating with Username/password, and has your own ADFS authority. | ||
| api_profile | string | latest | 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. | |
| auth_source | string | auto | 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. | ||||
| backup_management_type | string | Defines the type of resource the policy will be applied to. | ||
| cert_validation_mode | string | 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. | ||
| client_id | string | Azure client ID. Use when authenticating with a Service Principal or Managed Identity (msi). | ||
| Can also be set via the C(AZURE_CLIENT_ID) environment variable. | ||||
| cloud_environment | string | AzureCloud | 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. | |
| daily_retention_count | int | The amount of days to retain backups. | ||
| Does not apply to Weekly frequency. | ||||
| disable_instance_discovery | bool | false | Determines whether or not instance discovery is performed when attempting to authenticate. Setting this to true will completely disable both instance discovery and authority validation. This functionality is intended for use in scenarios where the metadata endpoint cannot be reached such as in private clouds or Azure Stack. The process of instance discovery entails retrieving authority metadata from https://login.microsoft.com/ to validate the authority. By setting this to True, the validation of the authority is disabled. As a result, it is crucial to ensure that the configured authority host is valid and trustworthy. | |
| Set via credential file profile or the C(AZURE_DISABLE_INSTANCE_DISCOVERY) environment variable. | ||||
| instant_recovery_snapshot_retention | int | How many days to retain instant recovery snapshots. | ||
| log_mode | string | Parent argument. | ||
| log_path | string | Parent argument. | ||
| monthly_retention_count | int | The amount of months to retain backups. | ||
| Requires either the I(retention_weekdays)+I(retention_weeks_of_the_month) pair (Weekly format) or the I(retention_days_of_the_month)/I(retention_include_last_day) pair (Daily format). Set one pair; the two pairs are mutually exclusive. | ||||
| months_of_year | list | List of months of the year to retain backups for yearly retention. | ||
| Valid values are full month names (January, February, …). | ||||
| name | string | yes | The name of the backup policy. | |
| oidc_token | string | Direct OpenID Connect (OIDC) token (JWT) used for workload identity authentication. | ||
| This token is exchanged with Azure AD using OIDC federated identity. | ||||
| Useful in CI systems (for example GitHub Actions, Azure DevOps) where an OIDC token is provided directly by the platform. | ||||
| Can also be set via the C(AZURE_FEDERATED_TOKEN) environment variable. | ||||
| oidc_token_file_path | string | Path to a file containing an OpenID Connect (OIDC) token (JWT) used for workload identity authentication. | ||
| The file must contain only raw token. | ||||
| This method is commonly used in platforms that materialize OIDC tokens as files | ||||
| Can also be set via the C(AZURE_FEDERATED_TOKEN_FILE) environment variable. | ||||
| password | string | Active Directory user password. Use when authenticating with an Active Directory user rather than service principal. | ||
| policy_type | string | V1 | Defines the type of backup policy | |
| profile | string | Security profile found in ~/.azure/credentials file. | ||
| resource_group | string | yes | The name of the resource group the vault is in. | |
| retention_days_of_the_month | list | Days of the month to retain monthly/yearly backups on (Daily format). | ||
| Use 1-28 to guarantee the day exists in every month; values 29, 30, and 31 are accepted but the backup is skipped in months that do not have that day. | ||||
| To also retain the last day of every month regardless of length, set I(retention_include_last_day=true). | ||||
| Mutually exclusive with I(retention_weekdays) and I(retention_weeks_of_the_month). | ||||
| retention_include_last_day | bool | false | Include the last day of every month in the Daily-format retention set, regardless of month length. | |
| Use with I(retention_days_of_the_month) (or on its own to retain only the last day of each month). | ||||
| retention_weekdays | list | Days of the week to retain monthly/yearly backups on (Weekly format). | ||
| Use with I(retention_weeks_of_the_month). | ||||
| Mutually exclusive with I(retention_days_of_the_month) and I(retention_include_last_day). | ||||
| retention_weeks_of_the_month | list | Weeks of the month to retain monthly/yearly backups on (Weekly format). | ||
| Valid values are First, Second, Third, Fourth, Last. | ||||
| Use with I(retention_weekdays). | ||||
| schedule_days | list | List of days to execute the schedule. | ||
| Does not apply to Daily frequency. | ||||
| schedule_run_frequency | string | The frequency to run the policy. | ||
| schedule_run_time | int | The hour to run backups. | ||
Valid Choices: on 24 hour scale (0-23). | ||||
| schedule_weekly_frequency | int | The amount of weeks between backups. | ||
| Backup every I(schedule_weekly_frequency) week(s). | ||||
| Azure will default behavior to running weekly if this is left blank. | ||||
| Does not apply to Daily frequency. | ||||
| secret | string | Azure client secret. Use when authenticating with a Service Principal. | ||
| state | string | present | Assert the state of the backup policy. | |
| Use C(present) to create or update a backup policy and C(absent) to delete it. | ||||
| subscription_id | string | Your Azure subscription Id. | ||
| tenant | string | Azure tenant ID. Use when authenticating with a Service Principal. | ||
| thumbprint | string | 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. | ||||
| time_zone | string | UTC | Timezone to apply I(schedule_run_time). | |
| vault_name | string | yes | The name of the Recovery Services Vault the policy belongs to. | |
| weekly_retention_count | int | The amount of weeks to retain backups. | ||
| x509_certificate_path | string | 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. | ||||
| yearly_retention_count | int | The amount of years to retain backups. | ||
| Requires I(months_of_year) and one of the two format pairs described in I(monthly_retention_count). |
Example
yaml
- name: Delete a backup policy
azure.azcollection.azure_rm_backuppolicy:
vault_name: Vault_Name
name: Policy_Name
resource_group: Resource_Group_Name
state: absent
- name: Create a daily VM backup policy
azure.azcollection.azure_rm_backuppolicy:
vault_name: Vault_Name
name: Policy_Name
resource_group: Resource_Group_Name
state: present
backup_management_type: "AzureIaasVM"
schedule_run_frequency: "Daily"
instant_recovery_snapshot_retention: 2
daily_retention_count: 12
time_zone: "Pacific Standard Time"
schedule_run_time: 14
- name: Create a weekly VM backup policy
azure.azcollection.azure_rm_backuppolicy:
vault_name: Vault_Name
name: Policy_Name
resource_group: Resource_Group_Name
state: present
backup_management_type: "AzureIaasVM"
schedule_run_frequency: "Weekly"
instant_recovery_snapshot_retention: 5
weekly_retention_count: 4
schedule_days:
- "Monday"
- "Wednesday"
- "Friday"
time_zone: "Pacific Standard Time"
schedule_run_time: 8
- name: Create daily enhanced policy
azure.azcollection.azure_rm_backuppolicy:
vault_name: Vault_Name
name: Policy_Name_Enhanced
resource_group: Resource_Group_Name
policy_type: V2
state: present
backup_management_type: AzureIaasVM
schedule_run_frequency: Daily
instant_recovery_snapshot_retention: 7
daily_retention_count: 28
time_zone: UTC
schedule_run_time: 20
- name: Create a daily VM backup policy with monthly and yearly retention
azure.azcollection.azure_rm_backuppolicy:
vault_name: Vault_Name
name: Policy_Name
resource_group: Resource_Group_Name
state: present
backup_management_type: "AzureIaasVM"
schedule_run_frequency: "Daily"
instant_recovery_snapshot_retention: 2
daily_retention_count: 12
schedule_run_time: 14
monthly_retention_count: 12
yearly_retention_count: 5
months_of_year:
- January
retention_weekdays:
- Sunday
retention_weeks_of_the_month:
- Last
- name: Create a daily VM backup policy with monthly retention on specific days of the month
azure.azcollection.azure_rm_backuppolicy:
vault_name: Vault_Name
name: Policy_Name
resource_group: Resource_Group_Name
state: present
backup_management_type: "AzureIaasVM"
schedule_run_frequency: "Daily"
instant_recovery_snapshot_retention: 2
daily_retention_count: 12
schedule_run_time: 14
monthly_retention_count: 6
retention_days_of_the_month:
- 1
- 15
retention_include_last_day: true