newrelic / ansible-install

Building installation support for our customers are using ansible to manage their infrastructure and services at scale
Apache License 2.0
8 stars 6 forks source link

PHP Agent fails due to not running as sudo #82

Open nvahalik opened 2 months ago

nvahalik commented 2 months ago

Description

When trying to use the apm-php target, it fails to install.

Steps to Reproduce

I have copied and pasted the sample from the repository, commenting out logs and adding my NRAK-* key and account ID.

Expected Behavior

The PHP Agent should be installed.

Relevant Logs / Console output

TASK [newrelic.newrelic_install : Report incomplete installs] ********************************************************
ok: [demo-server] => {
    "msg": {
        "node": "demo-server",
        "status": "INCOMPLETE",
        "summary": [
            "  Installation Summary",
            "",
            "  ✔  Infrastructure Agent  (installed)  ",
            "  ⊘  PHP Agent  (unsupported)  ",
            "  ⊘  NGINX Integration  (unsupported)  ",
            "",
            "  Installation was successful overall, however, one or more installations could not be completed.",
            "  Follow the instructions at the URL below to complete the installation process. ",
            "",
            "  ⮕  https://onenr.io/0OwvMNxAaQv",
            "",
            "  --------------------",
            "",
            "",
            "We encountered an issue during the installation: one or more selected recipes could not be installed.",
            "If this problem persists, visit the documentation and support page for additional help here at https://docs.newrelic.com/docs/infrastructure/install-infrastructure-agent/get-started/requirements-infrastructure-agent/",
            "",
            ""
        ]
    }
}

Your Environment

Debian 11. Fresh install.

Additional context

This appears to be a known bug: https://forum.newrelic.com/s/hubtopic/aAXPh0000000bcHOAQ/php-agent-installation-via-ansible-is-not-working-unsupported

tcarreira commented 1 month ago

There seems to be an easy fix for that PHP Agent (unsupported): just add a SUDO_USER env

Quickfix:

- name: Install New Relic
  hosts: all
  roles:
    - role: newrelic.newrelic_install
      vars:
        targets:
          - infrastructure
          - logs
          - apm-php
        tags:
          foo: bar
  environment:
    SUDO_USER: root
    NEW_RELIC_API_KEY: <API key>
    NEW_RELIC_ACCOUNT_ID: <Account ID>
    NEW_RELIC_REGION: <Region>

This is caused by a poor check for admin under open-install-library

reported here: https://github.com/newrelic/open-install-library/issues/1076