1

When I build my dockerfile, which does the following:

FROM debian:jessie
...
RUN echo "deb http://ppa.launchpad.net/ansible/ansible/ubuntu trusty main" > /etc/apt/sources.list \
    && apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 93C4A3FD7BB9C367 \
    && apt-get update \
    && apt-get install ansible

I get:

The following packages have unmet dependencies:
 ansible : Depends: python-jinja2 but it is not installable
           Depends: python but it is not installable
           Depends: python-yaml but it is not installable
           Depends: python-paramiko but it is not installable
           Depends: python-httplib2 but it is not installable
           Depends: python-six but it is not installable
           Depends: python-crypto (>= 2.6) but it is not installable
           Depends: python-setuptools but it is not installable
           Depends: sshpass but it is not installable
           Depends: python-pkg-resources but it is not installable

Shouldn't the process of installing ansible already install these packages? I'm kinda noob into this, but as I know, one package can list dependencies for other packages, so why these aren't installing automatically? Shouldn't debian also come with python at least?

I've put them into the apt-get script and it worket, but shouldn't it be automatic? What if a new ansible package in the ppa requires more packages? It'd break my dockerfile

Guerlando OCs
  • 863
  • 10
  • 51
  • 88

3 Answers3

2

Instead of overriding the /etc/apt/sources.list file using > you can append the text using >>.

So it will be something similar to the following.

RUN echo "deb http://ppa.launchpad.net/ansible/ansible/ubuntu trusty main" >> /etc/apt/sources.list \
&& apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 93C4A3FD7BB9C367 \
&& apt-get update \
&& apt-get install -y ansible
1

Try adding the -f option to apt-get install, which attempts to fix broken dependencies. Prior to running apt-get update you may also want to run apt-get clean to clear the local apt repo. These worked for my Packer build that uses the Ansible provisioner.

Your code would become:

RUN echo "deb http://ppa.launchpad.net/ansible/ansible/ubuntu trusty main" > /etc/apt/sources.list \
&& apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 93C4A3FD7BB9C367 \
&& apt-get autoclean \
&& apt-get update \
&& apt-get install -f ansible

For additional details I recommend this excellent answer to the broader question, "How do I resolve unmet dependencies after adding a PPA?"

thinkmassive
  • 783
  • 5
  • 9
0

For currently supported versions of Ubuntu You can update your system with unsupported packages from this untrusted PPA by adding ppa:ansible/ansible to your system's Software Sources.

deb http://ppa.launchpad.net/ansible/ansible/ubuntu YOUR_UBUNTU_VERSION_HERE main 
deb-src http://ppa.launchpad.net/ansible/ansible/ubuntu YOUR_UBUNTU_VERSION_HERE main

You can install ansible utilizing the following commands.

$ sudo apt update
$ sudo apt install software-properties-common
$ sudo apt-add-repository --yes --update ppa:ansible/ansible
$ sudo apt install ansible 

Note that if you are using a version of Ubuntu prior to 18.04 there is no -u or --update switch for apt-add-repository so if that's your case leave the --update switch out of the 3rd line of code above.

Sources:

https://docs.ansible.com/ansible/latest/installation_guide/intro_installation.html#installing-ansible-on-ubuntu

man apt-add-repository

Elder Geek
  • 36,023
  • 25
  • 98
  • 183