DataDog / ansible-datadog

Ansible role for Datadog Agent
Apache License 2.0
297 stars 222 forks source link

Lookup File Failed - tasks/_agent-linux-macos-shared.yml - Parse install.json file if it exists #574

Closed DePinto closed 1 month ago

DePinto commented 2 months ago

Summary

The file exists, and the previous step confirms it exists. Then the task attempts to read the file and fails to find the file.

I believe this is because the lookup command occurs on the local computer, not on the remote computer.

This step is also a new addition from three days ago: https://github.com/DataDog/ansible-datadog/pull/572/files

edit 1: I forgot to mention this doesn't seem to happen on the initial run. But subsequent runs with pending changes will hit this.

edit 2: Pinning to v4.23.0 instead of main is a workaround.

Error

Message

{
  "msg": "The 'file' lookup had an issue accessing the file '/etc/datadog-agent/install.json'. file not found, use -vvvvv to see paths searched",
  "_ansible_no_log": false
}

Task

Parse install.json file if it exists https://github.com/DataDog/ansible-datadog/blob/main/tasks/_agent-linux-macos-shared.yml#L106-L109

Previous step of checking if file exists

{
  "changed": false,
  "stat": {
    "exists": true,
    "path": "/etc/datadog-agent/install.json",
    "mode": "0644",
    "isdir": false,
    "ischr": false,
    "isblk": false,
    "isreg": true,
    "isfifo": false,
    "islnk": false,
    "issock": false,
    "uid": 117,
    "gid": 122,
    "size": 117,
    "inode": 436318870,
    "dev": 64768,
    "nlink": 1,
    "atime": 1718991971.2185278,
    "mtime": 1718991280.467356,
    "ctime": 1718991280.7633574,
    "wusr": true,
    "rusr": true,
    "xusr": false,
    "wgrp": false,
    "rgrp": true,
    "xgrp": false,
    "woth": false,
    "roth": true,
    "xoth": false,
    "isuid": false,
    "isgid": false,
    "blocks": 8,
    "block_size": 4096,
    "device_type": 0,
    "readable": true,
    "writeable": true,
    "executable": false,
    "pw_name": "dd-agent",
    "gr_name": "dd-agent",
    "checksum": "5f079e7ddc794ac0b82928b2053c631932fc6a2e",
    "mimetype": "application/json",
    "charset": "us-ascii",
    "version": "2357828033",
    "attributes": [],
    "attr_flags": ""
  },
  "invocation": {
    "module_args": {
      "path": "/etc/datadog-agent/install.json",
      "follow": false,
      "get_md5": false,
      "get_checksum": true,
      "get_mime": true,
      "get_attributes": true,
      "checksum_algorithm": "sha1"
    }
  },
  "_ansible_no_log": false
}

Facts

    "ansible_distribution": "Ubuntu",
    "ansible_distribution_version": "22.04",
    "ansible_os_family": "Debian",