Microsoft defender deployment through ansible

I have started Microsoft defender deployment through ansible but when i add microsoft apt repository for mdatp it not works so please revert me. Also i don’t know the meaning of “[codename] main”

  • name: Add Microsoft apt repository for MDATP
    apt_repository:
    repo: deb [arch=arm64,armhf,amd64] https://packages.microsoft.com/[distro]/[version]/prod [codename] main
    update_cache: yes
    state: present
    filename: microsoft-[channel]
    when: ansible_os_family == “Debian”

You can make your code and playbook tasks more readable if you start and end the line with three backticks (`)

like this

Anyway, I take it you’re following Microsoft’s manual installation guide Deploy Microsoft Defender for Endpoint on Linux manually - Microsoft Defender for Endpoint | Microsoft Learn

You can’t really just continue down the road it looks like you’re going down, you’re going to need to understand which Linux OS flavors and what versions of the OS you’re going to be installing MDATP upon. I say this because going to Index of config/ shows different agents for different versions of Debian, Ubuntu, SLES, RHEL, Rocky, and a few others.

If you wanted to instantiate a repository for MDATP for Ubuntu 24.04, it looks like you’d use a repository set up like this https://packages.microsoft.com/config/ubuntu/24.04/prod.list

If you’re installing on Debian 11, you’d need this https://packages.microsoft.com/config/debian/11/prod.list

And so on.

So you’re going to need to find a way to iterate over your systems and figure out which repository belongs where. There are options with templating but it is still going to require effort and understanding your target environment.

1 Like