Skip to content

Commit f859f7b

Browse files
author
naman-msft
committed
containerized ada
1 parent e15d741 commit f859f7b

File tree

14 files changed

+254
-672
lines changed

14 files changed

+254
-672
lines changed
File renamed without changes.
File renamed without changes.
Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ Before running any commands, ensure that your local environment is connected to
2020

2121
```bash
2222
# Retrieve AKS cluster credentials:
23-
az aks get-credentials --resource-group "myAKSResourceGroupabcf37" --name "myAKSClusterabcf37"
23+
az aks get-credentials --resource-group $RESOURCE_GROUP --name $CLUSTER_NAME
2424
```
2525

2626
After executing this command, `kubectl` will be configured to communicate with the specified AKS cluster.
@@ -190,4 +190,9 @@ In the final part of the script, the focus shifts to monitoring and alerting:
190190
kubectl gadget undeploy
191191
```
192192

193-
These steps ensure that your metrics are visually accessible via Grafana and that alerts are configured for proactive monitoring. The final undeploy command removes the deployed gadget from the cluster, wrapping up the execution workflow.
193+
These steps ensure that your metrics are visually accessible via Grafana and that alerts are configured for proactive monitoring. The final undeploy command removes the deployed gadget from the cluster, wrapping up the execution workflow.
194+
195+
## Next Steps
196+
- [Real-world scenarios where Inspektor Gadget can help you](https://go.microsoft.com/fwlink/p/?linkid=2260402#use-cases)
197+
- [Explore the available gadgets](https://go.microsoft.com/fwlink/p/?linkid=2260070)
198+
- [Run your own eBPF program](https://go.microsoft.com/fwlink/p/?linkid=2259865)
Lines changed: 120 additions & 101 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
---
2-
title: Create a Linux virtual machines in Azure using Ansible
2+
title: Create a Linux virtual machines in Azure using Ansible
33
description: Learn how to create a Linux virtual machine in Azure using Ansible
44
keywords: ansible, azure, devops, virtual machine
55
ms.topic: tutorial
66
ms.date: 08/14/2024
7-
ms.custom: devx-track-ansible, linux-related-content
7+
ms.custom: devx-track-ansible, linux-related-content, innovation-engine
8+
author: <your GitHub username>
9+
ms.author: <your GitHub username>
810
---
911

1012
# Create a Linux virtual machines in Azure using Ansible
@@ -21,118 +23,135 @@ In this article, you learn how to:
2123
> * Create a virtual network interface card
2224
> * Create a virtual machine
2325
24-
## 1. Configure your environment
26+
## Configure your environment
2527

26-
[!INCLUDE [open-source-devops-prereqs-azure-sub.md](../includes/open-source-devops-prereqs-azure-subscription.md)]
27-
[!INCLUDE [ansible-prereqs-cloudshell-use-or-vm-creation1.md](includes/ansible-prereqs-cloudshell-use-or-vm-creation1.md)]
28+
- **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.
29+
- **Install Ansible**: Do one of the following options:
2830

29-
## 2. Create an SSH key pair
31+
- [Install](/azure/ansible/ansible-install-configure#install-ansible-on-an-azure-linux-virtual-machine) and [configure](/azure/ansible/ansible-install-configure#create-azure-credentials) Ansible on a Linux virtual machine
32+
- [Configure Azure Cloud Shell](/azure/cloud-shell/quickstart)
3033

31-
1. Run the following command. When prompted, specify the files to be created in the following directory: `/home/azureuser/.ssh/authorized_keys`.
34+
## Implement the Ansible playbook
3235

33-
```bash
34-
ssh-keygen -m PEM -t rsa -b 4096
35-
```
36+
1. Create a directory in which to test and run the sample Ansible code and make it the current directory.
3637

37-
1. Copy the contents of the public key file. By default, the public key file is named `id_rsa.pub`. The value is a long string starting with "ssh-rsa ". You'll need this value in the next step.
38-
39-
## 3. Implement the Ansible playbook
38+
2. Create a file named main.yml and insert the following code. In the playbook below the resource group name and other relevant properties use environment variables so that they are unique for each run.
4039

41-
1. Create a directory in which to test and run the sample Ansible code and make it the current directory.
40+
```bash
41+
export RANDOM_SUFFIX=$(openssl rand -hex 3)
42+
export REGION="eastus2"
43+
export MY_RESOURCE_GROUP="myResourceGroup$RANDOM_SUFFIX"
44+
export MY_VM_NAME="myVM$RANDOM_SUFFIX"
45+
export MY_VNET_NAME="myVnet$RANDOM_SUFFIX"
46+
export MY_SUBNET_NAME="mySubnet$RANDOM_SUFFIX"
47+
export MY_NIC_NAME="myNIC$RANDOM_SUFFIX"
48+
export MY_PUBLIC_IP_NAME="myPublicIP$RANDOM_SUFFIX"
49+
export MY_NSG_NAME="myNetworkSecurityGroup$RANDOM_SUFFIX"
50+
51+
cat > main.yml <<'EOF'
52+
- name: Create Azure VM
53+
hosts: localhost
54+
connection: local
55+
tasks:
56+
- name: Create resource group
57+
azure_rm_resourcegroup:
58+
name: "{{ lookup('env', 'MY_RESOURCE_GROUP') }}"
59+
location: "{{ lookup('env', 'REGION') }}"
60+
- name: Create virtual network
61+
azure_rm_virtualnetwork:
62+
resource_group: "{{ lookup('env', 'MY_RESOURCE_GROUP') }}"
63+
name: "{{ lookup('env', 'MY_VNET_NAME') }}"
64+
address_prefixes: "10.0.0.0/16"
65+
- name: Add subnet
66+
azure_rm_subnet:
67+
resource_group: "{{ lookup('env', 'MY_RESOURCE_GROUP') }}"
68+
name: "{{ lookup('env', 'MY_SUBNET_NAME') }}"
69+
address_prefix: "10.0.1.0/24"
70+
virtual_network: "{{ lookup('env', 'MY_VNET_NAME') }}"
71+
- name: Create public IP address
72+
azure_rm_publicipaddress:
73+
resource_group: "{{ lookup('env', 'MY_RESOURCE_GROUP') }}"
74+
allocation_method: Static
75+
name: "{{ lookup('env', 'MY_PUBLIC_IP_NAME') }}"
76+
register: output_ip_address
77+
- name: Public IP of VM
78+
debug:
79+
msg: "The public IP is {{ output_ip_address.state.ip_address }}."
80+
- name: Create Network Security Group that allows SSH
81+
azure_rm_securitygroup:
82+
resource_group: "{{ lookup('env', 'MY_RESOURCE_GROUP') }}"
83+
name: "{{ lookup('env', 'MY_NSG_NAME') }}"
84+
rules:
85+
- name: SSH
86+
protocol: Tcp
87+
destination_port_range: 22
88+
access: Allow
89+
priority: 1001
90+
direction: Inbound
91+
- name: Create virtual network interface card
92+
azure_rm_networkinterface:
93+
resource_group: "{{ lookup('env', 'MY_RESOURCE_GROUP') }}"
94+
name: "{{ lookup('env', 'MY_NIC_NAME') }}"
95+
virtual_network: "{{ lookup('env', 'MY_VNET_NAME') }}"
96+
subnet_name: "{{ lookup('env', 'MY_SUBNET_NAME') }}"
97+
security_group: "{{ lookup('env', 'MY_NSG_NAME') }}"
98+
ip_configurations:
99+
- name: ipconfig1
100+
public_ip_address_name: "{{ lookup('env', 'MY_PUBLIC_IP_NAME') }}"
101+
primary: yes
102+
- name: Create VM
103+
azure_rm_virtualmachine:
104+
resource_group: "{{ lookup('env', 'MY_RESOURCE_GROUP') }}"
105+
name: "{{ lookup('env', 'MY_VM_NAME') }}"
106+
vm_size: Standard_DS1_v2
107+
admin_username: azureuser
108+
ssh_password_enabled: false
109+
generate_ssh_keys: yes # This will automatically generate keys if they don't exist
110+
network_interfaces: "{{ lookup('env', 'MY_NIC_NAME') }}"
111+
image:
112+
offer: 0001-com-ubuntu-server-jammy
113+
publisher: Canonical
114+
sku: 22_04-lts
115+
version: latest
116+
EOF
117+
```
42118

43-
1. Create a file named `main.yml` and insert the following code. Replace the `<key_data>` placeholder with the public key value from the previous step.
44-
45-
```yaml
46-
- name: Create Azure VM
47-
hosts: localhost
48-
connection: local
49-
tasks:
50-
- name: Create resource group
51-
azure_rm_resourcegroup:
52-
name: myResourceGroup
53-
location: eastus
54-
- name: Create virtual network
55-
azure_rm_virtualnetwork:
56-
resource_group: myResourceGroup
57-
name: myVnet
58-
address_prefixes: "10.0.0.0/16"
59-
- name: Add subnet
60-
azure_rm_subnet:
61-
resource_group: myResourceGroup
62-
name: mySubnet
63-
address_prefix: "10.0.1.0/24"
64-
virtual_network: myVnet
65-
- name: Create public IP address
66-
azure_rm_publicipaddress:
67-
resource_group: myResourceGroup
68-
allocation_method: Static
69-
name: myPublicIP
70-
register: output_ip_address
71-
- name: Public IP of VM
72-
debug:
73-
msg: "The public IP is {{ output_ip_address.state.ip_address }}."
74-
- name: Create Network Security Group that allows SSH
75-
azure_rm_securitygroup:
76-
resource_group: myResourceGroup
77-
name: myNetworkSecurityGroup
78-
rules:
79-
- name: SSH
80-
protocol: Tcp
81-
destination_port_range: 22
82-
access: Allow
83-
priority: 1001
84-
direction: Inbound
85-
- name: Create virtual network interface card
86-
azure_rm_networkinterface:
87-
resource_group: myResourceGroup
88-
name: myNIC
89-
virtual_network: myVnet
90-
subnet: mySubnet
91-
public_ip_name: myPublicIP
92-
security_group: myNetworkSecurityGroup
93-
- name: Create VM
94-
azure_rm_virtualmachine:
95-
resource_group: myResourceGroup
96-
name: myVM
97-
vm_size: Standard_DS1_v2
98-
admin_username: azureuser
99-
ssh_password_enabled: false
100-
ssh_public_keys:
101-
- path: /home/azureuser/.ssh/authorized_keys
102-
key_data: "<key_data>"
103-
network_interfaces: myNIC
104-
image:
105-
offer: 0001-com-ubuntu-server-jammy
106-
publisher: Canonical
107-
sku: 22_04-lts
108-
version: latest
109-
```
110-
111-
## 4. Run the playbook
112-
113-
[!INCLUDE [ansible-playbook.md](includes/ansible-playbook.md)]
114-
115-
## 5. Verify the results
116-
117-
Run [az vm list](/cli/azure/vm#az-vm-list) to verify the VM was created.
118-
119-
```azurecli
120-
az vm list -d -o table --query "[?name=='myVM']"
121-
```
122-
123-
## 6. Connect to the VM
124-
125-
Run the SSH command to connect to your new Linux VM. Replace the &lt;ip-address> placeholder with the IP address from the previous step.
119+
## Run the playbook
120+
121+
Run the Ansible playbook using the ansible-playbook command.
126122

127123
```bash
128-
ssh azureuser@<ip_address> -i /home/azureuser/.ssh/authorized_keys/id_rsa
124+
ansible-playbook main.yml
125+
```
126+
127+
## Verify the results
128+
129+
Run the following command to verify the VM was created. This command filters the VMs by name.
130+
131+
```azurecli
132+
az vm list -d -o table --query "[?name=='${MY_VM_NAME}']"
133+
```
134+
135+
<!-- expected_similarity=0.3 -->
136+
```JSON
137+
[
138+
{
139+
"name": "myVM",
140+
"powerState": "running",
141+
"publicIps": "xxx.xxx.xxx.xxx"
142+
}
143+
]
129144
```
130145

131-
## Clean up resources
146+
## Connect to the VM
132147

133-
[!INCLUDE [ansible-delete-resource-group.md](includes/ansible-delete-resource-group.md)]
148+
Run the SSH command to connect to your new Linux VM. Replace the <ip_address> placeholder with the IP address obtained from the previous step.
149+
150+
```bash
151+
ssh -o StrictHostKeyChecking=no azureuser@$MY_PUBLIC_IP_NAME
152+
```
134153

135154
## Next steps
136155

137-
> [!div class="nextstepaction"]
156+
> [!div class="nextstepaction"]
138157
> [Manage a Linux virtual machine in Azure using Ansible](./vm-manage.md)

tools/abc_converted.md renamed to scenarios/azure-docs/articles/iot-edge/quickstart-linux.md

File renamed without changes.

scenarios/metadata.json

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1939,5 +1939,83 @@
19391939
}
19401940
]
19411941
}
1942+
},
1943+
{
1944+
"status": "inactive",
1945+
"key": "UseIGOnAKS/use-ig-on-aks.md",
1946+
"title": "Comprehensive Guide to Using Inspektor Gadget in Kubernetes",
1947+
"description": "This Exec Doc provides a detailed walkthrough of a shell script that demonstrates various operations with the Inspektor Gadget in a Kubernetes environment. It explains each functional block, how the gadget plugin is installed, deployed, and used to run examples, export metrics, and verify configurations.",
1948+
"stackDetails": "",
1949+
"sourceUrl": "https://raw.githubusercontent.com/MicrosoftDocs/executable-docs/main/scenarios/UseIGOnAKS/use-ig-on-aks.md",
1950+
"documentationUrl": "",
1951+
"nextSteps": [
1952+
{
1953+
"title": "Real-world scenarios where Inspektor Gadget can help you",
1954+
"url": "https://go.microsoft.com/fwlink/p/?linkid=2260402#use-cases"
1955+
},
1956+
{
1957+
"title": "Explore the available gadgets",
1958+
"url": "https://go.microsoft.com/fwlink/p/?linkid=2260070"
1959+
},
1960+
{
1961+
"title": "Run your own eBPF program",
1962+
"url": "https://go.microsoft.com/fwlink/p/?linkid=2259865"
1963+
}
1964+
],
1965+
"configurations": {
1966+
"permissions": [],
1967+
"configurableParams": [
1968+
{
1969+
"inputType": "textInput",
1970+
"commandKey": "RESOURCE_GROUP",
1971+
"title": "Resource Group Name",
1972+
"defaultValue": ""
1973+
},
1974+
{
1975+
"inputType": "textInput",
1976+
"commandKey": "CLUSTER_NAME",
1977+
"title": "AKS Cluster Name",
1978+
"defaultValue": ""
1979+
}
1980+
]
1981+
}
1982+
},
1983+
{
1984+
"status": "inactive",
1985+
"key": "azure-docs/articles/iot-edge/quickstart-linux.md",
1986+
"title": "Quickstart: Create an Azure IoT Edge Device on Linux",
1987+
"description": "Learn to configure an Azure IoT Edge device on Linux. This guide walks you through creating an IoT Hub, registering a device, and deploying a simulated sensor module.",
1988+
"stackDetails": "",
1989+
"sourceUrl": "https://raw.githubusercontent.com/MicrosoftDocs/executable-docs/main/scenarios/azure-docs/articles/iot-edge/quickstart-linux.md",
1990+
"documentationUrl": "",
1991+
"nextSteps": [
1992+
{
1993+
"title": "Monitor IoT Edge Devices",
1994+
"url": "https://learn.microsoft.com/en-us/azure/iot-edge/tutorial-monitor-with-workbooks"
1995+
}
1996+
],
1997+
"configurations": {
1998+
"permissions": [],
1999+
"configurableParams": []
2000+
}
2001+
},
2002+
{
2003+
"status": "inactive",
2004+
"key": "azure-dev-docs/articles/ansible/vm-configure.md",
2005+
"title": "Create a Linux virtual machines in Azure using Ansible",
2006+
"description": "Learn how to create a Linux virtual machine in Azure using Ansible",
2007+
"stackDetails": "",
2008+
"sourceUrl": "https://raw.githubusercontent.com/MicrosoftDocs/executable-docs/main/scenarios/azure-dev-docs/articles/ansible/vm-configure.md",
2009+
"documentationUrl": "",
2010+
"nextSteps": [
2011+
{
2012+
"title": "Manage a Linux virtual machine in Azure using Ansible",
2013+
"url": "https://learn.microsoft.com/en-us/azure/developer/ansible/vm-manage"
2014+
}
2015+
],
2016+
"configurations": {
2017+
"permissions": [],
2018+
"configurableParams": []
2019+
}
19422020
}
19432021
]

0 commit comments

Comments
 (0)