Ansible from ppa won't install python-related packages

6,962

Solution 1

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

Solution 2

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?"

Share:
6,962

Related videos on Youtube

Guerlando OCs
Author by

Guerlando OCs

Updated on September 18, 2022

Comments

  • Guerlando OCs
    Guerlando OCs over 1 year

    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