Open TomArcherMsft opened 2 years ago
A temporary workaround, is to install a newer version.
ansible-playbook --version
: Results in 2.10.2
.pip3 install 'ansible[azure]'
curl -O https://raw.githubusercontent.com/ansible-collections/azure/dev/requirements-azure.txt
pip3 install -r requirements-azure.txt
ansible-galaxy collection install azure.azcollection
ansible-playbook --version
: Results in 2.11.8
.Then, I need to modify the playbook tasks, so that they use CLI as auth souce:
auth_source: cli
e.g.
- name: Create a resource group
hosts: localhost
connection: local
gather_facts: no
tasks:
- name: Create a resource group
azure_rm_resourcegroup:
name: tarcher-test-rg
location: eastus
auth_source: cli
Run the playbook again, it should work now.
PR https://github.com/Azure/CloudShell/pull/153 will fix this issue.
https://raw.githubusercontent.com/ansible-collections/azure/dev/requirements-azure.txt is the latest dependency, may not suit for the release version. Install the dependencies with ~/.ansible/collections/ansible_collections/azure/azcollection/requirements-azure.txt
instead.
@TomArcherMsft @DavidLievrouw latest CloudShell release has fixed this issue
@hisasima @DavidLievrouw opened a GitHub Issue in the Ansible developer documentation about Ansible no longer working in Cloud Shell.
I tested a very simple Ansible playbook:
I see similar errors as them: An exception occurred during task execution. To see the full traceback, use -vvv. The error was: ModuleNotFoundError: No module named 'azure.mgmt.monitor.version' fatal: [localhost]: FAILED! => {"changed": false, "msg": "Failed to import the required Python library (ansible[azure] (azure >= 2.0.0)) on cc-77654aed-c95b8b99d-hvlnm's Python /opt/ansible/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"}