Docker Image for testing Ansible deployment using Docker with Molecule Docker, by FEROX
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: https://hub.docker.com/r/frxyt/molecule-dind
- GitHub: /~https://github.com/frxyt/docker-molecule-dind
frxyt/molecule-dind
- Create your Ansible role:
molecule init role <name>
cd <name>
- 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
- 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
- Add a file
prepare.yml
:--- - name: Prepare hosts: all #vars: # ansible_become: true tasks: - name: Start Docker service: name: docker state: started
- If you use a specific user, edit also
converge.yml
to add these lines (and make sure they are uncommented inprepare.yml
) :vars: ansible_become: true
molecule create
molecule converge
molecule login
molecule destroy
- 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.
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
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.