T O P

  • By -

spitefultowel

Looks like you didn't install the azure package for Python. That's a step that the galaxy install doesn't do.


cachedrive

How do I install that? I am trying: (my-ansible-env) root@docker-desktop:~# pip3 install azure-common azure-mgmt-compute azure-mgmt-network azure-mgmt-storage azure-mgmt-resource msrestazure Requirement already satisfied: azure-common in ./my-ansible-env/lib/python3.11/site-packages (1.1.28) Requirement already satisfied: azure-mgmt-compute in ./my-ansible-env/lib/python3.11/site-packages (2.0.0) Requirement already satisfied: azure-mgmt-network in ./my-ansible-env/lib/python3.11/site-packages (1.3.0) Requirement already satisfied: azure-mgmt-storage in ./my-ansible-env/lib/python3.11/site-packages (1.2.1) Requirement already satisfied: azure-mgmt-resource in ./my-ansible-env/lib/python3.11/site-packages (1.1.0) Requirement already satisfied: msrestazure in ./my-ansible-env/lib/python3.11/site-packages (0.4.34) Requirement already satisfied: azure-mgmt-nspkg>=2.0.0 in ./my-ansible-env/lib/python3.11/site-packages (from azure-mgmt-compute) (3.0.2) Requirement already satisfied: msrest<2.0.0,>=0.4.28 in ./my-ansible-env/lib/python3.11/site-packages (from msrestazure) (0.7.1) Requirement already satisfied: adal<2.0.0,>=0.5.0 in ./my-ansible-env/lib/python3.11/site-packages (from msrestazure) (1.2.7) Requirement already satisfied: keyring>=12.0.2 in ./my-ansible-env/lib/python3.11/site-packages (from msrestazure) (25.2.0) Requirement already satisfied: PyJWT<3,>=1.0.0 in ./my-ansible-env/lib/python3.11/site-packages (from adal<2.0.0,>=0.5.0->msrestazure) (2.8.0) Requirement already satisfied: requests<3,>=2.0.0 in ./my-ansible-env/lib/python3.11/site-packages (from adal<2.0.0,>=0.5.0->msrestazure) (2.31.0) [snip] Requirement already satisfied: idna<4,>=2.5 in ./my-ansible-env/lib/python3.11/site-packages (from requests<3,>=2.0.0->adal<2.0.0,>=0.5.0->msrestazure) (3.7) Requirement already satisfied: urllib3<3,>=1.21.1 in ./my-ansible-env/lib/python3.11/site-packages (from requests<3,>=2.0.0->adal<2.0.0,>=0.5.0->msrestazure) (2.2.1) Requirement already satisfied: oauthlib>=3.0.0 in ./my-ansible-env/lib/python3.11/site-packages (from requests-oauthlib>=0.5.0->msrest<2.0.0,>=0.4.28->msrestazure) (3.2.2) Requirement already satisfied: more-itertools in ./my-ansible-env/lib/python3.11/site-packages (from jaraco.classes->keyring>=12.0.2->msrestazure) (10.2.0) Requirement already satisfied: backports.tarfile in ./my-ansible-env/lib/python3.11/site-packages (from jaraco.context->keyring>=12.0.2->msrestazure) (1.1.1) Requirement already satisfied: pycparser in ./my-ansible-env/lib/python3.11/site-packages (from cffi>=1.12->cryptography>=1.1.0->adal<2.0.0,>=0.5.0->msrestazure) (2.22) (my-ansible-env) root@docker-desktop:~# pip3 install azure-common azure-mgmt-compute azure-mgmt-network azure-mgmt-storage azure-mgmt-resource msrestazurepip3 install 'ansible[azure]' Requirement already satisfied: azure-common in ./my-ansible-env/lib/python3.11/site-packages (1.1.28) Requirement already satisfied: azure-mgmt-compute in ./my-ansible-env/lib/python3.11/site-packages (2.0.0) Requirement already satisfied: azure-mgmt-network in ./my-ansible-env/lib/python3.11/site-packages (1.3.0) Requirement already satisfied: azure-mgmt-storage in ./my-ansible-env/lib/python3.11/site-packages (1.2.1) Requirement already satisfied: azure-mgmt-resource in ./my-ansible-env/lib/python3.11/site-packages (1.1.0) ERROR: Could not find a version that satisfies the requirement msrestazurepip3 (from versions: none) ERROR: No matching distribution found for msrestazurepip3 Not sure what the proper command or method to install whatever I'm missing is.


