An open API service indexing awesome lists of open source software.

https://github.com/pyratlabs/ansible-role-azcli

Ansible role for installing an Azure CLI (azure-cli) into a Python3 VirtualEnv.
https://github.com/pyratlabs/ansible-role-azcli

ansible ansible-role automation azure azure-cli cloud infrastructure-as-code

Last synced: 8 months ago
JSON representation

Ansible role for installing an Azure CLI (azure-cli) into a Python3 VirtualEnv.

Awesome Lists containing this project

README

          

# Ansible Role: azurecli

Ansible role for installing an Azure CLI (`azure-cli`) into a Python3 VirtualEnv.

[![Build Status](https://www.travis-ci.org/PyratLabs/ansible-role-azcli.svg?branch=master)](https://www.travis-ci.org/PyratLabs/ansible-role-azcli)

## Requirements

This role has been tested on Ansible 2.7.0+ against the following Linux Distributions:

- Amazon Linux 2
- CentOS 8
- CentOS 7
- Debian 10
- Fedora 29
- Fedora 30
- Fedora 31
- Ubuntu 18.04 LTS

The target server requires the following packages:

- python3
- python3 development packages
- python3 venv
- gcc

## Disclaimer

If you have any problems please create a GitHub issue, I maintain this role in
my spare time so I cannot promise a speedy fix delivery.

## Role Variables

| Variable | Description | Default Value |
|---------------------------------|--------------------------------------------------------------------------------|----------------------|
| `azcli_version` | Use a specific version of azure-cli, eg. `2.0.78`. Specify `false` for latest. | `false` |
| `azcli_install_dir` | Installation directory to put azure-cli virtual environments. | `$HOME/.virtualenvs` |
| `azcli_venv_name` | Name for the azure-cli Virtualenv. | azure-cli |
| `azcli_venv_suffix` | Add a custom suffix to virtualenv. | `azcli_version` |
| `azcli_venv_site_packages` | Allow venv to inherit packages from global site-packages. | `false` |
| `azcli_install_venv_helper` | Install a venv helper to launch venv executables from a "bin" directory. | `true` |
| `azcli_bin_dir` | "bin" directory to install venv-helpers to. | `$HOME/bin` |
| `azcli_install_os_dependencies` | Allow role to install OS dependencies. | `false` |
| `azcli_python3_path` | Specify a path to a specific python version to use in virtualenv. | _NULL_ |

## Dependencies

No dependencies on other roles.

## Example Playbook

Example playbook for installing to single user:

```yaml
- hosts: azcli_hosts
roles:
- { role: xanmanning.azurecli, azcli_version: 2.0.78 }
```

Example playbook for installing the latest azure-cli version globally:

```yaml
---
- hosts: azcli_hosts
become: true
vars:
azcli_install_os_dependencies: true
azcli_install_dir: /opt/azure-cli/bin
azcli_bin_dir: /usr/bin
azcli_venv_name: current
roles:
- role: xanmanning.azurecli
```

### Activating the azure-cli venv

You need to activate the python3 virtual environment to be able to access `az`.
This is done as per the below:

```bash
source {{ azure_install_dir }}/{{ azcli_venv_name }}/bin/activate
```

In the above example global installation playbook, this would look like the
following:

```bash
source /opt/azure-cli/bin/current/bin/activate
```

## License

[BSD 3-clause](LICENSE.txt)

## Author Information

[Xan Manning](https://xanmanning.co.uk/)