-
Notifications
You must be signed in to change notification settings - Fork 225
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 from docs
tasks/integration.yml
Outdated
- 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 }}" |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 :)
There was a problem hiding this comment.
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:
ansible-datadog/tasks/parse-version.yml
Lines 2 to 6 in e08729a
- 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.
There was a problem hiding this comment.
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 👍
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:
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.