Skip to content

Commit f6ea046

Browse files
authored
Merge pull request #234107 from divargas-msft/patch-4
[Doc-a-thon] Updating disable-provisioning.md
2 parents bf1b95f + 0ccbcb5 commit f6ea046

File tree

1 file changed

+58
-40
lines changed

1 file changed

+58
-40
lines changed

articles/virtual-machines/linux/disable-provisioning.md

Lines changed: 58 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ ms.subservice: imaging
88
ms.topic: how-to
99
ms.workload: infrastructure
1010
ms.custom: devx-track-azurecli
11-
ms.date: 07/06/2020
11+
ms.date: 04/11/2023
1212
ms.author: danis
1313
ms.reviewer: cynthn
1414
---
@@ -22,6 +22,7 @@ Before removing the Linux Agent, you must understand of what VM will not be able
2222
Azure virtual machine (VM) [extensions](../extensions/overview.md) are small applications that provide post-deployment configuration and automation tasks on Azure VMs, extensions are installed and managed by the Azure control plane. It is the job of the [Azure Linux Agent](../extensions/agent-linux.md) to process the platform extension commands and ensure the correct state of the extension inside the VM.
2323

2424
The Azure platform hosts many extensions that range from VM configuration, monitoring, security, and utility applications. There is a large choice of first and third-party extensions, examples of key scenarios that extensions are used for:
25+
2526
* Supporting first party Azure services, such as Azure Backup, Monitoring, Disk Encryption, Security, Site Replication and others.
2627
* SSH / Password resets
2728
* VM configuration - Running custom scripts, installing Chef, Puppet agents etc..
@@ -32,19 +33,22 @@ The Azure platform hosts many extensions that range from VM configuration, monit
3233

