| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
from __future__ import absolute_import, division, print_function |
| 8 |
__metaclass__ = type |
| 9 |
|
| 10 |
|
| 11 |
class ModuleDocFragment(object): |
| 12 |
|
| 13 |
|
| 14 |
DOCUMENTATION = r''' |
| 15 |
|
| 16 |
options: |
| 17 |
ad_user: |
| 18 |
description: |
| 19 |
- Active Directory username. Use when authenticating with an Active Directory user rather than service |
| 20 |
principal. |
| 21 |
type: str |
| 22 |
password: |
| 23 |
description: |
| 24 |
- Active Directory user password. Use when authenticating with an Active Directory user rather than service |
| 25 |
principal. |
| 26 |
type: str |
| 27 |
profile: |
| 28 |
description: |
| 29 |
- Security profile found in ~/.azure/credentials file. |
| 30 |
type: str |
| 31 |
subscription_id: |
| 32 |
description: |
| 33 |
- Your Azure subscription Id. |
| 34 |
type: str |
| 35 |
client_id: |
| 36 |
description: |
| 37 |
- Azure client ID. Use when authenticating with a Service Principal or Managed Identity (msi). |
| 38 |
- Can also be set via the C(AZURE_CLIENT_ID) environment variable. |
| 39 |
type: str |
| 40 |
secret: |
| 41 |
description: |
| 42 |
- Azure client secret. Use when authenticating with a Service Principal. |
| 43 |
type: str |
| 44 |
tenant: |
| 45 |
description: |
| 46 |
- Azure tenant ID. Use when authenticating with a Service Principal. |
| 47 |
type: str |
| 48 |
oidc_token: |
| 49 |
description: |
| 50 |
- Direct OpenID Connect (OIDC) token (JWT) used for workload identity authentication. |
| 51 |
- This token is exchanged with Azure AD using OIDC federated identity. |
| 52 |
- Useful in CI systems (for example GitHub Actions, Azure DevOps) where an OIDC token is provided directly by the platform. |
| 53 |
- Can also be set via the C(AZURE_FEDERATED_TOKEN) environment variable. |
| 54 |
type: str |
| 55 |
version_added: '3.17.0' |
| 56 |
oidc_token_file_path: |
| 57 |
description: |
| 58 |
- Path to a file containing an OpenID Connect (OIDC) token (JWT) used for workload identity authentication. |
| 59 |
- The file must contain only raw token. |
| 60 |
- This method is commonly used in platforms that materialize OIDC tokens as files |
| 61 |
- Can also be set via the C(AZURE_FEDERATED_TOKEN_FILE) environment variable. |
| 62 |
type: path |
| 63 |
version_added: '3.17.0' |
| 64 |
cloud_environment: |
| 65 |
description: |
| 66 |
- For cloud environments other than the US public cloud, the environment name (as defined by Azure Python SDK, eg, C(AzureChinaCloud), |
| 67 |
C(AzureUSGovernment)), or a metadata discovery endpoint URL (required for Azure Stack). Can also be set via credential file profile or |
| 68 |
the C(AZURE_CLOUD_ENVIRONMENT) environment variable. |
| 69 |
type: str |
| 70 |
default: AzureCloud |
| 71 |
version_added: '0.0.1' |
| 72 |
adfs_authority_url: |
| 73 |
description: |
| 74 |
- Azure AD authority url. Use when authenticating with Username/password, and has your own ADFS authority. |
| 75 |
type: str |
| 76 |
version_added: '0.0.1' |
| 77 |
cert_validation_mode: |
| 78 |
description: |
| 79 |
- Controls the certificate validation behavior for Azure endpoints. By default, all modules will validate the server certificate, but |
| 80 |
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 |
| 81 |
set via credential file profile or the C(AZURE_CERT_VALIDATION) environment variable. |
| 82 |
type: str |
| 83 |
choices: [ ignore, validate ] |
| 84 |
version_added: '0.0.1' |
| 85 |
disable_instance_discovery: |
| 86 |
description: |
| 87 |
- Determines whether or not instance discovery is performed when attempting to authenticate. |
| 88 |
Setting this to true will completely disable both instance discovery and authority validation. |
| 89 |
This functionality is intended for use in scenarios where the metadata endpoint cannot be reached |
| 90 |
such as in private clouds or Azure Stack. The process of instance discovery entails retrieving |
| 91 |
authority metadata from https://login.microsoft.com/ to validate the authority. By setting this |
| 92 |
to **True**, the validation of the authority is disabled. As a result, it is crucial to ensure |
| 93 |
that the configured authority host is valid and trustworthy. |
| 94 |
- Set via credential file profile or the C(AZURE_DISABLE_INSTANCE_DISCOVERY) environment variable. |
| 95 |
type: bool |
| 96 |
default: False |
| 97 |
version_added: '2.3.0' |
| 98 |
auth_source: |
| 99 |
description: |
| 100 |
- Controls the source of the credentials to use for authentication. |
| 101 |
- Can also be set via the C(ANSIBLE_AZURE_AUTH_SOURCE) environment variable. |
| 102 |
- When set to C(auto) (the default) the precedence is module parameters -> C(env) -> C(credential_file) -> C(cli). |
| 103 |
- When set to C(env), the credentials will be read from the environment variables. |
| 104 |
- When set to C(credential_file), it will read the profile from C(~/.azure/credentials). |
| 105 |
- When set to C(cli), the credentials will be sources from the Azure CLI profile. C(subscription_id) or the environment variable |
| 106 |
C(AZURE_SUBSCRIPTION_ID) can be used to identify the subscription ID if more than one is present otherwise the default |
| 107 |
az cli subscription is used. |
| 108 |
- When set to C(msi), the host machine must be an azure resource with an enabled MSI extension. C(subscription_id) or the |
| 109 |
environment variable C(AZURE_SUBSCRIPTION_ID) can be used to identify the subscription ID if the resource is granted |
| 110 |
access to more than one subscription, otherwise the first subscription is chosen. |
| 111 |
- The C(msi) was added in Ansible 2.6. |
| 112 |
type: str |
| 113 |
default: auto |
| 114 |
choices: |
| 115 |
- auto |
| 116 |
- cli |
| 117 |
- credential_file |
| 118 |
- env |
| 119 |
- msi |
| 120 |
version_added: '0.0.1' |
| 121 |
api_profile: |
| 122 |
description: |
| 123 |
- Selects an API profile to use when communicating with Azure services. Default value of C(latest) is appropriate for public clouds; |
| 124 |
future values will allow use with Azure Stack. |
| 125 |
type: str |
| 126 |
default: latest |
| 127 |
version_added: '0.0.1' |
| 128 |
log_path: |
| 129 |
description: |
| 130 |
- Parent argument. |
| 131 |
type: str |
| 132 |
log_mode: |
| 133 |
description: |
| 134 |
- Parent argument. |
| 135 |
type: str |
| 136 |
x509_certificate_path: |
| 137 |
description: |
| 138 |
- Path to the X509 certificate used to create the service principal in PEM format. |
| 139 |
- The certificate must be appended to the private key. |
| 140 |
- Use when authenticating with a Service Principal. |
| 141 |
type: path |
| 142 |
version_added: '1.14.0' |
| 143 |
thumbprint: |
| 144 |
description: |
| 145 |
- The thumbprint of the private key specified in I(x509_certificate_path). |
| 146 |
- Use when authenticating with a Service Principal. |
| 147 |
- Required if I(x509_certificate_path) is defined. |
| 148 |
type: str |
| 149 |
version_added: '1.14.0' |
| 150 |
requirements: |
| 151 |
- python >= 2.7 |
| 152 |
- The host that executes this module must have the azure.azcollection collection installed via galaxy |
| 153 |
- All python packages listed in collection's requirements.txt must be installed via pip on the host that executes modules from azure.azcollection |
| 154 |
- Full installation instructions may be found https://galaxy.ansible.com/azure/azcollection |
| 155 |
|
| 156 |
notes: |
| 157 |
- For authentication with Azure you can pass parameters, set environment variables, use a profile stored |
| 158 |
in ~/.azure/credentials, or log in before you run your tasks or playbook with C(az login). |
| 159 |
- Authentication is also possible using a service principal or Active Directory user. |
| 160 |
- To authenticate via OIDC, pass client_id, tenant and oidc_token or oidc_token_file_path, or set environment |
| 161 |
variables AZURE_CLIENT_ID, AZURE_TENANT and AZURE_FEDERATED_TOKEN or AZURE_FEDERATED_TOKEN_FILE. |
| 162 |
- To authenticate via service principal, pass subscription_id, client_id, secret and tenant or set environment |
| 163 |
variables AZURE_SUBSCRIPTION_ID, AZURE_CLIENT_ID, AZURE_SECRET and AZURE_TENANT. |
| 164 |
- To authenticate via Active Directory user, pass ad_user and password, or set AZURE_AD_USER and |
| 165 |
AZURE_PASSWORD in the environment. |
| 166 |
- "Alternatively, credentials can be stored in ~/.azure/credentials. This is an ini file containing |
| 167 |
a [default] section and the following keys: subscription_id, client_id, secret and tenant or |
| 168 |
subscription_id, ad_user and password. It is also possible to add additional profiles. Specify the profile |
| 169 |
by passing profile or setting AZURE_PROFILE in the environment." |
| 170 |
|
| 171 |
seealso: |
| 172 |
- name: Sign in with Azure CLI |
| 173 |
link: https://docs.microsoft.com/en-us/cli/azure/authenticate-azure-cli?view=azure-cli-latest |
| 174 |
description: How to authenticate using the C(az login) command. |
| 175 |
''' |