ansible / ansible-container

DEPRECATED -- Ansible Container was a tool to build Docker images and orchestrate containers using only Ansible playbooks.
GNU Lesser General Public License v3.0
2.19k stars 392 forks source link

need detailed instructions on how to create a conductor base image #849

Open dchsueh opened 6 years ago

dchsueh commented 6 years ago
ISSUE TYPE
container.yml

not applicable

OS / ENVIRONMENT
# ansible-container --debug version
Ansible Container, version 0.9.2
Linux, ubuntu, 4.4.0-104-generic, #127-Ubuntu SMP Mon Dec 11 12:16:42 UTC 2017, x86_64
2.7.12 (default, Nov 20 2017, 18:23:56) 
SUMMARY

Documentation on making conductor base images is very brief and lacks detail. Existing conductor base images have filesystem items (e.g. /_ansible, /usr/bin/conductor or /usr/local/bin/conductor) that aren't mentioned in the writeup at https://docs.ansible.com/ansible-container/conductor.html#baking-your-own-conductor-base .

(I also tried to make my own Dockerfile patterned after conductor-src-dockerfile.j2 but am unable to determine where many files are supposed to come from.)

(For the record, I'm trying to make a centos:6 conductor base; I'm well aware of the python 2.6 / 2.7 situation but that is the least of the problems I'm experiencing.)

j00bar commented 6 years ago

Completely valid. This will be ameliorated. Thanks!

zentavr commented 6 years ago

For building the conductor image I used this Dockerfile:

FROM alpine:3.7
MAINTAINER zentavr <zentavr@hello.world>

ENV ANSIBLE_CONTAINER=1
ENV ANSIBLE_CONTAINER_VERSION=0.9.2

# How to build the conductor-image: http://docs.ansible.com/ansible-container/conductor.html#baking-your-own-conductor-base

# openssh is necessary until this is fixed: https://github.com/ansible/ansible/issues/24705
RUN apk add --no-cache -U \
    python-dev \
    py2-pip \
    make \
    git \
    curl \
    rsync \
    libffi \
    libffi-dev \
    openssl \
    openssl-dev \
    gcc \
    musl-dev \
    tar \
    openssh \
    docker \
    docker-py && rm -f /var/cache/apk/*

RUN mkdir -p /etc/ansible/roles /_ansible/src

# The COPY here will break cache if the version of Ansible Container changed
COPY / /_ansible/container

RUN cd /_ansible && \
    pip install --no-cache-dir -r container/conductor-build/conductor-requirements.txt && \
    pip install --no-cache-dir ansible-container[docker,k8s]==${ANSIBLE_CONTAINER_VERSION}  && \
    ansible-galaxy install -p /etc/ansible/roles -r container/conductor-build/conductor-requirements.yml

conductor-requirements.yml:

- src: ansible.kubernetes-modules
  name: kubernetes-modules

conductor-requirements.txt:

https://github.com/ansible/ansible/archive/devel.tar.gz
https://github.com/openshift/openshift-restclient-python/archive/master.tar.gz#egg=openshift
PyYAML>=3.12
docker-compose>=1.14
requests>=2
ruamel.yaml>=0.14.2
six>=1.10
structlog[dev]>=16.1
python-string-utils>=0.6.0

Build

docker build .
  ...
  ...
 ---> 1f8513cdf7a6
Successfully built 1f8513cdf7a6

Tag

docker tag 1f8513cdf7a6 container-conductor-alpine-3.7:0.9.2

You can find something interesting in container/docker/templates/conductor-src-dockerfile.j2 of the project.