3334
There are several ways to disable extension processing, depending on your needs, but before you continue, you **MUST** remove all extensions deployed to the VM, for example using the Azure CLI, you can [list](/cli/azure/vm/extension#az-vm-extension-list) and [delete](/cli/azure/vm/extension#az-vm-extension-delete):
3435

35-
```azurecli
36+
```azurecli-interactive
3637
az vm extension delete -g MyResourceGroup --vm-name MyVm -n extension_name
3738
```
39+
3840
> [!Note]
39-
>
41+
>
4042
> If you do not do the above, the platform will try to send the extension configuration and timeout after 40min.
4143
4244
### Disable at the control plane
45+
4346
If you are not sure whether you will need extensions in the future, you can leave the Linux Agent installed on the VM, then disable extension processing capability from the platform. This is option is available in `Microsoft.Compute` api version `2018-06-01` or higher, and does not have a dependency on the Linux Agent version installed.
4447

45-
```azurecli
48+
```azurecli-interactive
4649
az vm update -g <resourceGroup> -n <vmName> --set osProfile.allowExtensionOperations=false
4750
```
51+
4852
You can easily reenable this extension processing from the platform, with the above command, but set it to 'true'.
4953

5054
## Remove the Linux Agent from a running VM
@@ -55,108 +59,122 @@ Ensure you have **removed** all existing extensions from the VM before, as per a
5559

5660
If you just remove the Linux Agent, and not the associated configuration artifacts, you can reinstall at a later date. Run one of the following, as root, to remove the Azure Linux Agent:
5761

58-
#### For Ubuntu >=18.04
62+
#### For Ubuntu 18.04+
63+
5964
```bash
60-
apt -y remove walinuxagent
65+
sudo apt -y remove walinuxagent
6166
```
6267

63-
#### For Redhat >= 7.7
68+
#### For Redhat 7.X, 8.X and 9.X
69+
6470
```bash
65-
yum -y remove WALinuxAgent
71+
sudo yum -y remove WALinuxAgent
6672
```
6773

68-
#### For SUSE
74+
#### For SUSE 12.X, 15.X
75+
6976
```bash
70-
zypper --non-interactive remove python-azure-agent
77+
sudo zypper --non-interactive remove python-azure-agent
7178
```
7279

7380
### Step 2: (Optional) Remove the Azure Linux Agent artifacts
74-
> [!IMPORTANT]
81+
82+
> [!IMPORTANT]
7583
>
7684
> You can remove all associated artifacts of the Linux Agent, but this will mean you cannot reinstall it at a later date. Therefore, it is strongly recommended you consider disabling the Linux Agent first, removing the Linux Agent using the above only.
7785
7886
If you know you will not ever reinstall the Linux Agent again, then you can run the following:
7987

80-
#### For Ubuntu >=18.04
88+
#### For Ubuntu 18.04+
89+
8190
```bash
82-
apt -y purge walinuxagent
83-
rm -rf /var/lib/waagent
84-
rm -f /var/log/waagent.log
91+
sudo pt -y purge walinuxagent
92+
sudo cp -rp /var/lib/waagent /var/lib/waagent.bkp
93+
sudo rm -rf /var/lib/waagent
94+
sudo rm -f /var/log/waagent.log
8595
```
8696

87-
#### For Redhat >= 7.7
97+
#### For Redhat 7.X, 8.X, 9.X
98+
8899
```bash
89-
yum -y remove WALinuxAgent
90-
rm -f /etc/waagent.conf.rpmsave
91-
rm -rf /var/lib/waagent
92-
rm -f /var/log/waagent.log
100+
sudo yum -y remove WALinuxAgent
101+
sudo rm -f /etc/waagent.conf.rpmsave
102+
sudo rm -rf /var/lib/waagent
103+
sudo rm -f /var/log/waagent.log
93104
```
94105

95-
#### For SUSE
106+
#### For SUSE 12.X, 15.X
107+
96108
```bash
97-
zypper --non-interactive remove python-azure-agent
98-
rm -f /etc/waagent.conf.rpmsave
99-
rm -rf /var/lib/waagent
100-
rm -f /var/log/waagent.log
109+
sudo zypper --non-interactive remove python-azure-agent
110+
sudo rm -f /etc/waagent.conf.rpmsave
111+
sudo rm -rf /var/lib/waagent
112+
sudo rm -f /var/log/waagent.log
101113
```
102114

103115
## Preparing an image without the Linux Agent
116+
104117
If you have an image that already contains cloud-init, and you want to remove the Linux agent, but still provision using cloud-init, run the steps in Step 2 (and optionally Step 3) as root to remove the Azure Linux Agent and then the following will remove the cloud-init configuration and cached data, and prepare the VM to create a custom image.
105118

106119
```bash
107-
cloud-init clean --logs --seed
120+
sudo cloud-init clean --logs --seed
108121
```
109122

110123
## Deprovision and create an image
124+
111125
The Linux Agent has the ability to clean up some of the existing image metadata, with the step "waagent -deprovision+user", however, after it has been removed, you will need to perform actions such as the below, and remove any other sensitive data from it.
112126

113-
- Remove all existing ssh host keys
127+
* Remove all existing ssh host keys
114128

115129
```bash
116-
rm /etc/ssh/ssh_host_*key*
130+
sudo rm /etc/ssh/ssh_host_*key*
117131
```
118-
- Delete the admin account
132+
133+
* Delete the admin account
119134

120135
```bash
121-
touch /var/run/utmp
122-
userdel -f -r <admin_user_account>
136+
sudo touch /var/run/utmp
137+
sudo userdel -f -r <admin_user_account>
123138
```
124-
- Delete the root password
139+
140+
* Delete the root password
125141

126142
```bash
127-
passwd -d root
143+
sudo passwd -d root
128144
```
129145

130146
Once you have completed the above, you can create the custom image using the Azure CLI.
131147

148+
### Create a regular managed image
132149

133-
**Create a regular managed image**
134-
```azurecli
150+
```azurecli-interactive
135151
az vm deallocate -g <resource_group> -n <vm_name>
136152
az vm generalize -g <resource_group> -n <vm_name>
137153
az image create -g <resource_group> -n <image_name> --source <vm_name>
138154
```
139155

140-
**Create an image version in a Azure Compute Gallery**
156+
### Create an image version in a Azure Compute Gallery
141157

142-
```azurecli
158+
```azurecli-interactive
143159
az sig image-version create \
144160
-g $sigResourceGroup
145161
--gallery-name $sigName
146162
--gallery-image-definition $imageDefName
147163
--gallery-image-version 1.0.0
148164
--managed-image /subscriptions/00000000-0000-0000-0000-00000000xxxx/resourceGroups/imageGroups/providers/images/MyManagedImage
149165
```
166+
150167
### Creating a VM from an image that does not contain a Linux Agent
168+
151169
When you create the VM from the image with no Linux Agent, you need to ensure the VM deployment configuration indicates extensions are not supported on this VM.
152170

153-
> [!NOTE]
154-
>
171+
> [!NOTE]
172+
>
155173
> If you do not do the above, the platform will try to send the extension configuration and timeout after 40min.
156174
157175
To deploy the VM with extensions disabled, you can use the Azure CLI with [--enable-agent](/cli/azure/vm#az-vm-create).
158176

159-
```azurecli
177+
```azurecli-interactive
160178
az vm create \
161179
--resource-group $resourceGroup \
162180
--name $prodVmName \

0 commit comments

Comments
 (0)