Skip to content

Commit f87b5b8

Browse files
committed
Learn Editor: Update linux-deploy-defender-for-endpoint-with-chef.md
1 parent 5fd78d6 commit f87b5b8

File tree

1 file changed

+129
-46
lines changed

1 file changed

+129
-46
lines changed

defender-endpoint/linux-deploy-defender-for-endpoint-with-chef.md

Lines changed: 129 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -27,58 +27,133 @@ ms.date: 12/16/2024
2727
- Microsoft Defender for Endpoint Server
2828
- [Microsoft Defender for Servers](/azure/defender-for-cloud/integration-defender-for-endpoint)
2929

30-
Before you begin: Install unzip if it's not already installed.
30+
## Introduction
3131

32-
The Chef components are already installed and a Chef repository exists (chef generate repo \<reponame\>) to store the cookbook that's used to deploy to Defender for Endpoint on Chef managed Linux servers.
32+
This article talks about how to deploy Defender for Endpoint on Linux at scale with chef using two methods, installer script and by manually configuring the repositories for more granular control over the deployment.
3333

34-
You can create a new cookbook in your existing repository by running the following command from inside the cookbooks folder that is in your chef repository:
34+
## Prerequisites and system requirements
35+
36+
For a description of prerequisites and system requirements, see [Microsoft Defender for Endpoint on Linux](/defender-endpoint/microsoft-defender-endpoint-linux).
37+
38+
## Download the onboarding package
39+
40+
Download the onboarding package from Microsoft Defender portal.
41+
42+
In the [Microsoft Defender portal](https://security.microsoft.com/), go to **Settings** > **Endpoints** > **Device management** > **Onboarding**.
43+
44+
In the first drop-down menu, select **Linux Server** as the operating system. In the second drop-down menu, select **Your preferred Linux configuration management tool** as the deployment method.
45+
46+
1. Select **Download onboarding package**. Save the file as `WindowsDefenderATPOnboardingPackage.zip`.
47+
48+
![The option to download the onboarded package.](https://learn.microsoft.com/en-us/defender-endpoint/media/portal-onboarding-linux-2.png)
49+
50+
1. Extract the contents of the archive:
51+
52+
Command:
53+
54+
```
55+
unzip WindowsDefenderATPOnboardingPackage.zip
56+
```
57+
58+
Output:
59+
60+
```
61+
Archive: WindowsDefenderATPOnboardingPackage.zip
62+
inflating: mdatp_onboard.json
63+
```
64+
65+
## Create a directory structure
66+
67+
Before you begin, make sure the Chef components are already installed and a Chef repository exists (chef generate repo <reponame>) to store the cookbook that's used to deploy to Defender for Endpoint on Chef managed Linux servers.
68+
69+
This command creates a new folder structure for the new cookbook called mdatp. You can also use an existing cookbook if you already have one you'd like to use to add the Defender for Endpoint deployment into.
3570

3671
```bash
3772
chef generate cookbook mdatp
3873
```
3974

40-
This command creates a new folder structure for the new cookbook called mdatp. You can also use an existing cookbook if you already have one you'd like to use to add the Defender for Endpoint deployment into.
4175
After the cookbook is created, create a files folder inside the cookbook folder that just got created:
4276

4377
```bash
4478
mkdir mdatp/files
4579
```
4680

47-
Transfer the Linux Server Onboarding zip file that can be downloaded from the Microsoft Defender portal to this new files folder.
48-
49-
[!INCLUDE [Defender for Endpoint repackaging warning](../includes/repackaging-warning.md)]
81+
Copy `mdatp_onboard.json` to the `/tmp` folder.
5082

5183
On the Chef Workstation, navigate to the mdatp/recipes folder. This folder is created when the cookbook was generated. Use your preferred text editor (like vi or nano) to add the following instructions to the end of the default.rb file:
5284

53-
- include_recipe '::onboard_mdatp'
5485
- include_recipe '::install_mdatp'
5586

5687
Then save and close the default.rb file.
5788

58-
Next create a new recipe file named install_mdatp.rb in the recipes folder and add this text to the file:
89+
## Create a cookbook
90+
91+
Cookbook can be created via two methods:
92+
93+
1. create a cookbook using installer script
94+
95+
1. create a cookbook by manually configuring repositories
96+
97+
### Create a cookbook using Installer script
98+
99+
1. Download the installer bash script. Pull the [installer bash script](https://github.com/microsoft/mdatp-xplat/tree/master/linux/installation) from Microsoft GitHub Repository or use the following command to download it.
100+
101+
102+
```bash
103+
wget https://raw.githubusercontent.com/microsoft/mdatp-xplat/refs/heads/master/linux/installation/mde_installer.sh /tmp
104+
```
105+
106+
2. Next create a new recipe file named install_mdatp.rb in the recipes folder `~/cookbooks/mdatp/recipes/install_mdatp.rb` and add this text to the file. You can also download the file directly from [GitHub](https://github.com/microsoft/mdatp-xplat/blob/master/linux/installation/third_party_installation_playbooks/chef.install_mdatp_simplified.rb)
107+
108+
```bash
109+
mdatp = "/etc/opt/microsoft/mdatp"
110+
111+
#Download the onboarding json from tenant, keep the same at specific location
112+
onboarding_json = "/tmp/mdatp_onboard.json"
113+
114+
#Download the installer script from: https://github.com/microsoft/mdatp-xplat/blob/master/linux/installation/mde_installer.sh
115+
#Place the same at specific location, edit this if needed
116+
mde_installer= "/tmp/mde_installer.sh"
117+
118+
119+
## Invokve the mde-installer script
120+
bash 'Installing mdatp using mde-installer' do
121+
code <<-EOS
122+
chmod +x #{mde_installer}
123+
#{mde_installer} --install --onboard #{onboarding_json}
124+
EOS
125+
end
126+
```
127+
128+
>[!Note]
129+
>Installer script also supports other parameters such as channel, realtime protection, version, etc. To select from the list of available options, check help.
130+
>```./mde_installer.sh --help```
131+
132+
133+
### Create a cookbook by manually configuring repositories
134+
135+
Create a new recipe file named install_mdatp.rb in the recipes folder `~/cookbooks/mdatp/recipes/install_mdatp.rb` and add this text to the file. You can also download the file directly from [Github](https://github.com/microsoft/mdatp-xplat/blob/master/linux/installation/third_party_installation_playbooks/chef.install_mdatp_manual.rb)
59136
60137
```powershell
61138
#Add Microsoft Defender
62-
Repo
63139
case node['platform_family']
64140
when 'debian'
65-
apt_repository 'MDAPRepo' do
141+
apt_repository 'MDATPRepo' do
66142
arch 'amd64'
67143
cache_rebuild true
68144
cookbook false
69145
deb_src false
70146
key 'BC528686B50D79E339D3721CEB3E94ADBE1229CF'
71147
keyserver "keyserver.ubuntu.com"
72-
distribution 'focal'
148+
distribution 'jammy'
73149
repo_name 'microsoft-prod'
74150
components ['main']
75-
trusted true
76-
uri "https://packages.microsoft.com/config/ubuntu/20.04/prod"
151+
uri "https://packages.microsoft.com/ubuntu/22.04/prod"
77152
end
78-
apt_package "mdatp"
153+
apt_package "mdatp"
79154
when 'rhel'
80155
yum_repository 'microsoft-prod' do
81-
baseurl "https://packages.microsoft.com/config/rhel/7/prod/"
156+
baseurl "https://packages.microsoft.com/rhel/7/prod/"
82157
description "Microsoft Defender for Endpoint"
83158
enabled true
84159
gpgcheck true
@@ -90,15 +165,10 @@ when 'rhel'
90165
dnf_package "mdatp"
91166
end
92167
end
93-
```
94-
95-
You need to modify the version number, distribution, and repo name to match the version you're deploying to and the channel you'd like to deploy.
96-
Next you should create an onboard_mdatp.rb file in the mdatp/recipies folder. Add the following text to that file:
97168
98-
```powershell
99169
#Create MDATP Directory
100170
mdatp = "/etc/opt/microsoft/mdatp"
101-
zip_path = "/path/to/chef-repo/cookbooks/mdatp/files/WindowsDefenderATPOnboardingPackage.zip"
171+
onboarding_json = "/tmp/mdatp_onboard.json"
102172
103173
directory "#{mdatp}" do
104174
owner 'root'
@@ -107,37 +177,47 @@ directory "#{mdatp}" do
107177
recursive true
108178
end
109179
110-
#Extract WindowsDefenderATPOnboardingPackage.zip into /etc/opt/microsoft/mdatp
111-
112-
bash 'Extract Onboarding Json MDATP' do
113-
code <<-EOS
114-
unzip #{zip_path} -d #{mdatp}
115-
EOS
116-
not_if { ::File.exist?('/etc/opt/microsoft/mdatp/mdatp_onboard.json') }
117-
end
118-
```
119-
120-
Make sure to update the path name to the location of the onboarding file.
121-
To test deploy it on the Chef workstation, run ``sudo chef-client -z -o mdatp``.
122-
After your deployment, you should consider creating and deploying a configuration file to the servers based on [Set preferences for Microsoft Defender for Endpoint on Linux](linux-preferences.md).
123-
After creating and testing your configuration file, you can put it into the `cookbook/mdatp/files` folder where you also placed the onboarding package. Then you can create a settings_mdatp.rb file in the mdatp/recipies folder and add this text:
124-
125-
```powershell
126-
#Copy the configuration file
127-
cookbook_file '/etc/opt/microsoft/mdatp/managed/mdatp_managed.json' do
128-
source 'mdatp_managed.json'
180+
#Onboarding using tenant json
181+
file "#{mdatp}/mdatp_onboard.json" do
182+
content lazy { ::File.open(onboarding_json).read }
129183
owner 'root'
130184
group 'root'
131-
mode '0755'
132-
action :create
185+
mode '0644'
186+
action :create_if_missing
133187
end
134188
```
135189
136-
To include this step as part of the recipe just add `include_recipe ':: settings_mdatp` to your default.rb file within the recipe folder.
190+
>[!Note]
191+
> You can modify the os distribution, distribution version number, channel (prod/insider-fast, insiders-slow) and repo name to match the version you're deploying to and the channel you'd like to deploy to..
192+
Run `chef-client --local-mode --runlist 'recipe[mdatp]'` to test the cookbook on the Chef workstation.
193+
194+
## Troubleshoot installation issues
195+
196+
For self-troubleshooting, do the following
197+
198+
1. For information on how to find the log that's generated automatically when an installation error occurs, see [Log installation issues](linux-resources.md#log-installation-issues).
199+
200+
2. For information about common installation issues, see [Installation issues](/defender-endpoint/linux-support-install).
201+
202+
3. If health of the device is `false`, see [Defender for Endpoint agent health issues](/defender-endpoint/health-status).
203+
204+
4. For product performance issues, see [Troubleshoot performance issues](/defender-endpoint/linux-support-perf).
205+
206+
5. For proxy and connectivity issues, see [Troubleshoot cloud connectivity issues](/defender-endpoint/linux-support-connectivity).
137207
138-
You can also use crontab to schedule automatic updates [Schedule an update for Microsoft Defender for Endpoint on Linux](linux-update-MDE-Linux.md).
208+
To get support from Microsoft, open a support ticket, and provide the log files created by using the [client analyzer](/defender-endpoint/run-analyzer-macos-linux).
139209
140-
Uninstall MDATP cookbook:
210+
## How to configure policies for Microsoft Defender on Linux
211+
212+
You can configure antivirus or EDR settings on your endpoints using following methods:
213+
214+
- See [Set preferences for Microsoft Defender for Endpoint on Linux](/defender-endpoint/linux-preferences).
215+
- See [security settings management](/mem/intune/protect/mde-security-integration) to configure settings in the Microsoft Defender portal.
216+
217+
218+
## Uninstall MDATP cookbook
219+
220+
To uninstall Defender, save the following as cookbook `~/cookbooks/mdatp/recipes/uninstall_mdatp.rb`.
141221
142222
```powershell
143223
#Uninstall the Defender package
@@ -159,4 +239,7 @@ then
159239
end
160240
end
161241
```
242+
243+
To include this step as part of the recipe just add `include_recipe ':: uninstall_mdatp` to your `default.rb` file within the recipe folder. Also make sure to remove the `include_recipe '::install_mdatp'` from the `default.rb` file.
244+
162245
[!INCLUDE [Microsoft Defender for Endpoint Tech Community](../includes/defender-mde-techcommunity.md)]

0 commit comments

Comments
 (0)