Skip to content

Docker Image for testing Ansible deployment using Docker with Molecule Docker, by FEROX.

License

Notifications You must be signed in to change notification settings

frxyt/docker-molecule-dind

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Docker Image for testing Ansible deployment using Docker with Molecule Docker, by FEROX

Docker Cloud Automated build Docker Cloud Build Status Docker Pulls GitHub issues GitHub last commit

This image packages cron, Docker, logrotate, Python, OpenSSH-Server, sudo and systemd. It can be used to test Ansible deployments using Docker within Molecule Docker. The purpose of this image is to be as close as possible to a random VM Debian Buster box that can be found on any cloud hosting provider.

Docker Hub Image

frxyt/molecule-dind

Usage

  1. Create your Ansible role: molecule init role <name>
  2. cd <name>
  3. Edit molecule.yml:
    ---
    dependency:
      name: galaxy
    driver:
      name: docker
    platforms:
      - name: molecule
        image: frxyt/molecule-dind:latest
        privileged: true
    provisioner:
      name: ansible
    verifier:
      name: ansible
  4. If you need a specific user, you can also edit Dockerfile.j2 and add these lines:
    RUN set -ex; \
        groupadd -r debian; \
        useradd --no-log-init -r -g debian debian; \
        adduser debian sudo; \
        echo 'debian ALL=(ALL) NOPASSWD:ALL' > /etc/sudoers.d/debian;
    USER debian
  5. Add a file prepare.yml:
    ---
    - name: Prepare
      hosts: all
      #vars:
      #  ansible_become: true
      tasks:
        - name: Start Docker
          service:
            name: docker
            state: started
  6. If you use a specific user, edit also converge.yml to add these lines (and make sure they are uncommented in prepare.yml) :
    vars:
      ansible_become: true
  7. molecule create
  8. molecule converge
  9. molecule login
  10. molecule destroy

Notes

  • Despite the fact this image embed systemd, systemd isn't properly started when the image is ran with Molecule.
    • Due to that, journald is unavailable.

Build & Test

docker build -f Dockerfile -t frxyt/molecule-dind:latest .
docker run --rm -it --privileged frxyt/molecule-dind:latest bash
service docker start
docker run --rm -it debian bash

License

This project and images are published under the MIT License.

MIT License

Copyright (c) 2020 FEROX YT EIRL, www.ferox.yt <devops@ferox.yt>
Copyright (c) 2020 Jérémy WALTHER <jeremy.walther@golflima.net>

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

About

Docker Image for testing Ansible deployment using Docker with Molecule Docker, by FEROX.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published