Adding NewRelic apm agent (php) with packer

I’m trying to set up NeRelic APM agent on an instance with packer. I’ve based what I’m doing off the installation and pre-seed instructions found here: https://docs.newrelic.com/docs/agents/php-agent/installation/php-agent-installation-ubuntu-debian

First of all I pre-seed the licence key and application name

- name: Configure new relic application name.
  debconf:
    name: newrelic-php5
    question: newrelic-php5/application-name
    value: "{{ new_relic_apm_app_name }}"
    vtype: string

- name: Configure new relic license key
  debconf:
    name: newrelic-php5
    question: newrelic-php5/license-key
    value: "{{ new_relic_apm_license_key }}"
    vtype: string

Then I install newrelic-php5:

    - name: Trust the New Relic GPG key
      apt_key:
        url: https://download.newrelic.com/548C16BF.gpg
        state: present

    - name: Configure the New Relic apt repository.
      apt_repository:
        repo: deb http://apt.newrelic.com/debian/ newrelic non-free
        state: present
        update_cache: yes

    - name: Update the local package list & Install the PHP agent.
      apt:
        name: newrelic-php5
        update_cache: yes

If I start an instance from the generated AMI the NewRelic agent is installed but doesn’t generated the newrelic.ini containing the licence key and application name. If I then manually remove the agent, re-install it with apt install, and restart php-fpm, the newrelic.ini is generated and the agent starts working.

Has anyone successfully installed the agent with packer or experienced anything similar?

I was being stupid, need to install PHP first! Surprised the New Relic package doesn’t have PHP as a dependency.