From dada2d4556452fb4d026a595809edc3ea10f8c10 Mon Sep 17 00:00:00 2001 From: Dieter Verhelst Date: Tue, 12 Mar 2019 12:14:10 +0100 Subject: [PATCH] slim down docker container, doing everything in prepare.yml --- molecule/generic_files/Dockerfile.j2 | 8 ++---- molecule/generic_files/prepare.yml | 42 ++++++++++++++++++++++------ 2 files changed, 35 insertions(+), 15 deletions(-) diff --git a/molecule/generic_files/Dockerfile.j2 b/molecule/generic_files/Dockerfile.j2 index 2a39d9e..c2bd953 100644 --- a/molecule/generic_files/Dockerfile.j2 +++ b/molecule/generic_files/Dockerfile.j2 @@ -1,14 +1,10 @@ # Molecule managed -{% if item.registry is defined %} -FROM {{ item.registry.url }}/{{ item.image }} -{% else %} FROM {{ item.image }} -{% endif %} -RUN if [ $(command -v apt-get) ]; then apt-get update && apt-get install -y python sudo bash ca-certificates cron iputils-ping openssh-client openssh-server && apt-get clean; \ +RUN if [ $(command -v apt-get) ]; then apt-get update && apt-get install -y python sudo bash ca-certificates && apt-get clean; \ elif [ $(command -v dnf) ]; then dnf makecache && dnf --assumeyes install python sudo python-devel python2-dnf bash && dnf clean all; \ - elif [ $(command -v yum) ]; then yum makecache fast && yum install -y python sudo yum-plugin-ovl bash anacron iputils openssh-clients openssh-server && sed -i 's/plugins=0/plugins=1/g' /etc/yum.conf && yum clean all; \ + elif [ $(command -v yum) ]; then yum makecache fast && yum install -y python sudo yum-plugin-ovl bash && sed -i 's/plugins=0/plugins=1/g' /etc/yum.conf && yum clean all; \ elif [ $(command -v zypper) ]; then zypper refresh && zypper install -y python sudo bash python-xml && zypper clean -a; \ elif [ $(command -v apk) ]; then apk update && apk add --no-cache python sudo bash ca-certificates; \ elif [ $(command -v xbps-install) ]; then xbps-install -Syu && xbps-install -y python sudo bash ca-certificates && xbps-remove -O; fi diff --git a/molecule/generic_files/prepare.yml b/molecule/generic_files/prepare.yml index eb8c72c..f8aa51a 100644 --- a/molecule/generic_files/prepare.yml +++ b/molecule/generic_files/prepare.yml @@ -1,17 +1,41 @@ --- -- name: prepare servers - Debian only - hosts: borgbackup_servers - gather_facts: true +- name: prepare debian-based systems + hosts: all:!centos + gather_facts: false tasks: + - name: install required packages + apt: + name: + - bash + - ca-certificates + - cron + - iputils-ping + - openssh-client + +- name: prepare centos-based systems + hosts: centos + gather_facts: false + tasks: + - name: install required packages + yum: + name: + - anacron + - iputils + - openssh-clients + +- name: prepare debian-based backupservers + hosts: borgbackup_servers + gather_facts: false + tasks: + - name: install required packages + apt: + name: + - openssh-server - name: start ssh - Debian Server command: service ssh start -# note: https://forums.docker.com/t/any-simple-and-safe-way-to-start-services-on-centos7-systemd/5695/8 -# needs to be implemented -# - name: start sshd -# command: service sshd start -- name: prepare all - hosts: all:!borgbackup_servers:!centos +- name: prepare lamp + hosts: lamp tasks: - name: Install required packages apt: