You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: articles/ansible/ansible-run-playbook-in-cloudshell.md
+1-1
Original file line number
Diff line number
Diff line change
@@ -16,7 +16,7 @@ In this tutorial, you learn how to use Bash within Cloud Shell to configure an A
16
16
17
17
## Prerequisites
18
18
19
-
-**Azure subscription** - If you don't have an Azure subscription, create a [free account](https://azure.microsoft.com/free/?ref=microsoft.com&utm_source=microsoft.com&utm_medium=docs&utm_campaign=visualstudio) before you begin.
19
+
-**Azure subscription** - If you don't have an Azure subscription, create a [free account](https://azure.microsoft.com/free/?ref=microsoft.com&utm_source=microsoft.com&utm_medium=docs&utm_campaign=visualstudio).
20
20
21
21
-**Configure Azure Cloud Shell** - If you are new to Azure Cloud Shell, the article, [Quickstart for Bash in Azure Cloud Shell](https://docs.microsoft.com/azure/cloud-shell/quickstart), illustrates how to start and configure Cloud Shell.
Copy file name to clipboardexpand all lines: articles/virtual-machines/linux/ansible-install-configure.md
+33-57
Original file line number
Diff line number
Diff line change
@@ -16,16 +16,17 @@ Ansible allows you to automate the deployment and configuration of resources in
16
16
17
17
For more installation options and steps for additional platforms, see the [Ansible install guide](https://docs.ansible.com/ansible/intro_installation.html).
18
18
19
-
One of the easiest ways to use Ansible with Azure is with the Azure Cloud Shell, a browser-based shell experience to manage and develop Azure resources. Ansible is pre-installed in the Cloud Shell, you can follow []() to configure your Cloud Shell and try it. For a list of additional tools also available in the Cloud Shell, see [Features and tools for Bash in the Azure Cloud Shell](../../cloud-shell/features.md#tools).
19
+
One of the easiest ways to use Ansible with Azure is with the [Azure Cloud Shell](https://docs.microsoft.com/en-us/azure/cloud-shell/overview), a browser-based shell experience to manage and develop Azure resources. Ansible is pre-installed in the Cloud Shell. For a list of additional tools available in the Cloud Shell, see [Features and tools for Bash in the Azure Cloud Shell](../../cloud-shell/features.md#tools).
20
20
21
-
The following instructions show you how to create a Linux VM for various distros and then install Ansible.
21
+
The following instructions show you how to create a Linux virtual machine for various distros and then install Ansible.
22
22
23
23
## Prerequisites
24
-
To manage Azure resources with Ansible, you need the following prerequisites:
25
24
26
-
-**Azure subscription** - If you don't have an Azure subscription, create a [free account](https://azure.microsoft.com/free/?ref=microsoft.com&utm_source=microsoft.com&utm_medium=docs&utm_campaign=visualstudio) before you begin.
25
+
-**Azure subscription** - If you don't have an Azure subscription, create a [free account](https://azure.microsoft.com/free/?ref=microsoft.com&utm_source=microsoft.com&utm_medium=docs&utm_campaign=visualstudio).
27
26
28
-
-**Linux machine** - If you don't have a Linux machine, create a [Linux virtual machine](/virtual-machines/linux/quick-create-cli.md) before you begin.
27
+
-**Access to Linux or a Linux virtual machine** - If you don't have a Linux machine, create a [Linux virtual machine](/virtual-machines/linux/quick-create-cli.md).
28
+
29
+
-**Azure service principal**: Follow the directions in the section of the **Create the service principal** section in the article, [Create an Azure service principal with Azure CLI 2.0](/cli/azure/create-an-azure-service-principal-azure-cli?view=azure-cli-latest#create-the-service-principal). Take note of the values for the **appId**, **displayName**, **password**, and **tenant**.
29
30
30
31
## Install Ansible
31
32
@@ -37,7 +38,7 @@ Sign in to your Linux machine and select one of the following distros for steps
37
38
38
39
### CentOS 7.4
39
40
40
-
Install the required packages for the Azure Python SDK modules and Ansible as follows:
41
+
Install the required packages for the Azure Python SDK modules and Ansible by entering the following commands in a terminal or Bash window:
Now move on to[Create Azure credentials](#create-azure-credentials).
85
+
Follow the instructions outlined in the section,[Create Azure credentials](#create-azure-credentials).
83
86
84
87
## Create Azure credentials
85
88
86
-
Ansible communicates with Azure using a username and password or a service principal. An Azure service principal is a security identity that you can use with apps, services, and automation tools like Ansible. You control and define the permissions as to what operations the service principal can perform in Azure. To improve security over just providing a username and password, this example creates a basic service principal.
87
-
88
-
In the Azure Cloud Shell or on your host machine if you installed [AZ CLI](), create a service principal.
89
-
90
-
To authenticate to Azure, you need to obtain your Azure subscription ID using [az account show](/cli/azure/account#az-account-show):
89
+
The combination of the subscription ID and the information returned from creating the service principal is used to configure the Ansible credentials in one of two ways:
91
90
92
-
```azurecli-interactive
93
-
az account show --query "{ subscription_id: id }"
94
-
```
95
-
96
-
If you want to change you workspace to another subscription, using [az account set]():
97
-
98
-
```azurecli-interactive
99
-
az account set -s <subscription-id>
100
-
```
91
+
-[Create an Ansible credentials file](#file-credentials)
Create a service principal using [az ad sp create-for-rbac](/cli/azure/ad/sp#az-ad-sp-create-for-rbac). The credentials that Ansible needs are output to the screen:
105
-
106
-
```azurecli-interactive
107
-
az ad sp create-for-rbac --query '{"client_id": appId, "secret": password, "tenant": tenant}'
108
-
```
109
-
110
-
An example of the output from the preceding commands is as follows:
You use the output of this command together with subscription ID to configure Ansible credentials in either [file](#file-credentials) or [environment variable](#env-credentials) ways.
94
+
If you are going to use tools such as Ansible Tower or Jenkins, you will need to use the option of declaring the service principal values as environment variables.
To provide credentials to Ansible, you define environment variables or create a local credentials file. For more information about how to define Ansible credentials, see [Providing Credentials to Azure Modules](https://docs.ansible.com/ansible/guide_azure.html#providing-credentials-to-azure-modules).
98
+
This section explains how to create a local credentials file to provide credentials to Ansible. For more information about how to define Ansible credentials, see [Providing Credentials to Azure Modules](https://docs.ansible.com/ansible/guide_azure.html#providing-credentials-to-azure-modules).
125
99
126
-
For a development environment, create a *credentials* file for Ansible on your host VM. Create a credentials file on the VM where you installed Ansible in a previous step:
100
+
For a development environment, create a *credentials* file for Ansible on your host virtual machine as follows:
127
101
128
102
```bash
129
103
mkdir ~/.azure
130
104
vi ~/.azure/credentials
131
105
```
132
106
133
-
The *credentials* file itself combines the subscription ID with the output of creating a service principal. Output from the previous [az ad sp create-for-rbac](/cli/azure/ad/sp#create-for-rbac) command is the same as needed for *client_id*, *secret*, and *tenant*. The following example *credentials* file shows these values matching the previous output. Enter your own values as follows:
107
+
Insert the following lines into the *credentials* file - replacing the placeholders with the information from the service principal creation.
You can configure you Ansible credentials by exporting it as environment variable. If you are going to use tools such as Ansible Tower or Jenkins, you need to define environment variables:
121
+
This section explains how to configure your Ansible credentials by exporting them as environment variables.
122
+
123
+
In a terminal or Bash window, enter the following commands:
0 commit comments