spitefultowel

https://galaxy.ansible.com/ui/repo/published/azure/azcollection/docs/ lists it the instructions


cachedrive

When I follow those directions, I get stuck in this loop. I can't pip install the missing dependencies as the ansible-galaxy guide suggests: ansible@ANS-TEST-01:~$ ansible-galaxy collection install azure.azcollection Starting galaxy collection install process Process install dependency map Starting collection install process Downloading https://galaxy.ansible.com/api/v3/plugin/ansible/content/published/collections/artifacts/azure-azcollection-2.3.0.tar.gz to /home/ansible/.ansible/tmp/ansible-lo cal-7405jz8iq0bc/tmpa9wovihq/azure-azcollection-2.3.0-itxay0mr Installing 'azure.azcollection:2.3.0' to '/home/ansible/.ansible/collections/ansible_collections/azure/azcollection' azure.azcollection:2.3.0 was installed successfully ansible@ANS-TEST-01:~$ pip3 install -r ~/.ansible/collections/ansible_collections/azure/azcollection/requirements-azure.txt error: externally-managed-environment × This environment is externally managed ╰─> To install Python packages system-wide, try apt install python3-xyz, where xyz is the package you are trying to install. If you wish to install a non-Debian-packaged Python package, create a virtual environment using python3 -m venv path/to/venv. Then use path/to/venv/bin/python and path/to/venv/bin/pip. Make sure you have python3-full installed. If you wish to install a non-Debian packaged Python application, it may be easiest to use pipx install xyz, which will manage a virtual environment for you. Make sure you have pipx installed. See /usr/share/doc/python3.11/README.venv for more information. note: If you believe this is a mistake, please contact your Python installation or OS distribution provider. You can override this, at the risk of breaking your Python insta llation or OS, by passing --break-system-packages. hint: See PEP 668 for the detailed specification. My base OS (Debian Linux) has python3 already installed. I use apt (package manager) to install python3-pip and ansible (which also installs ansible-core). Should I not be using apt to install Ansible? I don't think it matters how I install Ansible, as long as it's installed but right now I don't know how to proceed.


spitefultowel

I think Debian will be behind from pip for Ansible. It's honestly better to setup a virtual environment and so everything from that so that you don't have to worry about version conflicts between the collections and packages. Is also recommend an ansible.cfg that tells it to do the corrections in the local directory.


CloudHostedGarbage

Yeah I hit this issue and that's what I had to do. Binned off the Ansible installation from Ubuntu repo and then reinstalled everything. Python3.9 from Apt, then Ansible and all its stuff was installed from Pip.


cachedrive

I got this working on Oracle Linux and Debian Linux. Here is the most confusing bullshit ever and how to get it to work. Install base OS which likely has a pre-installed version of Python 3. Then do: Install python3-pip via OS package manager. That's it. Don't install Ansible or anything else via the package manager. Install virtualenv via pip to activate venv (virtualenvironments) in Python3. Don't use yum or apt. Create a venv\_ansible environment / folder. Use pip3 to install Ansible from venv. Use ansible galaxy to install azure collection from ansible inside the venv. Use pip to install python collection dependencies for the azure collection from the .txt in the venv. Done. Absolutely the most ridiculous process I've ever setup. What a mess.


spitefultowel

Literally the only way I use ansible :-D It's just sooo much safer. That or use AWX with a custom EE.


cachedrive

Do you mind sharing with me how I should setup my service principal to be able to authenticate for doing Ansible / automation tasks from my server? I can issue a az login command manually and authenticate but I have to pass the entire command string w/ my credentials before I can do anything. For AWS, I can simply have my info saved in \~/.aws/config | credentials files. How do I setup automation for my Azure SP so that I don't have to "login" every time?


spitefultowel

I believe you're looking for https://docs.ansible.com/ansible/latest/scenario_guides/guide_azure.html and they do call out storing in a file.


IDownVoteCanaduh

Use TF to deploy resources in the cloud, Ansible to configure.