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

[AGENT-12513] Fix Ansible check mode when installer/apm injection is enabled #619

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

tbavelier
Copy link
Member

@tbavelier tbavelier commented Oct 14, 2024

What does this PR do ?

  • For the APM inject task, move the not ansible_check_mode condition to the parent when. We should not run any of the commands/file from dd-host-install in check mode which we were doing individually (except injecting the Docker config which we should not have done in check mode, so this "fixes" it incidentally)
  • For the installer task, the playbook "depends" on datadog_installer_install_result which itself is only registered when not running in check mode, as coded in each tasks/pkg-, e.g.:
    register: datadog_installer_install_result
    . Thus, we add not ansible_check_mode on all the subsequent steps that depend on this registry, as we should not run any bootstrap/installer command, nor attempt to send any telemetry in check mode
  • In the main Agent linux task, do not try to check for services that might not exist (e.g. user never ran without --check yet)

Motivation

Closes #610

QA instructions

Use a playbook with the installer:

Role

- hosts: myhosts
  roles:
    - { role: ansible-datadog, become: yes }
  vars:
    datadog_api_key: baguette
    datadog_enabled: false
    datadog_apm_instrumentation_enabled: "host"
    datadog_apm_instrumentation_libraries: ["java:1", "python:2", "js:5", "dotnet:3", "ruby:2"]

Collection

- hosts: myhosts
  tasks:
  - name: Import the Datadog Agent role from the DD collection
    import_role:
      name: datadog.dd.agent
  vars:
    datadog_api_key: baguette
    datadog_enabled: false
    datadog_apm_instrumentation_enabled: "host"
    datadog_apm_instrumentation_libraries: ["java:1", "python:2", "js:5", "dotnet:3", "ruby:2"]

Run it in check mode and ensure it does not error out: ansible-playbook -i inventory.ini playbook.yml --check

@tbavelier tbavelier changed the title Fix Ansible check mode when installer/apm injection is enabled [AGENT-12513] Fix Ansible check mode when installer/apm injection is enabled Oct 14, 2024
@tbavelier tbavelier marked this pull request as ready for review October 14, 2024 14:20
@tbavelier tbavelier requested review from a team as code owners October 14, 2024 14:20
Copy link
Contributor

@chouquette chouquette left a comment

Choose a reason for hiding this comment

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

One nit/remark. LGTM otherwise

Copy link
Contributor

Choose a reason for hiding this comment

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

Wouldn't it be easier not to include the file when running in check mode? Almost every tasks are disabled and the remaining ones don't seem very valuable to check

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.

Breaks when in check mode
2 participants