Skip to content

Commit

Permalink
Add NPM support for Windows (#335)
Browse files Browse the repository at this point in the history
Redo of #326, with fixes to avoid undefined variable problems on Windows.

Co-authored-by: Derek Brown <[email protected]>
Co-authored-by: Lee Avital <[email protected]>
Co-authored-by: ruthnaebeck <[email protected]>
Co-authored-by: Albert Vaca Cintora <[email protected]>
  • Loading branch information
5 people authored Mar 24, 2021
1 parent e752ea9 commit 111b192
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 5 deletions.
9 changes: 6 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -163,9 +163,11 @@ The following variables are available for live processes:

#### System probe

The [Network Performance Monitoring][7] (NPM) system probe is configured under the `system_probe_config` variable. Any variables nested underneath are written to the `system-probe.yaml`.
The system probe is configured under the `network_config` variable. Any variables nested underneath are written to the `system-probe.yaml`.

**Note**: The system probe only works on Linux with the Agent v6+.
[Network Performance Monitoring][7] (NPM) is configured under the `network_config` variable. Any variables nested underneath are written to the `system-probe.yaml`, in the `network_config` section.

**Note**: The system probe works on Linux with Agent v6+. NPM is supported on Windows with Agent v6.27+ and v7.27+.

#### Example configuration

Expand All @@ -176,8 +178,9 @@ datadog_config:
scrub_args: true
custom_sensitive_words: ['consul_token','dd_api_key']
system_probe_config:
enabled: true
sysprobe_socket: /opt/datadog-agent/run/sysprobe.sock
network_config:
enabled: true
```

Once modification is complete, follow the steps below:
Expand Down
7 changes: 6 additions & 1 deletion defaults/main.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
---
role_version: 4.7.1

# default system-probe.yaml options
system_probe_config:
enabled: false

network_config:
enabled: false

# define if the datadog-agent services should be enabled
datadog_enabled: yes

# default datadog.conf options
# default datadog.conf / datadog.yaml options
datadog_config: {}

# default checks enabled
Expand Down
6 changes: 6 additions & 0 deletions tasks/agent-win.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,12 @@
with_items: "{{ datadog_checks|list }}"
notify: restart datadog-agent-win

- name: Create system-probe configuration file
win_template:
src: system-probe.yaml.j2
dest: "{{ datadog_windows_config_root }}\\system-probe.yaml"
notify: restart datadog-agent-win

- name: Ensure datadog-agent is running
win_service:
name: datadogagent
Expand Down
8 changes: 7 additions & 1 deletion tasks/pkg-windows-opts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -85,4 +85,10 @@

- name: Set Test
set_fact:
win_install_args: "{{ win_install_args }}"
win_install_args: "{{ win_install_args }}"

# Add the installation arguments to install Windows NPM.
- name: Set Windows NPM flag
set_fact:
win_install_args: "{{ win_install_args }} ADDLOCAL=MainApplication,NPM"
when: datadog_sysprobe_enabled
8 changes: 8 additions & 0 deletions tasks/pkg-windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@
var: dd_download_url
when: not datadog_skip_windows_install

## must be prior to `pkg-windows-opts.yml`, because the variable is used inside
- name: Set windows NPM installed
set_fact:
datadog_sysprobe_enabled: "{{ network_config is defined and 'enabled' in (network_config | default({}, true)) and network_config['enabled'] }}"
- include_tasks: pkg-windows-opts.yml

- name: pre-Delete temporary msi
Expand Down Expand Up @@ -87,6 +91,10 @@
propagation: None
when: datadog_windows_program_files_dir | length > 0

- name: Show installation flags
debug:
var: win_install_args

- name: Install downloaded agent
win_package:
path: "{{ download_msi_result.dest }}"
Expand Down
14 changes: 14 additions & 0 deletions templates/system-probe.yaml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,17 @@ system_probe_config:
{{ system_probe_config | to_nice_yaml }}
{% endfilter %}
{% endif %}

{% if network_config is defined and network_config | default({}, true) | length > 0 -%}
network_config:
{# The "first" option is only supported by jinja 2.10+
which is not present on older systems (CentOS 7, Debian 8, etc.)
Using the equivalent option "indentfirst" is supported for
all jinja 2 versions up to v2.10.
TODO: when future versions of Jinja are released, check that
indentfirst is still supported.
#}
{% filter indent(width=2, indentfirst=True) %}
{{ network_config | to_nice_yaml }}
{% endfilter %}
{% endif %}

0 comments on commit 111b192

Please sign in to comment.