|
16 | 16 | require => Package[$datadog_agent::params::package_name], |
17 | 17 | } |
18 | 18 | } else { |
| 19 | + # If `datadog-agent-exp` is active, skip service actions and exit early |
| 20 | + $exp_guard_cmd = 'if command -v systemctl >/dev/null 2>&1; then systemctl is-active --quiet datadog-agent-exp && exit 0; fi; if command -v service >/dev/null 2>&1; then service datadog-agent-exp status >/dev/null 2>&1 && exit 0; fi; pgrep -f datadog-packages/datadog-agent/experiment/bin/agent/agent >/dev/null 2>&1 && exit 0;' |
| 21 | + |
19 | 22 | if $service_provider { |
20 | 23 | service { $datadog_agent::params::service_name: |
21 | 24 | ensure => $service_ensure, |
22 | 25 | enable => $service_enable, |
23 | 26 | provider => $service_provider, |
24 | 27 | hasstatus => false, |
25 | 28 | pattern => 'dd-agent', |
| 29 | + # Avoid starting the Agent if a remote update is in progress (exp guard cmd terminates the whole command) |
| 30 | + start => ['/bin/sh', '-c', "${exp_guard_cmd} systemctl start datadog-agent 2>/dev/null || service datadog-agent start 2>/dev/null || /bin/true"], |
| 31 | + # Avoid restarting the Agent if a remote update is in progress (exp guard cmd terminates the whole command) |
| 32 | + restart => ['/bin/sh', '-c', "${exp_guard_cmd} systemctl restart datadog-agent 2>/dev/null || service datadog-agent restart 2>/dev/null || /bin/true"], |
26 | 33 | require => Package[$agent_flavor], |
27 | 34 | } |
28 | 35 | } else { |
|
31 | 38 | enable => $service_enable, |
32 | 39 | hasstatus => false, |
33 | 40 | pattern => 'dd-agent', |
| 41 | + # Avoid starting the Agent if a remote update is in progress (exp guard cmd terminates the whole command) |
| 42 | + start => ['/bin/sh', '-c', "${exp_guard_cmd} systemctl start datadog-agent 2>/dev/null || service datadog-agent start 2>/dev/null || /bin/true"], |
| 43 | + # Avoid restarting the Agent if a remote update is in progress (exp guard cmd terminates the whole command) |
| 44 | + restart => ['/bin/sh', '-c', "${exp_guard_cmd} systemctl restart datadog-agent 2>/dev/null || service datadog-agent restart 2>/dev/null || /bin/true"], |
34 | 45 | require => Package[$agent_flavor], |
35 | 46 | } |
36 | 47 | } |
|
0 commit comments