Issue

The following SSH command responded with a non-zero exit status.
Vagrant assumes that this means the command failed!


                add-apt-repository ppa:ansible/ansible -y &&                 apt-get update -y -qq &&                 apt-get install -y -qq ansible


Stdout from the command:

Hit:1 http://archive.ubuntu.com/ubuntu bionic InRelease

---

Setting up libssl1.1:amd64 (1.1.1-1ubuntu2.1~18.04.2) ...
Checking for services that may need to be restarted...done.
Checking for services that may need to be restarted...done.
Checking init scripts...
dpkg: error processing package libssl1.1:amd64 (--configure):
 installed libssl1.1:amd64 package post-installation script subprocess returned error exit status 10
Setting up python-enum34 (1.1.6-2) ...
dpkg: dependency problems prevent configuration of python-cryptography:
 python-cryptography depends on libssl1.1 (>= 1.1.1); however:
  Package libssl1.1:amd64 is not configured yet.

dpkg: error processing package python-cryptography (--configure):
 dependency problems - leaving unconfigured
Processing triggers for man-db (2.8.3-2ubuntu0.1) ...
Setting up python-ipaddress (1.0.17-1) ...
Setting up python-setuptools (39.0.1-2) ...
Setting up python-jinja2 (2.10-1ubuntu0.18.04.1) ...
dpkg: dependency problems prevent configuration of libssl-dev:amd64:
 libssl-dev:amd64 depends on libssl1.1 (= 1.1.1-1ubuntu2.1~18.04.2); however:
  Package libssl1.1:amd64 is not configured yet.

dpkg: error processing package libssl-dev:amd64 (--configure):
 dependency problems - leaving unconfigured
dpkg: dependency problems prevent configuration of python-paramiko:
 python-paramiko depends on python-cryptography (>= 1.1); however:
  Package python-cryptography is not configured yet.

dpkg: error processing package python-paramiko (--configure):
 dependency problems - leaving unconfigured
dpkg: dependency problems prevent configuration of ansible:
 ansible depends on python-paramiko; however:
  Package python-paramiko is not configured yet.
 ansible depends on python-cryptography; however:
  Package python-cryptography is not configured yet.

dpkg: error processing package ansible (--configure):
 dependency problems - leaving unconfigured
Processing triggers for libc-bin (2.27-3ubuntu1) ...
Errors were encountered while processing:
 libssl1.1:amd64
 python-cryptography
 libssl-dev:amd64
 python-paramiko
 ansible


Stderr from the command:

dpkg-preconfigure: unable to re-open stdin: No such file or directory
No apport report written because the error message indicates its a followup error from a previous failure.
No apport report written because the error message indicates its a followup error from a previous failure.
No apport report written because MaxReports is reached already
No apport report written because MaxReports is reached already
E: Sub-process /usr/bin/dpkg returned an error code (1)

Solution

Add this* before you provision with ansible:

webserver.vm.provision :shell, inline: "apt install -y python-cryptography python-paramiko libssl-dev"