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

Install apm/php recipe should allow running as root #1076

Open
tcarreira opened this issue May 21, 2024 · 0 comments
Open

Install apm/php recipe should allow running as root #1076

tcarreira opened this issue May 21, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@tcarreira
Copy link

Description

When installing apm/php with root, the logs show something like

This installation recipe for the New Relic PHP agent must be run under sudo.

Steps to Reproduce

Run ansible-playbook as root, with the playbook documented here:
https://github.com/newrelic/ansible-install?tab=readme-ov-file#getting-started

sudo su -
# ansible-playbook playbook.yaml
- name: Install New Relic
  hosts: localhost
  roles:
    - role: newrelic.newrelic_install
      vars:
        targets:
          - apm-php
        tags:
          foo: bar
  environment:
    NEW_RELIC_API_KEY: <API key>
    NEW_RELIC_ACCOUNT_ID: <Account ID>
    NEW_RELIC_REGION: <Region>

Expected Behavior

TASK [newrelic.newrelic_install : Report complete installs] ********************
ok: [localhost] => {
    "msg": {
        "node": "nodename",
        "status": "COMPLETE",
        "summary": [
            "  Installation Summary",
            "",
            "  ✔  PHP Agent  (installed)  ",
            "",
            "  View your data at the link below:",
            "  ⮕  https://onenr.io/xxxxxxxxxxx",
            "",
            "  --------------------"
        ]
    }
}

Relevant Logs / Console output

TASK [newrelic.newrelic_install : Report incomplete installs] ****************************
ok: [localhost] => {
    "msg": {
        "node": "nodename",
        "status": "INCOMPLETE",
        "summary": [
            "  Installation Summary",
            "",
            "  ⊘  PHP Agent  (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/xxxxxxxx",
            "",
            "  --------------------",
            "",
            "",
            "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/"
        ]
    }
}

also, from .newrelic/newrelic-cli.log:

...
Finished matching recipe php-agent-installer to running processes, found 8 matches.
This installation recipe for the New Relic PHP agent must be run under sudo.
recipe php-agent-installer failed script evaluation exit status 3: This installation recipe for the New Relic PHP agent must be run under sudo.
ScriptEvaluation for recipe:php-agent-installer completed in 7ms with status:
...

Your Environment

  • Operating System and version: ubuntu 22.04
  • user: root
  • cloud-init on aws (user: root)

Additional context

This is caused by a specific test for SUDO_USER env variable instead of checking for root permissions:

if [ -z "$SUDO_USER" ]; then

Possible solution for this bug:

if running with root, inject SUDO_USER=root

Workaround for this on ansible is documented here: newrelic/ansible-install#82 (comment)

Other reports for this bug:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant