djoos-cookbooks / newrelic

Development repository for the newrelic cookbook
https://supermarket.chef.io/cookbooks/newrelic
MIT License
143 stars 247 forks source link

Please add Ubuntu 22.04 support, Ubuntu 20.04 fails with malformed repository line #400

Open jjperry opened 10 months ago

jjperry commented 10 months ago

While working to certify Ubuntu 22.04 support in our Chef environment, this cookbook generated errors on Ubuntu.

It said that the deb repository line in the /etc/apt/sources.list.d/newrelic-infra.list was a malformed repository line.

        * file[/etc/apt/sources.list.d/newrelic-infra.list] action create
          - update content in file /etc/apt/sources.list.d/newrelic-infra.list from c81efd to 8c177b
          --- /etc/apt/sources.list.d/newrelic-infra.list       2023-09-13 23:37:08.591295593 +0000
          +++ /etc/apt/sources.list.d/.chef-newrelic-infra20230913-3151-7zpchn.list     2023-09-13 23:37:49.647491073 +0000
          @@ -1 +1 @@
          +deb      [arch=amd64] https://download.newrelic.com/infrastructure_agent/linux/apt main
        * execute[apt-cache gencaches] action run[2023-09-13T23:37:49+00:00] ERROR: execute[apt-cache gencaches] (vmn-newrelic::agent_infra line 415) had an error: Mixlib::ShellOut::ShellCommandFailed: Expected process to exit with [0], but received '100'
       ---- Begin output of ["apt-cache", "gencaches"] ----
       STDOUT:
       STDERR: E: Malformed entry 1 in list file /etc/apt/sources.list.d/newrelic-infra.list (Component)
       E: The list of sources could not be read.
       ---- End output of ["apt-cache", "gencaches"] ----
       Ran ["apt-cache", "gencaches"] returned 100; ignore_failure is set, continuing

From New Relic's install page, https://docs.newrelic.com/docs/infrastructure/install-infrastructure-agent/linux-installation/install-infrastructure-monitoring-agent-linux/#ubuntu-version, the line being generated is incorrect and should be including the distribution name (xenial, bionic, groovy, jammy, etc).

For Ubuntu 22.04 this newrelic cookbook generated

deb      [arch=amd64] https://download.newrelic.com/infrastructure_agent/linux/apt main

where New Relic's install webpage has:

deb https://download.newrelic.com/infrastructure_agent/linux/apt/ jammy main

The commands that were being run by Chef on the Ubuntu 22.04 by this supermarket cookbook are

apt-key add /tmp/kitchen/cache/https___download_newrelic_com_infrastructure_agent_gpg_newrelic-infra_gpg
create file /etc/apt/sources.list.d/newrelic-infra with content: 
   deb      [arch=amd64] https://download.newrelic.com/infrastructure_agent/linux/apt main
apt-cache gencaches 
apt-get -q update
apt-cache policy newrelic-infra

Where those on New Relic's Ubuntu install pages are:

curl -fsSL https://download.newrelic.com/infrastructure_agent/gpg/newrelic-infra.gpg | sudo gpg --dearmor -o /etc/apt/trusted.gpg.d/newrelic-infra.gpg
echo "deb https://download.newrelic.com/infrastructure_agent/linux/apt/ jammy main" | sudo tee -a /etc/apt/sources.list.d/newrelic-infra.list
sudo apt-get install newrelic-infra -y

The latter set of commands installed the New Relic Infra agent on the Ubuntu 22.04 where the cookbook-generated commands had errors.