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

Don't install the agent when it is installed through the installer #589

Merged
merged 20 commits into from
Aug 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,12 @@ jobs:
- image: datadog/docker-library:ansible_<<parameters.os>>_<<parameters.ansible_version>>
steps:
- checkout
# datadog-installer will bailout if there's no systemctl binary, and won't attempt to
# create the systemd folder to store its units
# Since we're running the tests in a docker container without systemd, we can "help" it
# proceed by pretending systemd is there
- run: printf "#!/bin/bash\n\nexit 0" > /usr/bin/systemctl && chmod +x /usr/bin/systemctl
- run: mkdir -p /etc/systemd/system/
- run: >
ANSIBLE_JINJA2_NATIVE="<<parameters.jinja2_native>>" ansible-playbook
-i ./ci_test/inventory/<<parameters.inventory>> "./ci_test/install_installer.yaml"
Expand All @@ -265,6 +271,17 @@ jobs:
exit 2;
else
echo datadog-installer is not installed as expected;
fi
if [ "<<parameters.remote_updates>>" = "true" ]; then
if [ -d /opt/datadog-agent ]; then
echo "The agent should NOT have been installed by the distribution";
exit 1;
fi
else
if [ ! -d /opt/datadog-agent ]; then
echo "The agent should have been installed by the distribution";
exit 1;
fi
fi'

workflows:
Expand Down
8 changes: 8 additions & 0 deletions handlers/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,14 @@
state: restarted
when: datadog_enabled and not ansible_check_mode and not ansible_facts.os_family == "Windows" and not ansible_facts.os_family == "Darwin"

- name: restart datadog-installer # noqa name[casing]
service:
name: datadog-installer
state: restarted
# The installer currently only setup its systemd unit when remote updates are enabled
when: datadog_enabled and datadog_installer_enabled and datadog_remote_updates and
not ansible_check_mode and not ansible_facts.os_family == "Windows" and not ansible_facts.os_family == "Darwin"

# We can't add the Windows Agent service restart handler directly here because that makes the role require
# the ansible.windows collection on all platforms. We only want it to be needed on Windows.
# Therefore, what we do is the following: when needed, our Windows tasks call this handler to require a
Expand Down
2 changes: 1 addition & 1 deletion tasks/agent-linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
agent_dd_config_dir: /etc/datadog-agent
agent_dd_user: "{{ datadog_user }}"
agent_dd_group: "{{ datadog_group }}"
agent_dd_notify_agent: restart datadog-agent
agent_dd_notify_agent: [restart datadog-agent, restart datadog-installer]

- name: Create system-probe configuration file
template:
Expand Down
2 changes: 1 addition & 1 deletion tasks/installer-setup.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
DATADOG_PARENT_ID: "{{ datadog_installer_trace_id }}"
DD_SITE: "{{ datadog_site | default('datadoghq.com') }}"
DD_API_KEY: "{{ datadog_api_key }}"
DD_REMOTE_UPDATES: "{{ 'true' if datadog_remote_updates is defined and datadog_remote_updates else '' }}"
DD_REMOTE_UPDATES: "{{ 'true' if datadog_remote_updates is defined and datadog_remote_updates | bool else '' }}"
DD_APM_INSTRUMENTATION_ENABLED: "{{ datadog_apm_instrumentation_enabled }}"
DD_APM_INSTRUMENTATION_LIBRARIES: "{{ datadog_apm_instrumentation_libraries | join(',') }}"
ignore_errors: true
Expand Down
4 changes: 2 additions & 2 deletions tasks/pkg-debian.yml
Original file line number Diff line number Diff line change
Expand Up @@ -123,11 +123,11 @@

- name: Include debian pinned version install task
include_tasks: pkg-debian/install-pinned.yml
when: agent_datadog_agent_debian_version is defined
when: not agent_datadog_skip_install and agent_datadog_agent_debian_version is defined

- name: Include debian latest version install task
include_tasks: pkg-debian/install-latest.yml
when: agent_datadog_agent_debian_version is not defined
when: not agent_datadog_skip_install and agent_datadog_agent_debian_version is not defined

- name: Install latest datadog-signing-keys package
apt:
Expand Down
4 changes: 2 additions & 2 deletions tasks/pkg-redhat.yml
Original file line number Diff line number Diff line change
Expand Up @@ -254,8 +254,8 @@

- name: Include redhat agent pinned version install task
include_tasks: pkg-redhat/install-pinned.yml
when: agent_datadog_agent_redhat_version is defined
when: not agent_datadog_skip_install and agent_datadog_agent_redhat_version is defined

- name: Include redhat agent latest version install task
include_tasks: pkg-redhat/install-latest.yml
when: agent_datadog_agent_redhat_version is not defined
when: not agent_datadog_skip_install and agent_datadog_agent_redhat_version is not defined
2 changes: 1 addition & 1 deletion tasks/pkg-redhat/install-installer-yum.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
- name: Install latest datadog-agent package (yum)
- name: Install latest datadog-installer package (yum)
yum:
name: "{{ datadog_installer_flavor }}"
update_cache: true
Expand Down
6 changes: 3 additions & 3 deletions tasks/pkg-suse.yml
Original file line number Diff line number Diff line change
Expand Up @@ -133,13 +133,13 @@
# refresh zypper repos only if the template changed
- name: Refresh Datadog zypper_repos # noqa: command-instead-of-module
command: zypper refresh datadog
when: agent_datadog_zypper_repo_template.changed and not ansible_check_mode
when: not agent_datadog_skip_install and agent_datadog_zypper_repo_template.changed and not ansible_check_mode
changed_when: true

- name: Include Suse agent pinned version install task
include_tasks: pkg-suse/install-pinned.yml
when: agent_datadog_agent_suse_version is defined
when: not agent_datadog_skip_install and agent_datadog_agent_suse_version is defined

- name: Include Suse agent latest version install task
include_tasks: pkg-suse/install-latest.yml
when: agent_datadog_agent_suse_version is not defined
when: not agent_datadog_skip_install and agent_datadog_agent_suse_version is not defined