diff --git a/.circleci/config.yml b/.circleci/config.yml index cb0ab3ed..9398ba63 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -252,6 +252,12 @@ jobs: - image: datadog/docker-library:ansible_<>_<> 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="<>" ansible-playbook -i ./ci_test/inventory/<> "./ci_test/install_installer.yaml" @@ -265,6 +271,17 @@ jobs: exit 2; else echo datadog-installer is not installed as expected; + fi + if [ "<>" = "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: diff --git a/handlers/main.yml b/handlers/main.yml index 60bc9c67..c88aa12c 100644 --- a/handlers/main.yml +++ b/handlers/main.yml @@ -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 diff --git a/tasks/agent-linux.yml b/tasks/agent-linux.yml index f881679c..870367ec 100644 --- a/tasks/agent-linux.yml +++ b/tasks/agent-linux.yml @@ -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: diff --git a/tasks/installer-setup.yml b/tasks/installer-setup.yml index 49b6f4d4..0ebcfdbe 100644 --- a/tasks/installer-setup.yml +++ b/tasks/installer-setup.yml @@ -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 diff --git a/tasks/pkg-debian.yml b/tasks/pkg-debian.yml index fd9dc8fd..79b7456d 100644 --- a/tasks/pkg-debian.yml +++ b/tasks/pkg-debian.yml @@ -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: diff --git a/tasks/pkg-redhat.yml b/tasks/pkg-redhat.yml index 31dc7b3b..b80b4b04 100644 --- a/tasks/pkg-redhat.yml +++ b/tasks/pkg-redhat.yml @@ -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 diff --git a/tasks/pkg-redhat/install-installer-yum.yml b/tasks/pkg-redhat/install-installer-yum.yml index b84134ee..1c162eef 100644 --- a/tasks/pkg-redhat/install-installer-yum.yml +++ b/tasks/pkg-redhat/install-installer-yum.yml @@ -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 diff --git a/tasks/pkg-suse.yml b/tasks/pkg-suse.yml index fb1992af..124596db 100644 --- a/tasks/pkg-suse.yml +++ b/tasks/pkg-suse.yml @@ -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