|
--- |
|
# This task file depends on the parameter "azure_cli_virtualenv" |
|
# |
|
# Once this task file is executed, it's possible to use azure cli |
|
# using "{{ azure_cli_virtualenv }}/bin/az". |
|
--- |
|
|
|
- name: Install azure-cli into dedicated virtual environment |
|
# A block is used to group multiple tasks together |
|
# NOTE 1: We could install azure-cli only in the virtual environment, but we would not be able |
|
# to upgrade azure-cli manually later on if we choose to do so. |
|
# NOTE 2: On Ubuntu >= 22.04, we can use the --upgrade-deps option to upgrade the pip/setuptools dependencies |
|
# of the virtual environment. In such case, we would need a single task to both create the virtual environment |
|
# and install the azure-cli dependency. However, on older versions of Ubuntu, we need to create the virtual |
|
# environment first with up-to-date dependencies, then install the azure-cli dependency |
|
block: |
|
- name: Create a virtual environment for azure-cli |
|
ansible.builtin.pip: |
|
name: "{{ item }}" |
|
virtualenv: "{{ azure_cli_virtualenv }}" |
|
# Uncomment to support Ubuntu >= 22.04 only |
|
# If you decide to uncomment the following line, you should also |
|
# change the dependencies to install into [azure-cli] only in this |
|
# task, and you should remove the next task. |
|
# virtualenv_command : python3 -m venv --upgrade-deps |
|
state: latest |
|
# Rather than using --upgrade-deps, we can force the upgrade of the dependencies by using the following: |
|
# Change the dependencies to install into [azure-cli] only in this task if you decide |
|
# to use the virtualenv_comand ansible option with --upgrade-deps |
|
loop: |
|
- pip |
|
- setuptools |
|
|
|
- name: Install azure-cli into the virtual environment |
|
ansible.builtin.pip: |
|
name: azure-cli |
|
virtualenv: "{{ azure_cli_virtualenv }}" |
|
# This will not update the azure-cli package if it's already installed |
|
# You may change the state to "latest" to force the upgrade of the package |
|
# to the latest version on each run. |
|
state: present |