Azure / Ansible

Ansible Solution Template on Azure
MIT License
7 stars 10 forks source link

Ansible in CloudShell appears to be broken #24

Open TomArcherMsft opened 2 years ago

TomArcherMsft commented 2 years ago

@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:

- 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

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"}

DavidLievrouw commented 2 years ago

A temporary workaround, is to install a newer version.

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.

xuzhang3 commented 2 years ago

PR https://github.com/Azure/CloudShell/pull/153 will fix this issue.

xuzhang3 commented 2 years ago

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.

xuzhang3 commented 2 years ago

@TomArcherMsft @DavidLievrouw latest CloudShell release has fixed this issue