Skip to content

Commit d4c19df

Browse files
authored
Merge pull request #2200 from MicrosoftDocs/main
pushing Linux updates live
2 parents df42682 + e3919c1 commit d4c19df

File tree

1 file changed

+207
-22
lines changed

1 file changed

+207
-22
lines changed

defender-endpoint/linux-install-with-ansible.md

Lines changed: 207 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -31,25 +31,35 @@ ms.date: 10/11/2024
3131
3232
This article describes how to deploy Defender for Endpoint on Linux using Ansible. A successful deployment requires the completion of all of the following tasks:
3333

34-
- [Download the onboarding package](#download-the-onboarding-package)
35-
- [Create Ansible YAML files](#create-ansible-yaml-files)
36-
- [Deployment](#deployment)
37-
- [References](#references)
34+
- [Prerequisites and system requirements](#prerequisites-and-system-requirements-applicable-to-both-the-methods)
35+
- [Download the onboarding package](#download-the-onboarding-package-applicable-to-both-the-methods)
36+
- [Deploy Defender for Endpoint on Linux using mde_installer.sh with Ansible](#deploy-defender-for-endpoint-using-mde_installersh-with-ansible)
37+
- [Deploy Defender for Endpoint on Linux using Ansible by configuring repositories manually](#deploy-defender-for-endpoint-using-ansible-by-configuring-repositories-manually)
3838

3939

4040
[!INCLUDE [Microsoft Defender for Endpoint third-party tool support](../includes/support.md)]
4141

42-
## Prerequisites and system requirements
42+
## Introduction
4343

44-
Before you get started, see [the main Defender for Endpoint on Linux page](microsoft-defender-endpoint-linux.md) for a description of prerequisites and system requirements for the current software version.
44+
Deploy Microsoft Defender for Endpoint on Linux Servers using Ansible to automate the deployment process for machines at scale. Following are the two methods to automate.
45+
46+
1. Using the installer script (recommended). This method greatly simplifies the automation process and helps to install the Defender for Endpoint agent and onboard the device to the Microsoft Defender portal using just a few steps without having to configure for different distros separately.
47+
48+
2. Manually configuring repositories for each distro. This method allows you to automate the deployment process by manually configuring repositories, installing the agent, and onboarding the device for each distro. This method  gives more granular control over the deployment process.
49+
50+
## Prerequisites and system requirements applicable to both the methods
51+
52+
Before you get started, see [the main Defender for Endpoint on Linux page](microsoft-defender-endpoint-linux.md) for a description of prerequisites and system requirements.
4553

4654
In addition, for Ansible deployment, you need to be familiar with Ansible administration tasks, have Ansible configured, and know how to deploy playbooks and tasks. Ansible has many ways to complete the same task. These instructions assume availability of supported Ansible modules, such as *apt* and *unarchive* to help deploy the package. Your organization might use a different workflow. Refer to the [Ansible documentation](https://docs.ansible.com/) for details.
4755

48-
- Ansible needs to be installed on at least one computer (Ansible calls this the control node).
49-
- SSH must be configured for an administrator account between the control node and all managed nodes (devices that will have Defender for Endpoint installed on them), and it is recommended to be configured with public key authentication.
56+
- Ansible needs to be installed on at least one computer (Ansible calls this computer the control node).
57+
58+
- SSH must be configured for an administrator account between the control node and all managed nodes (devices that have Defender for Endpoint installed on them), and it's recommended to be configured with public key authentication.
59+
5060
- The following software must be installed on all managed nodes:
5161
- curl
52-
- python-apt (if you are deploying on distributions using apt as a package manager)
62+
- python-apt (if you're deploying on distributions using apt as a package manager)
5363

5464
- All managed nodes must be listed in the following format in the `/etc/ansible/hosts` or relevant file:
5565

@@ -65,15 +75,17 @@ In addition, for Ansible deployment, you need to be familiar with Ansible admini
6575
ansible -m ping all
6676
```
6777

68-
## Download the onboarding package
78+
## Download the onboarding package applicable to both the methods
6979

7080
Download the onboarding package from Microsoft Defender portal.
7181

7282
[!INCLUDE [Defender for Endpoint repackaging warning](../includes/repackaging-warning.md)]
7383

74-
1. In Microsoft Defender portal, go to **Settings > Endpoints > Device management > Onboarding**.
84+
1. In the [Microsoft Defender portal](https://security.microsoft.com), go to **Settings** > **Endpoints** > **Device management** > **Onboarding**.
85+
7586
2. 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.
76-
3. Select **Download onboarding package**. Save the file as WindowsDefenderATPOnboardingPackage.zip.
87+
88+
3. Select **Download onboarding package**. Save the file as `WindowsDefenderATPOnboardingPackage.zip`.
7789

7890
:::image type="content" source="media/portal-onboarding-linux-2.png" alt-text="The Download onboarding package option":::
7991

@@ -94,7 +106,161 @@ Download the onboarding package from Microsoft Defender portal.
94106
inflating: mdatp_onboard.json
95107
```
96108

97-
## Create Ansible YAML files
109+
## Deploy Defender for Endpoint using mde_installer.sh with Ansible
110+
111+
Before you begin, make sure to download the onboarding package and meet the prerequisites to deploy Defender for Endpoint on Linux using the installer bash script.
112+
113+
### Download the installer bash script
114+
115+
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.
116+
117+
```bash
118+
wget https://raw.githubusercontent.com/microsoft/mdatp-xplat/refs/heads/master/linux/installation/mde_installer.sh
119+
```
120+
121+
### Create Ansible YAML files
122+
123+
Create installation YAML file. You can also download the file directly from [GitHub](/defender-endpoint/linux-support-events)
124+
125+
```bash
126+
- name: Install and Onboard MDE
127+
hosts: servers
128+
tasks:
129+
- name: Create a directory if it does not exist
130+
ansible.builtin.file:
131+
path: /tmp/mde_install
132+
state: directory
133+
mode: '0755'
134+
135+
- name: Copy Onboarding script
136+
ansible.builtin.copy:
137+
src: "{{ onboarding_json }}"
138+
dest: /tmp/mde_install/mdatp_onboard.json
139+
- name: Install MDE on host
140+
ansible.builtin.script: "{{ mde_installer_script }} --install --channel {{ channel | default('insiders-fast') }} --onboard /tmp/mde_install/mdatp_onboard.json"
141+
register: script_output
142+
args:
143+
executable: sudo
144+
145+
- name: Display the installation output
146+
debug:
147+
msg: "Return code [{{ script_output.rc }}] {{ script_output.stdout }}"
148+
149+
- name: Display any installation errors
150+
debug:
151+
msg: "{{ script_output.stderr }}"
152+
```
153+
154+
### Apply the playbook
155+
156+
Apply the playbook by using the following command, replacing the corresponding paths and channel per your requirements:
157+
158+
```bash
159+
ansible-playbook -i /etc/ansible/hosts /etc/ansible/playbooks/install_mdatp.yml --extra-vars "onboarding_json=<path to mdatp_onboard.json > mde_installer_script=<path to mde_installer.sh> channel=<channel to deploy for: insiders-fast / insiders-slow / prod> "
160+
```
161+
162+
### Verify if the deployment is successful
163+
164+
1. In the [Microsoft Defender portal](https://security.microsoft.com), open the device inventory. It might take 5-20 mins for the device to show up in the portal.
165+
166+
2. Perform the following post-installation checks, which include checks like health, connectivity, antivirus, and EDR detection tests to ensure successful deployment and working of Defender for Endpoint.
167+
168+
```bash
169+
170+
- name: Run post-installation basic MDE test
171+
hosts: myhosts
172+
tasks:
173+
- name: Check health
174+
ansible.builtin.command: mdatp health --field healthy
175+
register: health_status
176+
177+
- name: MDE health test failed
178+
fail: msg="MDE is not healthy. health status => \n{{ health_status.stdout }}\nMDE deployment not complete"
179+
when: health_status.stdout != "true"
180+
181+
- name: Run connectivity test
182+
ansible.builtin.command: mdatp connectivity test
183+
register: connectivity_status
184+
185+
- name: Connectivity failed
186+
fail: msg="Connectivity failed. Connectivity result => \n{{ connectivity_status.stdout }}\n MDE deployment not complete"
187+
when: connectivity_status.rc != 0
188+
189+
- name: Check RTP status
190+
ansible.builtin.command: mdatp health --field real_time_protection_enabled
191+
register: rtp_status
192+
193+
- name: Enable RTP
194+
ansible.builtin.command: mdatp config real-time-protection --value enabled
195+
become: yes
196+
become_user: root
197+
when: rtp_status.stdout != "true"
198+
199+
- name: Pause for 5 second to enable RTP
200+
ansible.builtin.pause:
201+
seconds: 5
202+
203+
- name: Download EICAR
204+
ansible.builtin.get_url:
205+
url: https://secure.eicar.org/eicar.com.txt
206+
dest: /tmp/eicar.com.txt
207+
208+
- name: Pause for 5 second to detect eicar
209+
ansible.builtin.pause:
210+
seconds: 5
211+
212+
- name: Check for EICAR file
213+
stat: path=/tmp/eicar.com.txt
214+
register: eicar_test
215+
216+
- name: EICAR test failed
217+
fail: msg="EICAR file not deleted. MDE deployment not complete"
218+
when: eicar_test.stat.exists
219+
220+
- name: MDE Deployed
221+
debug:
222+
msg: "MDE succesfully deployed"
223+
224+
225+
```
226+
227+
### How to uninstall Microsoft Defender for Endpoint on Linux Servers
228+
229+
Create uninstallation YAML file (for example: /etc/ansible/playbooks/uninstall_mdatp.yml) which uses mde_installer.sh. You can also download the file directly from [GitHub](/defender-endpoint/linux-support-events)
230+
231+
```bash
232+
233+
- name: Uninstall MDE
234+
hosts: myhosts
235+
tasks:
236+
- name: Uninstall MDE
237+
ansible.builtin.script: "{{ mde_installer_script }} --remove"
238+
register: script_output
239+
args:
240+
executable: sudo
241+
242+
243+
- name: Display the installation output
244+
debug:
245+
msg: "Return code [{{ script_output.rc }}] {{ script_output.stdout }}"
246+
247+
- name: Display any installation errors
248+
debug:
249+
msg: "{{ script_output.stderr }}"
250+
251+
```
252+
253+
Run the following command to uninstall Defender for Endpoint by using the playbook:
254+
255+
```bash
256+
ansible-playbook -i  /etc/ansible/hosts /etc/ansible/playbooks/uninstall_mdatp.yml --extra-vars "mde_installer_script=<path to mde_installer.sh>"
257+
```
258+
259+
## Deploy Defender for Endpoint using Ansible by configuring repositories manually
260+
261+
Follow the steps in this section after downloading the onboarding package and meeting prerequisites to deploy Defender for Endpoint by manually configuring the repositories for each Linux distribution.
262+
263+
### Create Ansible YAML files
98264
99265
Create a subtask or role files that contribute to a playbook or task.
100266
@@ -183,7 +349,7 @@ Create a subtask or role files that contribute to a playbook or task.
183349
184350
- Create the Ansible install and uninstall YAML files.
185351
186-
- For apt-based distributions use the following YAML file:
352+
- For apt-based distributions, use the following YAML file:
187353
188354
```bash
189355
cat install_mdatp.yml
@@ -216,7 +382,7 @@ Create a subtask or role files that contribute to a playbook or task.
216382
state: absent
217383
```
218384
219-
- For dnf-based distributions use the following YAML file:
385+
- For dnf-based distributions, use the following YAML file:
220386
221387
```bash
222388
cat install_mdatp_dnf.yml
@@ -249,9 +415,9 @@ Create a subtask or role files that contribute to a playbook or task.
249415
state: absent
250416
```
251417
252-
## Deployment
418+
## Apply the playbook
253419
254-
Now run the tasks files under `/etc/ansible/playbooks/` or relevant directory.
420+
In this step, you apply the playbook. Run the tasks files under `/etc/ansible/playbooks/` or relevant directory.
255421
256422
- Installation:
257423
@@ -277,15 +443,34 @@ Now run the tasks files under `/etc/ansible/playbooks/` or relevant directory.
277443
ansible-playbook /etc/ansible/playbooks/uninstall_mdatp.yml -i /etc/ansible/hosts
278444
```
279445
280-
## Log installation issues
446+
## Troubleshoot installation issues
447+
448+
For self-troubleshooting, do the following
449+
450+
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).
451+
452+
2. For information about common installation issues, see [Installation issues](/defender-endpoint/linux-support-install).
453+
454+
3. If health of the device is `false`, see [Defender for Endpoint agent health issues](/defender-endpoint/health-status).
281455
282-
See [Log installation issues](linux-resources.md#log-installation-issues) for more information on how to find the automatically generated log that is created by the installer when an error occurs.
456+
4. For product performance issues, see [Troubleshoot performance issues](/defender-endpoint/linux-support-perf).
457+
458+
5. For proxy and connectivity issues, see [Troubleshoot cloud connectivity issues](/defender-endpoint/linux-support-connectivity).
459+
460+
6. 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).
461+
462+
## How to configure policies for Microsoft Defender on Linux
463+
464+
You can configure antivirus or EDR settings on your endpoints using following methods:
465+
466+
- See [Set preferences for Microsoft Defender for Endpoint on Linux](/defender-endpoint/linux-preferences).
467+
- See [security settings management](/mem/intune/protect/mde-security-integration) to configure settings in the Microsoft Defender portal.
283468
284469
## Operating system upgrades
285470
286471
When upgrading your operating system to a new major version, you must first uninstall Defender for Endpoint on Linux, install the upgrade, and finally reconfigure Defender for Endpoint on Linux on your device.
287472
288-
## References
473+
## See also
289474
290475
- [Add or remove YUM repositories](https://docs.ansible.com/ansible/latest/collections/ansible/builtin/yum_repository_module.html)
291476
@@ -295,6 +480,6 @@ When upgrading your operating system to a new major version, you must first unin
295480
296481
- [Manage apt-packages](https://docs.ansible.com/ansible/latest/collections/ansible/builtin/apt_module.html)
297482
298-
## See also
299-
- [Investigate agent health issues](health-status.md)
483+
- [Missing event issues](/defender-endpoint/linux-support-events)
484+
300485
[!INCLUDE [Microsoft Defender for Endpoint Tech Community](../includes/defender-mde-techcommunity.md)]

0 commit comments

Comments
 (0)