I am getting the following error when attempting to use the
azure.azcollection.azure_rm_deployment module to provision a VM from an ARM
template:
"exception": "Traceback (most recent call last):\n File
\"/tmp/ansible_azure.azcollection.azure_rm_deployment_payload_cd7vrb_9/ansible_azure.azcollection.azure_rm_deployment_payload.zip/ansible_collections/azure/azcollection/plugins/module_utils/azure_rm_common.py\",
line 251, in <module>\n from azure.storage.blob import PageBlobService,
BlockBlobService\nImportError: cannot import name 'PageBlobService' from
'azure.storage.blob'
(/usr/local/lib/python3.8/site-packages/azure/storage/blob/__init__.py)\n",
"msg": "Failed to import the required Python library (ansible[azure]
(azure >= 2.0.0)) on automation-job-30098-w7s7q's Python /usr/bin/python3.
Please read the module documentation and install it in the appropriate
location. If the required library is installed, but Ansible is using the
wrong Python interpreter, please consult the documentation on
ansible_python_interpreter",
I am using a custom execution environment for AWX, which I configured as
follows:
*execution-environment.yml:*
---
version: 1
build_arg_defaults:
EE_BASE_IMAGE: 'quay.io/ansible/ansible-runner:latest'
dependencies:
galaxy: requirements.yml
python: requirements.txt
system: bindep.txt
additional_build_steps:
append:
- RUN pip3 install
git+https://github.com/vmware/vsphere-automation-sdk-python.git
- COPY --from=quay.io/ansible/receptor:latest /usr/bin/receptor
/usr/bin/receptor
- RUN mkdir -p /var/run/receptor
- RUN pip install 'ansible[azure]'
- USER 1000
- ADD run.sh /run.sh
- CMD /run.sh
- RUN git lfs install
*requirements.txt*
ansible[azure]
ansible-pylibssh >= 0.2.0
packaging
requests[security]
xmltodict
azure-cli-core
azure-common
azure-identity
azure-mgmt-apimanagement
azure-mgmt-authorization
azure-mgmt-batch
azure-mgmt-cdn
azure-mgmt-compute
azure-mgmt-containerinstance
azure-mgmt-core
azure-mgmt-containerregistry
azure-containerregistry
azure-mgmt-containerservice
azure-mgmt-datalake-store
azure-mgmt-datafactory
azure-mgmt-dns
azure-mgmt-keyvault
azure-mgmt-marketplaceordering
azure-mgmt-monitor
azure-mgmt-managedservices
azure-mgmt-managementgroups
azure-mgmt-network
azure-mgmt-nspkg
azure-mgmt-privatedns
azure-mgmt-redis
azure-mgmt-resource
azure-mgmt-rdbms
azure-mgmt-search
azure-mgmt-servicebus
azure-mgmt-sql
azure-mgmt-storage
azure-mgmt-trafficmanager
azure-mgmt-web
azure-nspkg
azure-storage-blob
msrest==0.6.21
msrestazure==0.6.4
azure-keyvault
azure-graphrbac
azure-mgmt-cosmosdb
azure-mgmt-hdinsight
azure-mgmt-devtestlabs
azure-mgmt-loganalytics
azure-mgmt-automation
azure-mgmt-iothub
azure-mgmt-recoveryservices
azure-mgmt-recoveryservicesbackup
azure-mgmt-notificationhubs
azure-mgmt-eventhub
awxkit
boto3>=1.17.0
botocore>=1.20.0
cryptography
dnspython
infoblox-client
invoke
ipaddress
jmespath
jsonpatch
jxmlease
kubernetes>=12.0.0
lxml
msrest==0.6.21
msrestazure==0.6.4
ncclient
netaddr
netapp-lib
openshift>=0.6.2
packaging
paramiko
pexpect
pyinotify
pynetbox
pyOpenSSL
pypsrp
python_dateutil
pyVmomi>=6.7
pywinrm
q
requests-oauthlib
six
solidfire-sdk-python
urllib3
xmljson
xmltodict
*requirements.yml*
---
collections:
- name: awx.awx
- name: community.general
- name: community.windows
- name: community.azure
- name: azure.azcollection
- name: ansible.windows
- name: ansible.posix
- name: ansible.netcommon
- name: community.vmware
I have captured the output from the ansible_builder command - its very
verbose, so I can will keep it handy, but will not post that for now.
Here is a sample playbook:
- name: Create VM from ARM Template
azure.azcollection.azure_rm_deployment:
resource_group: "{{ provisioning_rg }}"
name: "{{ async_item.0.0 | upper }}_Deployment"
parameters:
virtualNetworkResourceGroup: "{{ az_vnet_rg }}"
virtualNetworkName: "{{ az_vnet_name }}"
subnetName: "{{ az_subnet }}"
adminUserName: 'vmadmin'
adminPassword:
reference:
keyVault:
id:
"/subscriptions/--Redacted--/resourceGroups/rg-bigbiz-wus3-dev-workload/providers/Microsoft.KeyVault/vaults/kv-bigbiz-dev-wus3"
secretName: vmadmin-password
vm:
name: "{{ async_item.0.0 }}"
privateIPAddress: "{{
async_item.0.1.ansible_facts.provision_ip_addresses }}"
vmSize: "{{ az_vmsize }}"
location: "{{ az_vmlocation }}"
licenseType: "{{ az_license | default('None') }}"
vmImage:
publisher: "{{ publisher }}"
offer: "{{ offer }}"
sku: "{{ sku }}"
version: "latest"
osDiskSizeGB: 50
tags:
ApplicationName: "{{ async_item.0.0[4:7] | upper}}"
BusinessUnit: "{{ BU | default(omit) }}"
CostCenter: "{{ CostCenter | default(omit) }}"
Environment: "{{ async_item.1.ansible_facts.az_env }}"
Owner: "{{ POC }}"
CreateDate: "{{ ansible_date_time.iso8601}}"
Creator: "{{ awx_user_name }}"
PCI: "{{ 'false' if ( ispci == 'nonpci' ) else 'true' }}"
PII: "{{ pii | default(omit) }}"
Company: "{{ corporate_entity }}"
template_link:
"https://dev.azure.com/uhaul/_git/Azure%20IaC?path=/BaseTemplates/Amerco.VM.json&version=GBuswest3&_a=contents"
append_tags: no
subscription_id: "{{ lookup('vars',async_item.0.0[10:11] | lower |
regex_replace('[^p]','d') | regex_replace('p','p') + '_SubscriptionID') }}"
client_id: "{{ lookup('vars',async_item.0.0[10:11] | lower |
regex_replace('[^p]','d') | regex_replace('p','p') + '_ClientID') }}"
secret: "{{ lookup('vars',async_item.0.0[10:11] | lower |
regex_replace('[^p]','d') | regex_replace('p','p')+ '_ClientSecret') }}"
tenant: "{{ lookup('vars',async_item.0.0[10:11] | lower |
regex_replace('[^p]','d') | regex_replace('p','p') + '_TenantID') }}"
state: present
wait_for_deployment_polling_period: 25
with_items:
- "{{ clone }}"
loop_control:
loop_var: "async_item"
register: clone_async
--
You received this message because you are subscribed to the Google Groups
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/9fe2dbf4-f92c-4100-8bea-cb31cd68bd66n%40googlegroups.com.