From 01396585e8dd7f2b6ebb6106ea96f94fae021fcf Mon Sep 17 00:00:00 2001 From: Marethyu <45374460+Pythyu@users.noreply.github.com> Date: Thu, 6 Apr 2023 15:01:51 +0200 Subject: [PATCH] [ansible] Ensure user/group selected for macOS systemwide installation actually exist (#479) --- tasks/pkg-macos.yml | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/tasks/pkg-macos.yml b/tasks/pkg-macos.yml index fb17f24f..191003f4 100644 --- a/tasks/pkg-macos.yml +++ b/tasks/pkg-macos.yml @@ -6,6 +6,17 @@ msg: "The Datadog ansible role does not currently support Agent 5 on macOS" when: datadog_agent_major_version|int == 5 +- name: Check if the macOS user for Agent service exists + command: id -u "{{ datadog_macos_user }}" + register: mac_user_check + changed_when: false + ignore_errors: true + +- name: Fail if the macOS user for Agent service doesn't exist + fail: + msg: "The Datadog ansible role wasn't able to find the user : {{ datadog_macos_user }}" + when: mac_user_check.rc != 0 + - include_tasks: pkg-macos/macos_agent_latest.yml when: (not datadog_skip_install) and (datadog_agent_macos_version is not defined)