NEO4J_ACCEPT_LICENSE_AGREEMENT not accepting license prompt - Ubuntu 18.04.2 LTS

When setting the NEO4J_ACCEPT_LICENSE_AGREEMENT environment variable during install, the license is not accepted.

As a part of an ansible script, I'm trying to install and configure Neo4j 3.5 on a server. I can suppress the prompt with DEBIAN_FRONTEND=noninteractive but this still causes a dpkg error, so the package is not installed.

For reference, this is the command that still shows the license prompt:
sudo NEO4J_ACCEPT_LICENSE_AGREEMENT=yes apt -yq install neo4j-enterprise

This is the command that suppresses the license prompt, but still gets an error:
sudo DEBIAN_FRONTEND=noninteractive apt -yq install neo4j-enterprise

Setting both environment variables in one command still produces the same error:
eading package lists... Done
Building dependency tree
Reading state information... Done
The following NEW packages will be installed:
0 upgraded, 1 newly installed, 0 to remove and 214 not upgraded.
2 not fully installed or removed.
Need to get 0 B/143 MB of archives.
After this operation, 164 MB of additional disk space will be used.
Preconfiguring packages ...
(Reading database ... 70971 files and directories currently installed.)
Preparing to unpack .../neo4j-enterprise_1%3a3.5.28_all.deb ...
Neo4j License Rejected.
dpkg: error processing archive /var/cache/apt/archives/neo4j-enterprise_1%3a3.5.28_all.deb (--unpack):
new neo4j-enterprise package pre-installation script subprocess returned error exit status 1
Errors were encountered while processing:
E: Sub-process /usr/bin/dpkg returned an error code (1)

Has anyone encountered this before, and/or have suggestions for a solution?

is there a specific reason to use Neo4j 3.5.x and not a more recent version? For example 4.2.x?

I did some searching and found this ansible instruction:

You seem to be able to add to your ansible playbook something like accept licence is "true" (or answer is "true") to see what the neo4j deb package question is i think you can use this:

Use ‘debconf-show ’ on any Debian or derivative with the package installed to see questions/settings available

Then something in ansible like (replace with Neo4j)

  • name: Accept oracle license
    name: oracle-java7-installer
    question: shared/accepted-oracle-license-v1-1
    value: 'true'
    vtype: select

Yours Kindly

In case anyone comes across this thread one day, I figured I'd write how it was solved. Found a method to figure out to handle it programmatically here: Installing Java Automatically (With Silent Option) - Ask Ubuntu

You need debconf-utils installed, and then you need to run:

echo "neo4j-enterprise neo4j/question select I ACCEPT" | sudo debconf-set-selections

There may be a way to handle it with an Ansible module as suggested above, but I just used raw. May give the module a try at a later time, though.