Error trying to install Ansible in Jenkins image

I’m trying to install Ansible in my Jenkins image (this way). This is my Dockerfile:

FROM jenkins

USER root

RUN apt-get install -y software-properties-common
RUN apt-add-repository ppa:ansible/ansible
RUN apt-get update
RUN apt-get install -y ansible

USER jenkins

But when I build the image, I get this error:

  • Detect AWS host environment from within a Docker Container
  • mysql docker container crashes often
  • Docker Entrypoint for Postgres 9.3
  • How to connect MySQL client with server running in Docker
  • docker-compose service and the network
  • Running tests with Docker and Jenkins - Test Result
  • W: Failed to fetch http://ppa.launchpad.net/ansible/ansible/ubuntu/dists/jessie/main/binary-amd64/Packages 404 Not Found

    E: Some index files failed to download. Thet have been ignored, or old ones used instead.

    I have realized that
    http://ppa.launchpad.net/ansible/ansible/ubuntu/dists/jessie doesn’t exist.

    Thanks

  • Docker save not working on Ubuntu 16.04
  • Docker Compose: Avoid recreation of data container
  • Getting error when running mocha test with Xvfb and firefox headlessly in a docker container
  • Trying to send messages between Docker containers using rabbitmq
  • How can I set parameters from docker command line to configure spring boot application?
  • Deploying .NET Core 1.1 App to Docker - Could not resolve CoreCLR path
  • One Solution collect form web for “Error trying to install Ansible in Jenkins image”

    From your above link, ansible ppa seems to have support only for ubuntu, so you end up adding a broken ppa. Your docker image jenkins inherits from java:8-jdk which further inherits from buildpack-deps:jessie-scm which inherits buildpack-deps:jessie-curl and that one from debian:jessie

    From here

    If you are wishing to run the latest released version of Ansible and
    you are running Red Hat Enterprise Linux (TM), CentOS, Fedora, Debian,
    or Ubuntu, we recommend using the OS package manager.

    This means, if you have your Dockerfile like this

    [anovil@ubuntu-anovil docker-ansible-jenkins]$ cat Dockerfile 
    FROM jenkins
    USER root
    RUN apt-get update
    RUN apt-get install -y ansible
    USER jenkins
    [anovil@ubuntu-anovil docker-ansible-jenkins]$
    

    Thats enough and I managed to test this and this works !

    [anovil@ubuntu-anovil docker-ansible-jenkins]$ docker build -t jenkins --rm .
    Sending build context to Docker daemon 2.048 kB
    ...
    [anovil@ubuntu-anovil docker-ansible-jenkins]$ docker run -d -p 8080:8080 jenkins
    e722efecdf7beb462bafaff653b19261268abbd2d56f88334ba6c42d068b2877
    [anovil@ubuntu-anovil docker-ansible-jenkins]$ docker ps
    CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS                               NAMES
    e722efecdf7b        jenkins             "/bin/tini -- /usr/lo"   4 minutes ago       Up 4 minutes        0.0.0.0:8080->8080/tcp, 50000/tcp   focused_cray
    [anovil@ubuntu-anovil docker-ansible-jenkins]$ 
    

    Let us hear about how this went for you.

    Thanks,

    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.