Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for 3rd party integrations #291

Merged
merged 5 commits into from
Aug 14, 2020

Conversation

albertvaka
Copy link
Contributor

Adds support to install 3rd party integrations using the datadog-agent integration command.

I also tested that regular (1st party) integrations can still be installed by adding the following to a manual test:

    datadog_integration:
      datadog-snmp:
        action: 'install'
        version: '3.7.1'

Unfortunately I can't commit the above, since the version used might become superseded by the one shipped in the Agent, making the install fail. That shouldn't be the case for the 3rd party integration, because we won't bundle them, so I left the test there.

@albertvaka albertvaka requested review from a team as code owners August 13, 2020 16:11
Copy link

@kayayarai kayayarai left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 from docs

- integration
- install
- "{{ item.key }}=={{ item.value.version }}"
command: "{{ datadog_agent_binary_path }} integration install {% if 'third_party' in item.value and item.value.third_party %}--third-party{% endif %} {{ item.key }}=={{ item.value.version }}"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In Saltstack, I'm doing a strict comparison for item.value.third_party: https://github.com/DataDog/datadog-formula/blob/4a82ce48cc95b7acada75633e7227811798e2a53/datadog/config.sls#L64

because otherwise any truthy value works (eg. any non-empty string). Is that also the case here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's also the case here, I can make it explicit.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

By the way, I didn't find a way to define intermediate variables, so the condition is in the middle of the string. If there's a better way to write this in Ansible let me know :)

Copy link
Contributor

@KSerrania KSerrania Aug 13, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could maybe do something like:

- name: Install pinned version of integrations (Unix)
  command: "{{ datadog_agent_binary_path }} integration install (( third_party }}{{ item.key }}=={{ item.value.version }}"
  become: yes
  become_user: "{{ integration_command_user }}"
  vars:
    third_party: "{% if 'third_party' in item.value and item.value.third_party == true %}--third-party {% endif %}"
  loop: "{{ datadog_integration|dict2items }}"
  when: item.value.action == "install" and ansible_os_family != "Windows"

We're already using this syntax here:

- name: Parse Agent version
set_fact:
agent_version: "{{ datadog_agent_version | regex_search(regexp, '\\g<epoch>', '\\g<major>', '\\g<minor>', '\\g<bugfix>', '\\g<suffix>', '\\g<release>') }}"
vars:
regexp: '(?:(?P<epoch>[0-9]+):)?(?P<major>[0-9]+)\.(?P<minor>[0-9]+)\.(?P<bugfix>[0-9]+)(?P<suffix>(?:~|-)[^0-9\s-]+[^-\s]*)?(?:-(?P<release>[0-9]+))?'

However, that assumes that vars works correctly with loop (ie. that item is correctly defined in vars), which I haven't tested.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It works and I find it slightly more readable, so I've changed it 👍

@albertvaka albertvaka merged commit f5d55cc into master Aug 14, 2020
@albertvaka albertvaka deleted the albertvaka/third-party-integrations branch August 14, 2020 14:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants