Error while installing the New Relic agent into an Ubuntu 14.04 AMI using Packer

I am building a custom AMI’s for Ubuntu 14.04 and it keeps crashing at the end of the installation with the message “/home/ubuntu: Is a directory”. I got the exact same error when installing using the downloaded binary (dpkg -i ./newrelic-infra_upstart_1.0.673_amd64.deb) or using the New-Relic repository (apt-get install newrelic-infra -y). The packer installs as the Sudo user ubuntu

==> amazon-ebs: Provisioning with shell script: os-templates/ubuntu14-linux/scripts/download_install_ubuntu14_newrelic.sh
amazon-ebs: [Sun Mar 26 09:36:47 UTC 2017] - - Copy the newrelic software from /var/packer_build/files/newrelic to /var/trp_setup/newrelic
amazon-ebs: [Sun Mar 26 09:36:47 UTC 2017] - - Installing the New Relic Software
amazon-ebs: [Sun Mar 26 09:36:47 UTC 2017] - - Install New Relic - Started
amazon-ebs: % Total % Received % Xferd Average Speed Time Time Time Current
amazon-ebs: Dload Upload Total Spent Left Speed
amazon-ebs: 100 1662 100 1662 0 0 29647 0 --:–:-- --:–:-- --:–:-- 30218
amazon-ebs: OK

amazon-ebs: Reading package lists...
amazon-ebs: [Sun Mar 26 09:36:58 UTC 2017] -  - Install New Relic - Completed
amazon-ebs: /tmp/script_7352.sh: line 56: /home/ubuntu: Is a directory

==> amazon-ebs: Terminating the source AWS instance…
==> amazon-ebs: Cleaning up any extra volumes…
==> amazon-ebs: No volumes to clean up, skipping
==> amazon-ebs: Deleting temporary security group…
==> amazon-ebs: Deleting temporary keypair…
Build ‘amazon-ebs’ errored: Script exited with non-zero exit status: 126

Hi @ade_faleti,

Infrastructure must be installed and run as root:

https://docs.newrelic.com/docs/infrastructure/new-relic-infrastructure/getting-started/compatibility-requirements-new-relic-infrastructure#permissions

You will need to update your AMI to install using root in order to get this to work properly.

I curious as to why I was able to install on Amazon Linux and RHEL 7.3 using the username ec2-user and sudo.

@ade_faleti,

The reason root is required is there are certain permissions needed to both install the files and run the daemon. If the user you install as has the required permissions, it will work. But there’s no guarantee it will, or that all of the metrics will be collected. The only way to ensure everything is installed and works as expected is to use root.