we are trying to upload a txt file to a azure blob storage using ansible playbook.
We are using azure.azcollection.azure_rm_storageblob package to perform the upload.
My azure.azcollection version is 2.6.0
auto@32fb1b2fe9a1:/$ ansible-galaxy collection list
# /usr/local/lib/python3.9/site-packages/ansible_collections
Collection Version
----------------------------- -------
azure.azcollection 2.6.0
and ansibel version is ansible-core==2.15.5
the ansible playbook content is
—
- name: Upload a test file to Azure Blob
** hosts: localhost**
** tasks:**
** - name: Upload a test file to Azure Blob**
** azure.azcollection.azure_rm_storageblob:**
** subscription_id: “{{ lookup(‘env’, ‘AZURE_SUBSCRIPTION_ID’) }}”**
** client_id: “{{ lookup(‘env’, ‘AZURE_CLIENT_ID’) }}”**
** secret: “{{ lookup(‘env’, ‘AZURE_SECRET’) }}”**
** tenant: “{{ lookup(‘env’, ‘AZURE_TENANT’) }}”**
** storage_account_name: “your_storage_account_name”**
** resource_group: “your_resource_group”**
** container: “your_container_name”**
** blob: “test_blob_name”**
** src: “/path/to/your/local_file.txt”**
** state: present**
we have exported the env var as
export AZURE_SUBSCRIPTION_ID=“your_subscription_id”
export AZURE_CLIENT_ID=“your_client_id”
export AZURE_SECRET=“your_secret”
export AZURE_TENANT=“your_tenant_id”
but still getting belwo error where it is expecting azure-cli , which should not be rthe case as per documentation. It should use service principal for authentication and not azure cli.
err:
auto@d306e2ceedee:~$ ansible-playbook test.yml
[WARNING]: No inventory was parsed, only implicit localhost is available
[WARNING]: provided hosts list is empty, only localhost is available. Note that the implicit localhost does not match ‘all’
PLAY [Test Azure Blob Upload] *************************************************************************************************************************************************************
TASK [Gathering Facts] ********************************************************************************************************************************************************************
ok: [localhost]
TASK [Upload a test file to Azure Blob] ***************************************************************************************************************************************************
An exception occurred during task execution. To see the full traceback, use -vvv. The error was: ModuleNotFoundError: No module named ‘azure.cli’
fatal: [localhost]: FAILED! => {“changed”: false, “msg”: “Failed to import the required Python library (ansible[azure] (azure >= 2.0.0)) on d306e2ceedee’s Python /usr/local/bin/python. 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”}
PLAY RECAP ********************************************************************************************************************************************************************************
localhost : ok=1 changed=0 unreachable=0 failed=1 skipped=0 rescued=0 ignored=0
verbose stacktrace
The full traceback is:
Traceback (most recent call last):
File “/tmp/ansible_azure.azcollection.azure_rm_storageblob_payload_p5jrzqbn/ansible_azure.azcollection.azure_rm_storageblob_payload.zip/ansible_collections/azure/azcollection/plugins/module_utils/azure_rm_common.py”, line 243, in
from azure.cli.core import cloud as azure_cloud
ModuleNotFoundError: No module named ‘azure.cli’
EDIT PART
My oppologies for the confusion here.
While capturing the details by mistake took Screen shots from two different conatiners but they were both spinned up with same image.
However i am attaching the details again as the problem is still persisting.
autotron@c08393297018:~$ ansible-galaxy collection list
/usr/local/lib/python3.9/site-packages/ansible_collections
Collection Version
amazon.aws 6.5.0
ansible.netcommon 5.2.0
ansible.posix 1.5.4
ansible.utils 2.11.0
ansible.windows 1.14.0
arista.eos 6.1.2
awx.awx 22.7.0
azure.azcollection 2.6.0
autotron@c08393297018:~$ ansible-playbook test.yml
[WARNING]: No inventory was parsed, only implicit localhost is available
[WARNING]: provided hosts list is empty, only localhost is available. Note that the implicit localhost does not match ‘all’
PLAY [Upload file to Azure Blob] **********************************************************************************************************************************************************
TASK [Gathering Facts] ********************************************************************************************************************************************************************
ok: [localhost]
TASK [Upload file to Azure Blob] **********************************************************************************************************************************************************
An exception occurred during task execution. To see the full traceback, use -vvv. The error was: ModuleNotFoundError: No module named ‘azure.cli’
fatal: [localhost]: FAILED! => {“changed”: false, “msg”: “Failed to import the required Python library (ansible[azure] (azure >= 2.0.0)) on c08393297018’s Python /usr/local/bin/python. 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”}